0% found this document useful (0 votes)
43 views10 pages

ODE Notes 2

The document discusses numerical techniques for solving ordinary differential equations. It introduces Euler's method and modified Euler's method for approximating solutions to differential equations. An example applies Euler's method to solve a sample differential equation numerically and compute an approximate solution at a given point.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views10 pages

ODE Notes 2

The document discusses numerical techniques for solving ordinary differential equations. It introduces Euler's method and modified Euler's method for approximating solutions to differential equations. An example applies Euler's method to solve a sample differential equation numerically and compute an approximate solution at a given point.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

342 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES

x 3 x7 2
Thus, + + x 11 represents y correct to 4 decimal places. In the range |x| ≤ .988.
3 63 2079
i.e. –0.988 ≤ x ≤ 0.988.
dy 1
Example 13. Integrate the differential equation = x sin πy with y = at x = 0, by Picard’s
dx 2
method of successive approximations.
y = y0 + z
x0
x
b g
f x, y dx . ...(1)

1
Sol. The first approximation y1 of y is obtained by substituting y = In the right hand
2
member of (1) i.e., we have
1
y1 =
2
x 1
z
+ x sin π. dx = + .
0 2
1 x2
2 2
FG IJ
H K
Similarly, the second and third approximation y2 and y3 are given as
R| e1 + x j U|
z S|T 2 V|Wdx = z
2
1 x 1 x πx 2
y2 = + x sin π. + x cos dx
2 0 2 0 2

F π x + ...I dx
+ z xG 1 –
2 4

H 8 JK
1 x
= 0
2
1 x 2 π 2x 6
= + – + ...
2 2 48

and y3 =
1
2
+ z |RS|T12 + x2 – π48x + 12 + z x cos πFGH x2 – π 8x IJKdx|UV|W
0
x
x sin π
2 2 6 x

0
2 2 6

R| 1 F πx π x I U|
+ z xS1 – G
2

|T 2 H 2 48 JK V|W
2 2 6
1 x
= – + ... dx
2 0

1 x 2 π 2x 6
+
= – + ...
2 2 48
We observe that y2 agree with y3 upto and including term in x6.
1 x2 –x 6
We can use the relation y =+ with the knowledge that the error is approximately .
2 2 5
Thus, we can find y1 and y2 correct to 4 decimal places with h = 0.1.

7.4 EULER’S METHOD


The oldest and simplest method was derived by Euler. In this method, we determine the change
Δy is y corresponding to small increment in the argument x . Consider the differential equation.
dy
= f ( x, y ) ...(1)
dx
with the initial condition y ( x0 ) = y0 .
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 343

Integrating (1) w.r.t. x between x0 and x1, we get


y1 x1
∫ y0
dy = ∫ x0
f ( x , y ) dx

x1
y1 = y0 + ∫ x0
f ( x , y ) dx ...(2)

Now, replacing f ( x, y ) by the approximation f ( x0 , y0 ) , we get


x1
y1 = y0 + ∫ x0
f ( x0 , y0 ) dx

= y0 + f ( x0 , y0 )( x1 − x0 )
y1 = y0 + hf ( x0 , y0 ) (3 x1 – x0 = Δx = h)
This is the formula for first approximation y1 of y.
Similarly, second approximation y2 is given by
y2 = y1 + hf ( x1 , y1 )
In general,
yn + 1 = yn + hf ( xn , yn )

7.5 EULER’S MODIFIED METHOD


Instead of approximating f ( x, y ) by f ( x0 , y0 ) in equation (2). Let the integral is approximated by
Trapezoidal rule to botain.
h
[ f ( x0 , y0 ) + f ( x1 y1 )]
y1 = y0 +
2
We obtain the iteration formula,

y1
n +1 h
2⎣
( n)
= y0 + ⎡⎢ f ( x0 , y0 ) + f x1 , y1 ⎤⎥ (
⎦ ) n = 0,1, 2......

where, y1(n) is the nth approximation to y1.


The above iteration formula can be started by y1(1) from Euler’s method.
y1(0) = y0 + h(x0,y0)
Example 14. Using Euler’s method, compute y(0.5) for differential equation
dy 2
= y − x 2 , with y = 1 when x = 0
dx

0.5
Sol. Let h= = 0.1
5

x0 = 0, y0 = 1, f ( x, y ) = y 2 − x 2
Using Euler’s method we have
yn + 1 = yn + hf ( xn , yn )
344 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES

But considering n= 0,1, 2, ........in succession, we get


y1 = y0 + hf ( x0 , y0 )

