You are on page 1of 5

Cairo University Faculty of Engineering

Main-Stream Spring 2023

MTH 2134 Numerical Analysis

Assignment 9
Numerical Solution of ODE’s
1. Solve using Euler, Heun and the fourth order Runge Kutta formula the initial value
problem: 𝒚′ = 𝒙𝒚 + 𝒙𝟐 , with 𝒚(𝟎) = 𝟏, for 𝒙 = 𝟎. 𝟏
2. Use Runge-Kutta formula to solve the differential equation:
𝒚′′ + 𝒚 = 𝒙 at 𝒙 = 𝟏. 𝟐 with the initial values: 𝒚(𝟏) = 𝟏. 𝟖𝟒 and
𝒚′ (𝟏) = 𝟏. 𝟓𝟒. If the exact solution is: 𝒚 = 𝒙 + 𝐬𝐢𝐧 𝒙, estimate the percentage of
true error in your result.
3. Use Runge Kutta of the fourth order to solve the following system of differential
equations at x = 0.1:
𝒅𝒚
= −𝟐𝒚 + 𝟓𝒛𝒆−𝒙
𝒅𝒙
𝒅𝒛 𝒚𝒛𝟐
=−
𝒅𝒙 𝟐

the initial conditions are: y(0) = 2 and z(0) = 4.


4. Use Runge Kutta of the fourth order to solve, at = 𝟎. 𝟓 , the second order differential
equation 𝒚′′ = 𝒙𝟐 (𝒚 − 𝒚′ ) where the initial conditions are: 𝒚(𝟎) = 𝟏, and 𝒚′ (𝟎) =
𝟎. 𝟓
5. Use Adams-Bashforth formula to solve the differential equation:
𝒚+√𝒙𝟐 +𝒚𝟐
𝒚′ = at 𝒙 = 𝟐. 𝟐 with the following starting values:
𝒙
x 1 1.2 1.4 1.6 1.8 2
y 0 0.221 0.479 0.784 1.123 1.521
Perform 2 iterations. Estimate the error in your result.
Adams-Bashforth formula:

 33 21 39 21 33 
Predictor: y n +1 = y n −5 + h fn − f n −1 + f n−2 − f n −3 + f n−4 
 10 5 5 5 10 
 14 64 24 64 14 
Corrector: y n +1 = y n −3 + h f n −3 + f n−2 + f n −1 + fn + f n +1 
 45 45 45 45 45 
6. a) Use R-K method to get y(0.1) for ODE y = y sin( 2 xy) with y (0) = 1
b) Use (a) and the following formula of P-C method to get y (0.2)

yi(+P1) i+1 = yi−1 +


h
(3 fi + 2 fi−1 )
5
h
(15 f i+( r1) − 3 f i−1 + 12 f i )
yi(+c1)( r +1) = yi +
24
stop after one correction.
7. Use the following predictor corrector pairs to solve the differential equation
dy y2
= x− , at x = 0.3 with the following starting values:
dx 10
x -0.3 -0.2 -0.1 0 0.1 0.2
y 1.0812 1.0407 1.0151 1 0.9951 1.0002
 33 21 39 21 33 
Predictor: yn+1 = yn−5 + h fn − f n−1 + f n−2 − f n−3 + f n−4 
 10 5 5 5 10 
 14 64 24 64 14 
Corrector: yn+1 = yn−3 + h f n−3 + f n−2 + f n−1 + fn + f n+1 
 45 45 45 45 45 
Perform only 2 iterations.
8. Use the following predictor corrector pair to solve the differential equation
dy
= y 2 − x 2 , at x = 0.5 with the following starting values:
dx
x 0 0.1 0.2 0.3 0.4
y 1 1.11 1.25 1.42 0.64

 1 5 3 251 4 
Predictor: y1 = y0 + h f 0 + f 0 +  2 f 0 + 3 f 0 +  f 0 + ...
 2 12 8 720 
 1 1 1 19 4 
Corrector: y1 = y0 + h f1 − f1 −  2 f1 − 3 f1 −  f1 + .....
 2 12 24 720 
Perform only 2 iterations.
9. Using Runge-Kutta fourth order method to find y (0.2) & y (0.2) for the ODE
2 y  + 4 y  − 2 xy = 6 with y (0) = 1 & y (0) = −1.

