ODE Notes 2
ODE Notes 2
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.
x1
y1 = y0 + ∫ x0
f ( x , y ) dx ...(2)
= 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 )
y1
n +1 h
2⎣
( n)
= y0 + ⎡⎢ f ( x0 , y0 ) + f x1 , y1 ⎤⎥ (
⎦ ) n = 0,1, 2......
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
( )
= 1 + 0.1 12 − 0 = 1.10000
y2 = y1 + hf ( x1 , y1 )
y3 = y2 + hf ( x2 , y2 )
y5 = y4 + hf ( x4 , y4 )
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.
= 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 )
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
.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.
=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 )
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
( )
= 1 + 0.2 0 + 1 = 1.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.