( )
= 1 + 0.1 12 − 0 = 1.10000

y2 = y1 + hf ( x1 , y1 )

= 1.10000 + 0.1 ⎡⎣(1.10000 ) − ( 0.1) ⎤⎦ = 1.22000


2 2

y3 = y2 + hf ( x2 , y2 )

= 1.22000 + 0.1 ⎡(1.22 ) − ( 0.2 ) ⎤ = 1.36484


2 2
⎣ ⎦
y4 = y3 + hf ( x3 , y3 )

= 1.36484 + 0.1[(1.36484)2 _ (0.3 ) ] = 1.54212


2

y5 = y4 + hf ( x4 , y4 )

= 1.54212 + 0.1 ⎡(1.54212 ) − (0.4 ) ⎤ = 1.76393


2 2
⎣ ⎦
Hence, the value of y at x = 0.5 is 1.76393. Ans.

Example 15. Using Euler’s method, compute y(0.04) for the differential equation.
y1 = –y with y(0) = 1 (Take h = 0.01)
Sol. Using Euler’s method
yn + 1 = yn + hf ( xn , yn )
By considering n = 0,1, 2,......... in succession, we obtain
y1 = y0 + hf ( x0 , y0 )
= 1 + 0.01 ( −1 ) = 0.99
y2 = y1 + hf ( x1 , y1 )
= 0.99 + 0.01 ( −0.99) = 0.9801
y 3 = 0.9801 + 0.01 ( −0.9801 ) = 0.970299
y 4 = 0.970299 + 0.01 ( −0970299 ) = 0960596
Hence, the value of y ( 0.04 ) is 0.960596. Ans.

Example 16. Find the solution of differential equation


dy
= xy with y(1) = 5
dx
in the interval 1,1.5] using h = 0.1.
Sol. As per given we have
x1 = 1, y0 = 5, f ( xy ) = xy
Using Euler’s method
yn + 1 = yn + hf ( xn , yn )
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 345

Now, by considering n= 0,1, 2...... in succession, we get


For n= 0 y1 = y0 + 0.1 f ( x0 , y0 )

= 5 + 0.1 (1 × 5 ) = 5.5
For n= 1 y2 = y1 + 0.1 f ( x1 , y1 )
= 5.5 + 0.1 (1.1× 5.5 ) = 6.105

For n = 2 y3 = y2 + 0.1 f ( x2 , y2 )
= 6.105 + 0.1(1.2 × 6.105) = 6.838
For n= 3 y4 = y3 + 0.1 f ( x3 , y3 )

= 6.838 + 0.1 (1.3 × 6.838 ) = 7.727


For n= 4 y5 = y4 + 0.1 f(x4, y4)
= 7.727 + 0.1 (1.4 × 7.727 ) = 8.809

Hence, the value of y (1.5) is 8.809. Ans.

y −x
Example 17. Given y′ = with y0 = 1 find y for x = 0.1 in four steps by Euler’s method.
y+x
0.1
Sol. Let h= = 0.025 , given y0 = 1 , where x = 0
4
We know that
yn + 1 = yn + hf ( xn , yn )
By putting n= 0,1, 2, 3, we obtain
y1 = y0 + hf ( x0 , y0 )
(1 − 0 )
= 1 + 0.025 = 1.025
(1 + 0 )
⇒ y1 = 1.025
Again, y2 = y1 + hf ( x1 , y1 )

(1.025 − 0.025)
= 1.025 + 0.025 (where x1 = x0 + h = 0 + 0.025 ⇒ x1 = 0.025 )
(1.025 + 0.025)
= 1.0488
⇒ y2 = 1.0488
Now again y3 = y2 + hf(x2, y2) (where x2 = x0 + 2h = 0 + 2 × 0.025 = 0.05)
b1.0488 – 0.05g
=1.0488 + 0.025
b1.0488 + 0.05g = 1.07152

⇒ y3 = 1.07152
y4 = y3 + hf ( x3 , y3 ) (where x 3 = x 0 + 3 h = 0 + 3 × 0.025 = 0.075 )
346 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES

(1.07152 − 0.075 )
= 1.07152 + 0.025 = 1.09324
(1.07152 + 0.075)
⇒ y 4 = 1.09324 at ( x4 = x0 + 4h = 0 + 4 × 0.025 = 0.1)
Hence, y(0.1) = 1.0932 . Ans.