10. Use Runge-Kutta fourth order method to find y (1.1) & z (1.1) for the following
system of ODE's y + 2 x − z = y & cos x − 3z = zy with y (1) = 1.2 & z (1) = −0.3
11. Use R-K fourth order method to solve the following ODE
y ( x) + xy( x) + (1 − x) y ( x) = cos xy with y (0.5) = y (0.5) = 2 at x = 0.7 & 0.9.

12. For the following system of ODE y + xy − z = 0 & 2 y − x 2 + 3z = 1


with initial (0 , 1 , 2) , (0.1 , 1.56 , 2.39) , (0.2 , 3.06 , 1.33) & (0.3 , 2.42 , 0.86)

Find y and Z at x=0.4. yi(+p1) = yi +


h
(55 f i − 59 f i−1 + 37 f i−2 − 9 f i−3 )
24

yi(+c1) = yi +
h
(9 f i+1 + 19 f i − 5 f i−1 + f i−2 )
24
13. Use Range-Kutta fourth order to find y (0.2) for ODE 3x − y + xy = 0
with y (0) = 1 , then use the following P-C method to find y (0.4) with one correction.
h 3h
yi(+P1) = yi + ( f i−1 + 3 f i ) yi(+C1) = yi + (5 f i+1 + 3 f i − f i−1 )
4 7

14. Write the steps to find y (0.5) & z (0.5) for the system
y  = f ( x, y, z ) & z  = g ( x, y, z ) with initial y (0) = 1 & z (0) = 3 (h = 0.1)
Using R-K method and P-C method, stop after two corrections.
* the formula of P-C method

4h 28h 5 (5)
y P
i +1 = y i −3 + [2 f i − 2 − f i −1 + 2 f i ] + y ( )
3 90

h h 5 ( 5)
y iC+1 = y i −1 + [ f i −1 + 4 f i + f i +1 ] − y ( ) ]
3 90
15. Consider the differential equation: y = x + y, whose initial values are:
y(0) = 0, y(0.1) = 0.214 and y(0.2) = 0.0918.
Find by using the given set of predictor – corrector formula, y(0.3). Put your answer in a
h
table: y n( +p1) = y n + (55 f n − 59 f n−1 + 37 f n−2 )
24
h
y n( c+)1 = yn + (9 f n+1 + 19 f n − 5 f n−1 + f n−2 )
24
16. Using Heun's method with two correction to find y (0.2) & y (0.2) for the ODE
y  + 5 xy  − cos xy = 0 with y (0.1) = 1 & y (0.1) = −1. Find your relative error.

17. For y  + 5 xy  − y = 6 with y (1) = 1 & y (1) = −1


a) Use R-K fourth order to evaluate y(1.2) with h=0.2.
b) Write steps to evaluate y(1.4) using Heun's method with stopping error 0.1%.
c) Write steps to evaluate y(1.6) using predictor corrector with the given formula with two
corrections.
4h h
yiP+1 = yi −3 + [2 f i −2 − f i −1 + 2 f i ] yiC+1 = yi −1 + [ f i −1 + 4 f i + f i +1 ]
3 3
18. Use Runge-Kutta of the fourth order to solve the following simultaneous system
of ordinary differential equations at 𝒙 = 𝟎. 𝟏 , given the initial condition
(𝟎, 𝟐, −𝟎. 𝟕𝟓)
𝒅𝒚
+ 𝟐𝒚 + 𝟒𝒁 − 𝟒𝒙 = 𝟏
𝒅𝒙
𝒅𝒛 𝟑
+ 𝒚 − 𝒁 − 𝒙𝟐 = 𝟎
𝒅𝒙 𝟐
𝟏 𝒙𝟐
If the general solution is: 𝒚 = 𝒆𝟐𝒙 + 𝒆−𝟑𝒙 + 𝒙𝟐 + 𝒙 and 𝒛 = −𝒆𝟐𝒙 + 𝟒 𝒆−𝟑𝒙 − ,
𝟐

Find the percentage of true error,

