Professional Documents
Culture Documents
MATH IV CHAPTER 5 LPP Slides
MATH IV CHAPTER 5 LPP Slides
2 Euler’s Method
Improved Euler’s Method
Modified Euler’s Method
Example
Exact Solution
y (x) = A0 + A1 (x − x0 ) + A2 (x − x0 )2 + . . . , (2)
(x − x0 ) 0 (x − x0 )2 00
y (x) = y (x0 ) + y (x0 ) + y (x0 ) + . . . (3)
1! 2!
x 0 x2 x 3 000
y (x) = y (0) + y (0) + y 00 (0) + !y (0) + . . . (4)
1! 2! 3
Example
Example
Evaluate the solution to the differential equation y 0 = (1 + x)xy 2 subject to
y (0) = 1 by taking five terms in Maclaurin’s series for x = 0 (0.1) 0.4. Compare
with the exact solution.
Solution: Maclaurin’s series is
x 0 x2 x 3 000 x4
y (x) = y (0) + y (0) + y 00 (0) + !y (0) + y (4) + . . . (5)
1! 2! 3 4!
The given equation is
Solution Cont...
000
y (x) = 4yy 0 + 8xyy 0 + 2xy 02 + 2y 2 + 2xyy 00 + 2x 2 yy 00 + 2x 2 y 02
000
y (0) = 2
y (4)
= 2yy 02 + 6y 02 + 6xy 0 y 00 + 6yy 00 + 12yy 0 + 14xyy 00
+ 12yy 02 + 6x 2 y 0 y 00 + 2x 2 yy 00 ,
(4)
y (0) = 6
x x2 x3 x4
y (x) = 1+
(0) + (1) + (2) + (6)
1 2 3! 4!
x2 x3 x4
∴ y (x) = 1+ + + + .... (6)
2 3 4
Solution Cont...
Solution Cont...
Solution Cont...
Therefore,
x2 x3
1
− = + −1
y 2 3
3x 2 + 2x 3
= −1
6
3x 2 + 2x 3 − 6
=
6
6
∴y = . (7)
6 − 3x 2 − 2x 3
Solution Cont...
Since
6
y = .
6 − 3x 2 − 2x 3
Now putting x = 0.1, 0.2, 0.3, 0.4 successively in Equation 8, we get
y1 = y (0.1) = 1.0053619.
y2 = y (0.2) = 1.0231924.
y3 = y (0.3) = 1.0570825.
y4 = y (0.4) = 1.1127596.
Exercise III.1
Euler’s Method
Euler’s Method
y1 = y0 + (x1 − x0 )f (x0 , y0 )
∴ y1 = y0 + h f (x0 , y0 ). (9)
y2 = y1 + h f (x1 , y1 ). (10)
Note: The process is very slow and to obtain it with reasonable accuracy
using Euler Method. We have to use h very small.
As we assuming that the line passes through the point (x0 , y0 ) and (x1 , y1 ).
Therefore, the equation is
1
(1)
y1 = y0 + (x1 − x0 ) f (x0 , y0 ) + f (x1 , y1 )
2
h (1)
or y1 = y0 + f (x0 , y0 ) + f (x1 , y1 ) .
2
Therefore, we have
h
y1 = y0 + (f (x0 , y0 ) + f [x0 + h, y0 + h f (x0 , y0 )]) . (13)
2
That is, the slope at the middle point whose abscisse is the average of x0
and x0 + h2 . The equation of line L is
h h
y − y0 = (x − x0 ) f x0 + , y0 + f (x0 , y0 . (16)
2 2
Putting x = x1 , we get
h h
y1 = y0 + (x1 − x0 ) f x0 + , y0 + f (x0 , y0
2 2
h h
∴ y1 = y0 + h f x0 + , y0 + f (x0 , y0 . (17)
2 2
Proceeding in the same way, the general formula can be show that
h h
ym+1 = ym + h f xm + , ym + f (xm , ym . (18)
2 2
Example
Solve dy
dx = 1 − y , y (0) = 0 in the range 0 ≤ x ≤ 0.3 using the following
methods by choosing h = 0.1
1 Euler’s Method.
2 Improved Euler’s Method.
3 Modified Euler’s Method by.
Compare the answers with the exact solution.
dy
Given that dx = 1 − y, y (0) = 0, h = 0.1.
Now, we have to find out the solutions at x = 0.1, x = 0.2 and x = 0.3.
Euler’s Method: The algorithm is if dy
dx = f (x, y ), y (x0 ) = y0 , then
ym+1 = ym + hf (xm , ym ).
Here f (x, y ) = 1 − y , h = 0.1, x0 = 0 and y (0) = y0 = 0. Hence
= 1 − ym − h(1 − ym )
(1)
∴f xm+1 , ym+1 = (1 − h)(1 − ym )
So
h
ym+1 = ym + [1 − ym + (1 − h)(1 − ym )]
2
h
= ym + [(1 − ym )(1 + 1 − h)]
2
h
⇒ ym+1 = ym + [(2 − h)(1 − ym )] .
2
Here, h = 0.1
ym+1 = ym + 0.095(1 − ym ) = 0.095 + 0.905ym .
Since,
h
= ym + h 1 − (1 − ym )
2
0.1
= ym + 0.1 1 − (1 − ym )
2
∴ ym+1 = 0.095 + 0.905ym .
y = 1 − ex .
y1 = y (0.1) = 0.0951625.
y2 = y (0.2) = 0.1812691.
y3 = y (0, 3) = 0.2591817.
Exercise III.2
Given that
dy 2x
=y− , y (0) = 1
dx y
in the range 0 ≤ x ≤ 0.2 using
1 Euler’s Method,
2 Improved Euler’s Method,
3 Modified Euler’s Method
Take h = 0.1.
h 0 h2 00
y1 = y0 + y + y + ...
1! 0 2! 0
This implies that Euler’s method agrees with Taylor’s series solution up to
term in h.
Hence, Runge-Kutta method of first order is Euler’s method
h2 00 h3 000
y1 = y (x0 + h) = y0 + hy00 + y + y0 + . . . (21)
2! 0 3!
h2 0
y1 = y0 + hf (x0 , y0 ) + f (x0 , y0 ) + O(h3 )
2
h2 00
= y0 + hf (x0 , y0 ) + y0 + O(h3 )
2
Then,
h2 00
y1 = y0 + hf (x0 , y0 ) + y + O(h3 ). (22)
2 0
k1 = hf (x0 , y0 )
k2 = hf (x0 + h, y0 + k1 )
1
k = (K1 + k2 )
2
∴ y1 = y0 + k.
k1 = hf (x0 , y0 )
k2 = hf (x0 + h, y0 + k1 )
k3 = hf (x0 + h, y0 + k2 )
h k1
k4 = hf (x0 + , y0 + )
2 2
1
k = (k1 + 4k4 + k3 )
6
∴ y1 = y0 + k.
k1 = hf (x0 , y0 )
h k1
k2 = hf x0 + , y0 +
2 2
h k2
k3 = hf x0 + , y0 +
2 2
k4 = hf (x0 + h, y0 + k3 )
1
k = (k1 + 2k2 + 3k3 + k4 )
6
∴ y1 = y0 + k and x1 = x0 + h.
k1 = hf (x1 , y1 )
h k1
k2 = hf x1 + , y1 +
2 2
h k2
k3 = hf x1 + , y1 +
2 2
k4 = hf (x1 + h, y1 + k3 )
1
k = (k1 + 2k2 + 3k3 + k4 )
6
∴ y2 = y1 + k and x2 = x1 + h.
Example
Here, we have
k1 = hf (x0 , y0 ) = −0.1
k2 = hf (x0 + h, y0 + k1 ) = −0.089
k3 = hf (x0 + h, y0 + k2 ) = −0.0901
h k1
k4 = hf (x0 + , y0 + ) = −0.09475
2 2
1
k = (k1 + 4k4 + k3 ) = −0.9485
6
∴ y1 = y0 + k = 0.90515.
k1 = hf (x1 , y1 ) = −0.089515
k2 = hf (x1 + h, y1 + k1 ) = −0.0775635
k3 = hf (x1 + h, y1 + k2 ) = −0.0787586
h k1
k4 = hf (x1 + , y1 + ) = −0.0837892
2 2
1
k = (k1 + 4k4 + k3 ) = −0.0839051
6
∴ y2 = y1 + k = 0.82124490
Here,
k1 = hf (x0 , y0 ) = −0.1
h k1
k2 = hf x0 + , y0 + = −0.09475
2 2
h k2
k3 = hf x0 + , y0 + = −0.0550125
2 2
k4 = hf (x0 + h, y0 + k3 ) = −0.0894987
1
k = (k1 + 2k2 + 3k3 + k4 ) = −0.0948372
6
∴ y1 = y0 + k = 0.9051627.
k1 = hf (x1 , y1 ) = −0.0895162
h k1
k2 = hf x1 + , y1 + = −0.0837904
2 2
h k2
k3 = hf x1 + , y1 + = −0.0840767
2 2
k4 = hf (x1 + h, y1 + k3 ) = −0.0781085
1
k = (k1 + 2k2 + 3k3 + k4 ) = −0.083893
6
∴ y2 = y1 + k = 0.8212696.
Exercise III.3
Using Runge -Kutta method of fourth order, solve for y (0.1), y (0.2) and y (0.3)
given that
y 0 = xy + y 2 , y (0) = 1.