dy
Example 18. Given = x + y with initial condition y(0) = 1. Find y(.05) and y(.1) correct to 6
dx
decimal places.
Sol. Using Euler’s method, we obtain
y1(0) = y1 = y0 + hf ( x0 , y0 ) = 1 +.05 (0 + 1) = 1.05
We improve y1 by using Euler’s modified method
h
( )
y1( ) = y0 + ⎡ f ( x0 , y0 ) + f x1 , y10 ⎤
1
2⎣ ⎦
.05
= 1+ ⎡(0 + 1) + (.05 + 1.05 )⎤⎦
2 ⎣
= 1.0525.
.05
y1( ) = 1 + ⎡( 0 + 1)+ (.05 + 1.0525 )⎤⎦
2
2 ⎣
=1.0525625
( 3) .05
y1 = 1 + ⎡( 0 + 1) + (.05 + 1.0525625 )⎤⎦
2 ⎣
= 1.052564
( 4) .05
y1 = 1 + ⎡(0 + 1) + (.05 + 1.052564 )⎤⎦
2 ⎣
= 1.0525641 .

Since, y1( 3 ) = y1( 4 ) = 1.052564 correct to 6 decimal places. Hence we take y1 = 1.052564 i.e., we
have y (.05 ) = 1.052564
Again, using Euler’s method, we obtain
y2( ) = y2 = y1 + hf ( x1 , y1 )
0

= 1.052564 + .05 (1.052564 + .05 )


= 1.1076922.
We improve y2 by using Euler’s modified method
( 1) .05
y2 = 1.052564 + ⎡(1.052564 + .05 ) + (1.1076922 + .1)⎤⎦
2 ⎣
= 1.1120511.
.05
y2( ) = 1.052564 + ⎡(1.052564 + .05) + (1.1120511 + .1)⎤⎦
2
2 ⎣
= 1.1104294.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 347

.05
y(2 ) = 1.052564 + ⎡(1.052564 + .05 ) + (1.1104294 + .1)⎤⎦
3
2 ⎣
= 1.1103888.
.05
y(2 ) = 1.052564 + ⎡(1.052564 + .05 ) + (1.1103888 + .1)⎤⎦
4
2 ⎣
= 1.1103878.
.05
y(2 ) = 1.052564 + ⎡(1.052564 + .05 ) + (1.1103878 + .1)⎤⎦
5
2 ⎣
= 1.1103878.
Since, y2( 4 ) = y(25 ) = 1.1103878, correct to 7 decimal places. Hence, we take y 2 = 1.1103878.
Therefore, we have y (.1) = 1.110388, correct to 6 decimal places. Ans.

Example 19. Find y(2.2) using Euler’s method for


dy
= − xy 2 , where y(2) = 1. (Take h = .1 )
dx
Sol. By Euler’s method, we obtain,
y1(0) = y1 = y0 + hf ( x0 , y0 ) = 1 + .1 (−2)(−1) = .8.
2

This value of y1 is improved by using Euler’s modified method


1 h
2⎣
( )
y1( ) = y0 + ⎡⎢ f ( x0 , y0 ) + f x1 , y1( ) ⎤⎥
0

=1 +
0.1
2
{−2 (1) + (−2.1)(.8 ) }
2 2

= .8328

Similarly
( 2)
y1 = 1 +
0.1
2
{
−2 (1) + ( −2.1)(.8328 )
2 2
}
= .8272

y1( ) = 1 +
3 0.1
2
{
−2 (1) + ( −2.1)(.8272 )
2 2
}
= .8281

y1( ) =1 +
4 0.1
2
{
−2 (1) + ( −2.1)(.8281)
2 2
}
=.8280

y1( ) = 1 +
5 0.1
2
{
−2 (1) + ( −2.1)(.8280 )
2 2
}
= .8280
Since y1( 4 ) = y1( 5 ) = 0.8280. Hence, we take y1 = .828 at x1 = 2.1
Now, if y2 is the value of y at x = 2.2. Then, we apply Euler’s method to compute y ( 2.2) ,
i.e., we obtain
y2(0 ) = y2 = y1 + hf ( x1 , y1 )

= .828 + .1 ( −2.1)(.828 ) = .68402


2
348 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES

Now, using Euler’s modified formula, we obtain