19. Use Heun’s method to approximate the solution of the second order differential
equation: 𝒙𝟐 𝒚′′ − 𝟐𝒙𝒚′ + 𝟐𝒚 = 𝒙𝟑 𝐥𝐧 𝒙 , at 𝒙 = 𝟏. 𝟏, with initial conditions
𝒚(𝟏) = 𝟏 and 𝒚′ (𝟏) = 𝟎. (Perform only 2 iterations). Then find 𝒚(𝟏. 𝟐) using
Runge Kutta’s method.
Calculate the percentage of relative true error in both cases if the exact solution
𝟕 𝟏 𝟑
is 𝒚 = 𝟒 𝒙 + 𝟐 𝒙𝟑 𝐥𝐧 𝒙 − 𝟒 𝒙𝟑

20. Use Heun’s method to approximate the solution of the second order differential
equation: 𝒚′′ − 𝟐𝒚′ + 𝒚 = 𝒙𝒆𝒙 − 𝒙 , at 𝒙 = 𝟎. 𝟏, with initial conditions are
𝒚(𝟎) = 𝒚′ (𝟏) = 𝟎. (Perform only 2 iterations).
Then find 𝒚(𝟎. 𝟐) using Adams-Moulton predictor corrector set
𝒉
𝒚𝒏+𝟏 𝑷 = 𝒚𝒏 + (𝟑𝒇𝒏 − 𝒇𝒏−𝟏 )
𝟐
𝒉
𝒚𝒏+𝟏 𝑪 = 𝒚𝒏 + (𝟓𝒇𝒏+𝟏 + 𝟖𝒇𝒏 − 𝒇𝒏−𝟏 )
𝟏𝟐
Calculate the percentage of relative true error in both cases if the exact solution
𝟏
is 𝒚 = 𝟔 𝒙𝟑 𝒆𝒙 − 𝒙𝒆𝒙 + 𝟐𝒆𝒙 − 𝒙 − 𝟐

21. Given the predictor corrector pairs below, write the steps required for evaluating
𝒚(𝟎. 𝟓) for the differential equation: 𝒚′′ + 𝟓𝒙𝟐 𝒚′ + 𝒙𝒚 = 𝐜𝐨𝐬 𝒙𝟐 .
The initial conditions are : (𝟎, 𝒂), (𝟎, 𝒃), (𝟎, 𝒄) and (𝟎, 𝒅).
Use correction formula 3 times.
𝟒𝒉
𝒚𝒏+𝟏 𝑷 = 𝒚𝒏−𝟑 + (𝟐𝒇𝒏 − 𝒇𝒏−𝟏 + 𝟐𝒇𝒏−𝟐 )
𝟑
𝒉
𝒚𝒏+𝟏 𝑪 = 𝒚𝒏−𝟏 + (𝒇𝒏+𝟏 + 𝟒𝒇𝒏 + 𝒇𝒏−𝟏 )
𝟑
22. Use Heun’s method (Modified Euler) to approximate the solution of the
second order differential equation: 𝒙𝟐 𝒚′′ − 𝟐. 𝟓𝒙𝒚′ − 𝟐𝒚 = 𝟎 , at 𝒙 =
𝟏. 𝟐where, the initial conditions are: 𝒚(𝟏) = 𝟑 and 𝒚′(𝟏) = 𝟕. 𝟓 . Calculate
𝟏
the percentage of relative true error if the exact solution is: 𝒚 = + 𝟐𝒙𝟒
√𝒙

23. Use The given predictor-corrector pair to approximate the solution of the
𝒅𝒚 −𝟐𝒚
first order differential equation: 𝒅𝒙 = 𝟏+𝒙 , at 𝒙 = 𝟐 .
𝒉
Predictor: 𝒚𝒊+𝟏 = 𝒚𝒊 + (𝟓𝟓𝒇𝒊 − 𝟓𝟗𝒇𝒊−𝟏 + 𝟑𝟕𝒇𝒊−𝟐 − 𝟗𝒇𝒊−𝟑 )
𝟐𝟒
𝒉
Corrector: 𝒚𝒊+𝟏 = 𝒚𝒊 + 𝟐𝟒 (𝟗𝒇𝒊+𝟏 + 𝟏𝟗𝒇𝒊 − 𝟓𝒇𝒊−𝟏 + 𝒇𝒊−𝟐 )

The initial conditions are: 𝒚(𝟎) = 𝟐, 𝒚(𝟎. 𝟓) = 𝟎. 𝟖𝟗, 𝒚(𝟏) = 𝟎. 𝟓 and


𝒚(𝟏. 𝟓) = 𝟎. 𝟑𝟐𝟐 Perform 3 iterations. Calculate the percentage of
approximate error in the last step

You might also like