Improved Euler Method & Modified Euler Method (Second Order Runge Kutta Method) Requirements: Geometrical Interpretation of Derivative
Improved Euler Method & Modified Euler Method (Second Order Runge Kutta Method) Requirements: Geometrical Interpretation of Derivative
Improved Euler Method & Modified Euler Method (Second Order Runge Kutta Method)
(i) This method is a self-starting method of predictor corrector type having greater accuracy
than Euler method.
(ii) It is known by a variety of names such as Euler Trapezoidal method, Euler Predictor-
Corrector method, the Improved Euler Method, Heun’s method, Euler-Cauchy method and
Modified Euler method.
𝑑𝑦
Consider the first order differential equation 𝑑𝑥 = 𝑓(𝑥, 𝑦) with initial condition 𝑦 = 𝑦0 when 𝑥 = 𝑥0
To find the value of 𝑦 at 𝑥 = 𝑥𝑛+1 , Improved Euler Method makes use of average slope of 𝑦𝑛′ (i.e.
′ ′ ℎ
𝑓(𝑥𝑛 , 𝑦𝑛 )) and 𝑦𝑛+1 (i.e. 𝑓(𝑥𝑛+1 , 𝑦𝑛+1 )) as 𝑦𝑛+1 = 𝑦𝑛 + 2 {𝑦𝑛′ + 𝑦𝑛+1 }
ℎ
or 𝑦𝑛+1 = 𝑦𝑛 + {𝑓(𝑥𝑛 , 𝑦𝑛 ) + 𝑓(𝑥𝑛+1 , 𝑦𝑛+1 )}
2
Let us consider a line passing through (𝑥0 , 𝑦0 ) whose slope is the average of the slopes at (𝑥0 , 𝑦0 ) and
(1)
(𝑥1 , 𝑦1 ).
(1) (1)
Here 𝑦1 is known as the first approximation of 𝑦1 and is obtained by Euler method as 𝑦1 = 𝑦0 +
ℎ𝑓(𝑥0 , 𝑦0 )
The equation of the line passing through (𝑥0 , 𝑦0 ) and having slope which is the average of the slopes at
(1)
(1) 𝑓(𝑥0 ,𝑦0 )+𝑓((𝑥1 ,𝑦1 )
(𝑥0 , 𝑦0 ) and (𝑥1 , 𝑦1 ) is 𝑦 − 𝑦0 = (𝑥 − 𝑥0 ) { }
2
(1)
𝑓(𝑥0 ,𝑦0 )+𝑓((𝑥1 ,𝑦1 )
Since this line is to pass through (𝑥1 , 𝑦1 ) we get 𝑦1 − 𝑦0 = (𝑥1 − 𝑥0 ) { 2
}
(1)
𝑓(𝑥0 , 𝑦0 ) + 𝑓((𝑥1 , 𝑦1 )
𝑦1 = 𝑦0 + ℎ { }
2
In general,
(1)
𝑓(𝑥𝑛 ,𝑦𝑛 )+𝑓((𝑥𝑛+1 , 𝑦𝑛+1 ) (1)
𝑦𝑛+1 = 𝑦𝑛 + ℎ { 2
}, where 𝑦𝑛+1 = 𝑦𝑛 + ℎ𝑓(𝑥𝑛 , 𝑦𝑛 )
To obtain 𝑦2 , it would be
(1)
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 )
(1)
𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 )
𝑦2 = 𝑦1 + ℎ { }
2
To obtain 𝑦3 , it would be
(1)
𝑦3 = 𝑦2 + ℎ𝑓(𝑥2 , 𝑦2 )
(1)
𝑓(𝑥2 , 𝑦2 ) + 𝑓((𝑥3 , 𝑦3 )
𝑦3 = 𝑦2 + ℎ { }
2
To obtain 𝑦4 , it would be
(1)
𝑦4 = 𝑦3 + ℎ𝑓(𝑥3 , 𝑦3 )
(1)
𝑓(𝑥3 , 𝑦3 ) + 𝑓((𝑥4 , 𝑦4 )
𝑦4 = 𝑦3 + ℎ { }
2
and so on …
(1) Read 𝑥0 , 𝑦0 , ℎ, 𝑥𝑛 where 𝑥0 , 𝑦0 are the initial values, ℎ is the step length, 𝑥𝑛 is value of x
for which y is required
(2) While 𝑥0 ≤ 𝑥𝑛
(3) Print 𝑥0 , 𝑦0
(4) 𝑥1 ← 𝑥0 + ℎ
(5) 𝑡1 ← 𝑓(𝑥0 , 𝑦0 )
(6) 𝑡𝑦 ← 𝑦0 + ℎ × 𝑡1
(7) 𝑡2 ← 𝑓(𝑥1 , 𝑡𝑦)
(8) 𝑦1 ← 𝑦0 + ℎ × (𝑡1 + 𝑡2)/2
(9) 𝑦0 ← 𝑦1
(10) 𝑥0 ← 𝑥1
(11) End while
(12) stop
To obtain 𝑦2 , it would be
(1)
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 )
(1)
(2) 𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 )
𝑦2 = 𝑦1 + ℎ { }
2
(2)
(3) 𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 )
𝑦2 = 𝑦1 + ℎ { }
2
(3)
(4) 𝑓(𝑥1 ,𝑦1 )+𝑓((𝑥2 ,𝑦2 )
𝑦2 = 𝑦1 + ℎ { 2
}, etc…
To obtain 𝑦3 , it would be
(1)
𝑦3 = 𝑦2 + ℎ𝑓(𝑥2 , 𝑦2 )
(1)
(2) 𝑓(𝑥2 , 𝑦2 ) + 𝑓((𝑥3 , 𝑦3 )
𝑦3 = 𝑦2 + ℎ { }
2
(2)
(3) 𝑓(𝑥2 , 𝑦2 ) + 𝑓((𝑥3 , 𝑦3 )
𝑦3 = 𝑦2 + ℎ { }
2
(3)
(4) 𝑓(𝑥2 ,𝑦2 )+𝑓((𝑥3 ,𝑦3 )
𝑦3 = 𝑦2 + ℎ { 2
}, etc…
and so on …
Remarks:
But as soon as two consecutive values of 𝑦 are known (i.e. from 𝑦2 onwards), the first approximation to
succeeding 𝑦’s can be obtained more accurately by the formula 𝑦𝑛+1 = 𝑦𝑛−1 + 2ℎ𝑓(𝑥𝑛 , 𝑦𝑛 ).
To obtain 𝑦2 , it would be
(1)
𝑦2 = 𝑦0 + 2ℎ𝑓(𝑥1 , 𝑦1 )
(1)
(2) 𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 )
𝑦2 = 𝑦1 + ℎ { }
2
(2)
(3) 𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 )
𝑦2 = 𝑦1 + ℎ { }
2
(3)
(4) 𝑓(𝑥1 ,𝑦1 )+𝑓((𝑥2 ,𝑦2 )
𝑦2 = 𝑦1 + ℎ { 2
}, etc…
To obtain 𝑦3 , it would be
(1)
𝑦3 = 𝑦1 + 2ℎ𝑓(𝑥2 , 𝑦2 )
(1)
(2) 𝑓(𝑥2 , 𝑦2 ) + 𝑓((𝑥3 , 𝑦3 )
𝑦3 = 𝑦2 + ℎ { }
2
(2)
(3) 𝑓(𝑥2 , 𝑦2 ) + 𝑓((𝑥3 , 𝑦3 )
𝑦3 = 𝑦2 + ℎ { }
2
(3)
(4) 𝑓(𝑥2 ,𝑦2 )+𝑓((𝑥3 ,𝑦3 )
𝑦3 = 𝑦2 + ℎ { 2
}, etc…
and so on …
(1) Read 𝑥0 , 𝑦0 , ℎ, 𝑥𝑛, 𝜖 where 𝑥0 , 𝑦0 are the initial values, ℎ is the step length, 𝑥𝑛 is value of 𝑥
for which 𝑦 is required and 𝜖 is the precision value
(2) While (𝑥0 ≤ 𝑥𝑛 )
(3) Print 𝑥0 , 𝑦0
(4) 𝑡1 ← 𝑓(𝑥0 , 𝑦0 )
(5) 𝑦11 ← 𝑦0 + ℎ × 𝑡1
(6) 𝑥1 ← 𝑥0 + ℎ
(7) 𝑡2 ← 𝑓(𝑥1 , 𝑦11 )
(8) 𝑦12 ← 𝑦0 + ℎ × (𝑡1 + 𝑡2)/2
(9) While (𝑦11 − 𝑦12 ) > 𝜖
(10) 𝑡3 ← 𝑓(𝑥1 , 𝑦12 )
(11) 𝑦13 ← 𝑦0 + ℎ × (𝑡1 + 𝑡3)/2
(12) 𝑦11 ← 𝑦12
(13) 𝑦12 ← 𝑦13
(14) End while
(15) 𝑥0 ← 𝑥1
(16) 𝑦0 ← 𝑦12
(17) End while
(18) stop
(1)
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ) = 𝑦0 + ℎ{𝑦0 + 𝑒 𝑥0 } = 0 + 0.2{0 + 𝑒 0 } = 0.2
ℎ (1) ℎ (1)
𝑦1 = 𝑦0 + {𝑓(𝑥0 , 𝑦0 ) + 𝑓(𝑥1 , 𝑦1 )} = 𝑦0 + [{𝑦0 + 𝑒 𝑥0 } + {𝑦1 + 𝑒 𝑥1 }]
2 2
0.2
=0+ 2
[{0 + 𝑒 0 } + {0.2 + 𝑒 0.2 }] =0.24214
(1)
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 ) = 0.24214 + 0.2{0.24214 + 𝑒 0.2 } = 0.53485
(1)
𝑓(𝑥1 , 𝑦1 ) + 𝑓((𝑥2 , 𝑦2 ) {0.24214 + 𝑒 0.2 } + {0.53485 + 𝑒 0.4 }
𝑦2 = 𝑦1 + ℎ { } = 0.24214 + 0.2 [ ]
2 2
= 0.59116
Now,
(1) 2(0.1)
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 ) = 1.095909 + 0.1 {1.095909 − } = 1.18725
1.095909
ℎ (1)
𝑦2 = 𝑦1 + {𝑓(𝑥1 , 𝑦1 ) + 𝑓(𝑥2 , 𝑦2 )}
2
0.1 2(0.1) 2(0.2)
= 1.095909 + [{1.095909 − } + {1.18725 − }] = 1.1841009
2 1.095909 1.18725
Soln:
𝑑𝑦
Given that 𝑓(𝑥, 𝑦) = = 𝑥 + 𝑦 with 𝑥0 = 0, 𝑦0 = 1.
𝑑𝑥
Finding 𝒚𝟏 :
(1)
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ) = 𝑦0 + ℎ{𝑥0 + 𝑦0 } = 1 + 0.05{0 + 1} = 1.05
0.05
=1+ [{0 + 1} + {0.05 + 1.05256}] = 1.05256
2
(3) (4)
Since 𝑦1 = 𝑦1 , we stop here and take 𝑦1 = 1.05256
Finding 𝒚𝟐 :
(1)
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 ) = 𝑦1 + ℎ{𝑥1 + 𝑦1 } = 1.05256 + 0.05{0.05 + 1.05256} = 1.107688
(1)
𝑦2 = 𝑦0 + 2ℎ𝑓(𝑥1 , 𝑦1 ) = 𝑦0 + 2ℎ{𝑥1 + 𝑦1 } = 1 + 2(0.05){0.05 + 1.05256} = 1.110256
https://docs.google.com/forms/d/e/1FAIpQLSfA0MThqqiO1UUYPLOmo
ggSAvaJ_OW0xjCSyoDL3TiFCXvRag/viewform?usp=sf_link
Practice Questions:
𝑑𝑦 2𝑥
(1) Given = 𝑦− , 𝑦(0) = 1, ℎ = 0.1. Find 𝑦(0.3)
𝑑𝑥 𝑦
𝑑𝑦
(2) Given = 𝑥 + 𝑦, 𝑦(0) = 0, ℎ = 0.2. Find 𝑦(0.6), 𝑦(0.8), 𝑦(1)
𝑑𝑥
𝑑𝑦
(3) Calculate 𝑦(0.5) taking ℎ = 0.1 and = 𝑦 + 𝑆𝑖𝑛 𝑥, 𝑦(0) = 2
𝑑𝑥
𝑑𝑦 2𝑦
(4) Calculate 𝑦(1.2), 𝑦(1.4) given = + 𝑥3 , 𝑦(1) = 0.5
𝑑𝑥 𝑥
𝑑𝑦
(5) Given = −𝑥𝑦2 , 𝑦(0) = 2, ℎ = 0.1. Evaluate y(0.2)
𝑑𝑥
𝑑𝑦
(6) Given = 1 − 𝑦, 𝑦(0) = 0. Evaluate y(0.1) and y(0.2)
𝑑𝑥
𝑑𝑦
(1) Given = 𝑥2 + 𝑦2 , 𝑦(0) = 1 Find 𝑦(0.1) and y(0.2)
𝑑𝑥
𝑑𝑦
(2) Given = log(𝑥 + 𝑦), 𝑦(0) = 1, ℎ = 0.2. Find 𝑦(0.2)
𝑑𝑥
𝑑𝑦
(3) Compute 𝑦(0.25) given = 2𝑥𝑦, 𝑦(0) = 1
𝑑𝑥
𝑑𝑦
(4) Given = 2 + √𝑥𝑦, 𝑦(1) = 1, ℎ = 0.2. Evaluate y(2)
𝑑𝑥
𝑑𝑦 cos 𝑦
(5) Given = − 0.5𝑦2 , 𝑦(0) = 0, 0 ≤ 𝑥 ≤ 1, ℎ = 0.2.
𝑑𝑥 1+𝑥
𝑑𝑦 1
(6) Compute y for 0 ≤ 𝑥 ≤ 1 given = −5𝑦 + 5𝑥2 + 2𝑥, 𝑦(0) = , ℎ = 0.2
𝑑𝑥 3
void main()
{
float x0, y0, h, xn, y1;
printf(“\nEnter initial approximations x0, y0 & interval width h:”);
scanf(“%f%f”, &x0, &y0);
printf(“\nEnter the step length : ”);
scanf(“%f”, &h);
printf(“\nEnter the value of x at which y is required”);
scanf(“%f”, &xn);
while (x0 < = xn)
{
printf(“\n When x = %f the value of y = %f “, x0, y0);
y11 = y0+h*f(x0, y0);
x1 = x0+h;
y1 = y0+h*(f(x0,y0)+f(x1,y11))/2;
x0 = x1;
y0 = y1;
}
getch();
}
void main()
{
float x0, y0, h, xn, x1, y1, y11, y12, y13, e;
printf(“\nEnter initial approximations x0, y0:”);
scanf(“%f%f”, &x0, &y0);
printf(“\nEnter the step length : ”);
scanf(“%f”, &h);
printf(“\nEnter the value of x at which y is required”);
scanf(“%f”, &xn);
e=0.0001; The value of e may be asked from the user
while (x0<=xn) depending on the accuracy of the result desired
{
printf(“\n When x = %f the value of y = %f “, x0, y0);
y11 = y0+h*f(x0, y0);
x1 = x0+h;
y12 = y0+h*(f(x0,y0)+f(x1, y11))/2;
while ((y11-y12)>e)
{
y13 = y0+h*(f(x0,y0)+f(x1, y12))/2;
y11 = y12;
y12 = y13;
}
x0 = x1;
y0 = y12;
}
getch();
}