(1) 0.1 ⎡
y2 = .828 + (−2.1)(.828 )2 + (−2.2 )(.68402 )2 ⎤⎦
2 ⎣
= .70454
0.1 ⎡
y2( ) = .828 + (−2.1) (.828 ) + ( −2.2 )(.70454 ) ⎤
2 2 2
2 ⎣ ⎦
= .70141.
0.1 ⎡
y2( ) = .828 + (−2.1)(.828 )2 + (−2.2 )(.70141)2 ⎤⎦
3
2 ⎣
= .70189.
0.1 ⎡
y2( ) = .828 + (−2.1)(.828 )2 + (−2.2 )(.70189 )2 ⎤⎦
4
2 ⎣
= .70182
0.1 ⎡
y2( ) = .828 + (−2.1)(.828 )2 = (−2.2)(.70182)2 ⎤⎦
5
2 ⎣
= .70183
(4) ( 5)
Since, y2 = y2 = .7018 , correct to 4 decimal places.
Hence, we have y ( 2.2) = .7018. Ans.

Example 20. Find y(.2) and y(.5) Given


dy
= log10 ( x + y )
dx
with initial condition y = 1 for x = 0.
dy
Sol. Let = f ( x , y ) = log10 ( x + y ) and h = .2
dx
By Euler’s formula, we have
y1(0 ) = y1 = y 0 + hf ( x0 , y0 )
= 1 + .2log (0 + 1) = 1.
Now, we improve this value by using Euler’s modified formula and thus we obtain
1 h
2⎣
( 0
)
y1( ) = y0 + ⎡⎢ f ( x0 , y0 ) + f x1 , y1( ) ⎤⎥

0.2
=1 +
2
{log (0 + 1) = log (.2 + 1)}
= 1.0079
0.2
( 2)
y1 = 1 +
2
{log (0 + 1) + log (.2 + 1.0079)}
= 1.0082
0.2
y1( ) = 1 +
3
2
{log (0 + 1) + log (.2 + 1.0082)}
= 1.0082
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 349

Since, y1( 2 ) = y1( 3 ) = 1.0082 . Hence, we take y1 = 1.0082 at x = .2 , i.e., y (.2 ) = 1.0082. Ans.
Again using Euler’s formula, we obtain
y2(0 ) = y 2 = y1 + hf ( x1 + y1 )
= 1.0082 + 0.3 ⎡⎣ log (0.2 + 1.0082 )⎤⎦ = 1.0328
To improve y2 , we use Euler’s modified formula and we obtain
0.3
y (1) = 1.0082 + ⎡log (1.0328 + .5 )+ log (.2 + 1.0082 )⎤⎦
2
2 ⎣
= 1.0483
0.3
y2( ) = 1.0082 + ⎡log (1.0483 + .5 ) log (.2 + 1.0082)⎤⎦
2
2 ⎣
= 1.049
( 3) 0.3
y2 = 1.0082 + ⎡log (1.049 + .5 ) + log (.2 + 1.0082 )⎤⎦
2 ⎣
= 1.0490
(3) ( 2)
Since y2 = y2 = 1.0490, we take y2 = 1.0490 , i.e., y (.5 ) = 1.0490 . Ans.

Example 21. Using Euler’s modified method, compute y(0.1) correct to six decimal figures, where
dy 2
= x + y with y = .94 when x = 0.
dx
Sol. By Euler’s method, we have
y 1(0 ) = y 1 = y 0 + hf ( x 0 , y 0 )
= .94 + .1( 0 = .94 )
= 1.034
Now, we improve y1 by using Euler’s modified formula and we obtain
1 h
2⎣
0
(
y1( ) = y0 + ⎡⎢ f ( x0 , y0 ) + f x1 y1( ) ⎤⎥
⎦ )
=.94 +
0.1
2
b
0 + . 94 + 1 g {a f 2
+ 1.034 }
= 1.0392

y(2)
1
= .94 +
0.1 ⎡
2 ⎣
{
(0 + .94 ) + (.1)2 + 1.0392 ⎤⎦ }
=1.03946

( 3)
y1 = .94 +
0.1 ⎡
2 ⎣
{
(0 + .94 ) + (.1)2 + 1.03946 ⎤⎦ }
= 1.039473

y1( ) = .94 +
4 0.1 ⎡
2 ⎣
(0 + .94 ) + { (.1) + 1.039473}⎤⎦
2

= 1.0394737
350 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES

Since, y1( 3 ) = y1( 4 ) = 1.039473, correct to 6 decimal places


Hence, we have y (.1) = 1.039473. Ans.
dy
Example 22. Using Euler’s modified method, solve numerically the equation =x+ y with
dx
y(0) = 1 for 0 ≤ x ≤ 0.6, in steps of 0.2.
Sol. The interval h = 0.2

By Euler’s method, we obtain y1( 0 ) = y1 = y0 + h ( x0 , y0 )

( )
= 1 + 0.2 0 + 1 = 1.2.

The value of y1(0 ) , thus obtained is improved by modified method.


(n + 1)
y1
h
2⎣
(
(n )
= y0 + ⎡⎢ f ( x0 , y0 ) + f x1 , y1 ⎤⎥
⎦ )
By considering n = 0, we obtain
h
y1(1) = y0 + B ( N 0 , O0 ) + B ( N1 , O1 )
2

=1 +
0.2 ⎡
2 ⎣
( )(
0 + 1 + 0.2 + 1.2 ⎤
⎦ )
= 1.2295
By considering n= 1 , we obtain

y1( ) = 1 +
2 0.2 ⎡
2 ⎣
( ) (
0 + 1 + 0.2 + 1.2295 ⎤
⎦ )
= 1.2309.
By considering n= 2 , we obtain
( 3)
y1 = 1 +
0.2 ⎡
2 ⎣
( )(
0 + 1 + 0.2 + 1.2309 ⎤
⎦ )
= 1.2309.
Since y1( 2 ) = y1( 3 ) == 1.2309. Hence, we take y1 = 1.2309 at x = 0.2 and proceed to compute y at
x = 0.4.
Again, applying Euler’s method, we obtain

(
y2( ) = y 2 = 1.2309 + 0.2 0.2 + 1.2309 = 1.49279
0
)
Now, we apply modified method for more accurate approximations and we obtain

y2( ) = 1.2309 +
1 .2 ⎡
2⎣
(
2+ ) (
1.2309 + 0.4 + 1.49279 ⎤
⎦)
= 1.52402

( 2)
y2 = 1.2309 +
.2 ⎡
2⎣
( )(
2 + 1.2309 + 0.4 + 1.52402 ⎤
⎦ )
= 1.525297
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATION 351

.2
( ) (
y2( ) = 1.2309 + ⎡ 2 + 1.2309 + 0.4 + 1.525297 ⎤
3
2⎣ ⎦ )
= 1.52535
.2
( ) (
y2( ) = 1.2309 + ⎡ .2 1.2309 + 0.4 + 1.52535 ⎤
4
2 ⎣ ⎦ )
= 1.52535
Since, y2( )
3
= y2( ) = 1.52535 .
4
Hence, we take y2 = 1.52535 at x = 0.4 . To find the value of y ( = y3 )
for x = 0.6 , we apply Euler’s method to have
0
⎣ (
y(3 ) = y3 = 1.52535 + .2 ⎡ 4 + 1.52535 ⎤ = 1.85236
⎦ )
For better approximations, we use Euler’s modified formula and we obtain

y(3 ) = 1.52535 +
1 .2 ⎡
2⎣
( ) (
.4 + 1.52535 + 0.6 + 1.85236 ⎤
⎦ )
= 1.88496
.2
( ) (
y3( ) = 1.52535 + ⎡ .4 + 1.52535 + 0.6 + 1.88496 ⎤
2
2⎣ ⎦ )
= 1.88615
( 3)
y3 = 1.52535 +
.2 ⎡
2⎣
( )(
.4 + 1.52535 + 0.6 + 1.88615 ⎤
⎦ )
= 1.88619
(4)
y3 = 1.52535 +
.2 ⎡
2⎣
( )(
.4 + 1.52535 + 0.6 + 1.88619 ⎤
⎦ )
= 1.88619, correct to 5 decimal places.
Since, y3( 3) = y3( 4) = 1.88619. Hence, we take y = 1.88619 at x = 0.6. Ans.

PROBLEM SET 7.1


1 . Solve by Taylor’s method, y′ = x′′ + y′′ , y ( 0 ) = 1 . Computer y (0.1). [Ans. 1.11146]
dy 2x
2 . Solve by Taylor’s method, = y − ; y ( 0 ) = 1 . Also compute y (0.1) . [Ans. 1.0954]
dx y
dy 1
3 . Given differential equation = with y ( 4 ) = 4. Obtain y ( 4.1) and y ( 4.2) by Taylor’s
dx x 2 + y
series method. [Ans. 4.005. 4.0098]
dy
4 . Apply Picard’s method to find the third approximation of the solution of = x + y2 with
dx
3 2 4 3
the condition y(0) = 1. [Ans. = 1 + x + x + x + ... ]
2 3

5 . Using Picard’d method, obtain the solution of


dy
dx
( )
= x 1 + x 3 y ; y (0 ) = 3 Compute the value of

y (0.1) and y (0.2) . [Ans. 3.005, 3.020]

You might also like