Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Study Material Numerical Solution of Odinary Differential Equations
1. VIVEKANANDA COLLEGE, TIRUVEDAKAM WEST
(Residential & Autonomous – A Gurukula Institute of Life-Training)
(Affiliated to Madurai Kamaraj University)
PART III: PHYSICS MAJOR – FOURTH SEMESTER-CORE SUBJECT PAPER-II
NUMERICAL METHODS – 06CT42
(For those who joined in June 2018 and after)
Reference Text Book: Numerical Methods – P.Kandasamy, K.Thilagavathy & K.Gunavathi,
S.Chand & Company Ltd., New Delhi, 2014.
UNIT – V NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
Introduction:
In solving a differential equation for approximate solution. We find numerical values of
𝑦1, 𝑦2, 𝑦3 …. corresponding to given numerical values of independent variable values 𝑥1, 𝑥2, 𝑥3 … so
that the orderd pairs (𝑥𝑖, 𝑦𝑖), (𝑥2, 𝑦2) … … satisfy a particular solution, though approximately. A
solution of this type is called a point wise solution. Suppose we require to sole
𝑑𝑦
𝑑𝑥
= 𝑓(𝑥, 𝑦) with the
initial condition 𝑦(𝑥0) = 𝑦0. By numerical solution of the differential equation, let 𝑦(𝑥0) =
𝑦0, 𝑦(𝑥1), 𝑦(𝑥2), … be the solution of y at 𝑥 = 𝑥0, 𝑥1, 𝑥2, … Let 𝑦 = 𝑦(𝑥)be the exact solution.
Truncation errors are the errors that result from using an approximation in place of an exact
mathematical procedure. at 𝑥 = 𝑥𝑖
Power Series approximations
Let us suppose that we require to find the solution of
𝑦′
=
𝑑𝑦
𝑑𝑥
= 𝑓(𝑥, 𝑦)
subject to the initial condition 𝑦(𝑥0) = 𝑦0
By Taylor series, we have
𝑦(𝑥) = 𝑦(𝑥0) +
𝑥 − 𝑥0
1!
𝑦′(𝑥0) +
(𝑥 − 𝑥0)2
2!
𝑦′′(𝑥0) + ⋯
If 𝑥 = 𝑥0 = 0 (origin) we get the Maclaurin series expansion,
𝑦(𝑥) = 𝑦(0) +
𝑥
1!
𝑦′(0) +
𝑥2
2!
𝑦′′(0) + ⋯
Solution by Taylor series (Type 1)
If 𝑦′
= 𝑓(𝑡, 𝑦)𝑥0 ≤ 𝑥 ≤ 𝑏 𝑤𝑖𝑡ℎ 𝑦(𝑡0) = 𝑦0 gives the solution 𝑦0 at initial point 𝑥 = 𝑥0 for given step
size ℎ, the solution at 𝑥 = 𝑥0 + ℎ 𝑜𝑟 ℎ = 𝑥1 − 𝑥0 can be computed from Taylor series as
𝑦(𝑥) = 𝑦(𝑥0 + ℎ) = 𝑦(𝑥0) + ℎ𝑦′(𝑥0) +
ℎ2
2!
𝑦′′(𝑥0) +
ℎ3
3!
𝑦′′′(𝑥0) + ⋯ … (1)
from the differential equation, if is observed that 𝑦′(𝑥0) = 𝑓(𝑥0, 𝑦0)
Repeated differentiation gives 𝑦′′(𝑥0), 𝑦′′′(𝑥0) …as
𝑦′′(𝑥0) = [
𝛿𝑓
𝛿𝑡
+
𝛿𝑓
𝛿𝑦
𝑦′
]
𝑥=𝑥0
𝑦′′′(𝑥0) = [
𝛿2
𝑓
𝑑𝑡2
+
2𝛿2
𝑓
𝛿𝑡𝛿𝑦
𝑦′
+ (
𝛿𝑓
𝛿𝑦
𝑦′
)
2
]
𝑥=𝑥0
and so on
2. Substituting these derivatives and truncating the series in (1) give the approximate solution at 𝑥.
Now expanding y(x), in a Taylor’s series about the point 𝑥 = 𝑥1, we get
𝒚 𝒏+𝟏 = 𝒚 𝒏 +
𝒉
𝟏!
𝒚 𝒏
′
+
𝒉 𝟐
𝟐!
𝒚 𝒏
′′
+
𝒉 𝟑
𝟑!
𝒚 𝒏
′′′
+ ⋯
where
𝑦𝑛
𝑟
= (
𝑑 𝑟
𝑦
𝑑𝑥 𝑟
)
𝑥 𝑛 𝑦 𝑛
This formula is an infinite series and hence we have to truncate at some term to have the numerical
value calculated.
Problems
1. Using Taylor series method, find, correct to four decimal places, the value of y (0.1), given
𝒅𝒚
𝒅𝒙
= 𝒙 𝟐
+ 𝒚 𝟐
and y (0) = 1.
Solution.
Here 𝑥0 = 0, 𝑦0 = 1, ℎ = 𝑥1 − 𝑥0 = 0.1 − 0 = 0.1
𝑥1 = 0.1, 𝑦1 = 𝑦(𝑥1) = 𝑦(0.1) =?
𝑦′
= 𝑥2
+ 𝑦2
𝑦′′
= 2𝑥 + 2𝑦𝑦′
𝑦′′′
= 2 + 2𝑦𝑦′′
+ 2(𝑦′)2
𝑦′′′′
= 2𝑦𝑦′′′
+ 2𝑦′
𝑦′′
+ 4𝑦′
𝑦′′
= 2𝑦𝑦′′′
+ 6𝑦′
𝑦′′
𝑦0
′
= 𝑥0
2
+ 𝑦0
2
= 0 + 1 = 1
𝑦′0
′
= 2𝑥0 + 2𝑦0 𝑦0
′
= 2
𝑦𝑜
′′′
= 2 + 2𝑦0 𝑦0
′′
+ 2(𝑦0
′ )2
= 2 + 2(1)(2) + 2(1)2
= 8
𝑦0
′′′′
= 2𝑦0 𝑦0
′′′
+ 6𝑦0
′
𝑦0
′′
= 2 x 1 x 8 + 6 (1) (2) =28
By Taylor Series Method,
𝑦(𝑥) = 𝑦(𝑥0) + ℎ𝑦′(𝑥0) +
ℎ2
2!
𝑦′′(𝑥0) +
ℎ3
3!
𝑦′′′(𝑥0) + ⋯
𝑦(0.1) = 𝑦1 = 1 +
0.1
1
(1) +
(0.1)2
2
(2) +
(0.1)3
6
(8) +
(0.1)4
24
+ (28) + ⋯
= 1 + 0.1 + 0.01 + 0.001333333 + 0.000116666
= 1.11144999
= 𝟏. 𝟏𝟏𝟏𝟒𝟓.
2. By means of Taylor series expansion, find y at x = 0.1, 0.2 correct to three significant digit given
𝒅𝒚
𝒅𝒙
− 𝟐𝒚 = 𝟑𝒆 𝒙
, 𝒚(𝟎) = 𝟎.
Solution. Here 𝑥0 = 0, 𝑦0 = 0, 𝑥1 = 0.1, 𝑥2 = 0.2, ℎ = 0.1
𝑦′
= 2𝑦 + 3𝑒 𝑥
𝑦′′
= 2𝑦′
+ 3𝑒 𝑥
𝑦′′′
= 2𝑦′′
+ 3𝑒 𝑥
𝑦′′′′
= 2𝑦′′′
+ 3𝑒 𝑥
𝑦0
′
= 2𝑦0 + 3𝑒 𝑥0 = 3
𝑦0
′′
= 2𝑦0
′
+ 3𝑒 𝑥0 = 9
𝑦0
′′′
= 18 + 3 = 21
𝑦0
′′′′
= 42 + 3 = 45
5. Here, 𝑥2 = 0.4 ℎ = 0.2
By Taylor Series
𝑦(𝑥2) = 𝑦(𝑥1) + ℎ𝑦′(𝑥1) +
ℎ2
2!
𝑦′′(𝑥1) +
ℎ3
3!
𝑦′′′(𝑥1) +
ℎ4
4!
𝑦′′′′(𝑥1) + ⋯
𝑦(𝑥2) = 𝑦(0.4)
= 0.194752003 +
0.2
1
(0.9220992) +
(0.2)2
2
(−0.758343686) +
(0.2)3
6
(−3.38505933)
+
(0.2)4
24
(5.90403585)
= 0.194752003 + 0.18441984 − 0.0151668737 − 0.00451341243 + 0.00039360239
= 0.35988515
Euler’s Method
In solving a first order differential equation by numerical methods, we come across two types of
solutions:
• A series solution of y in terms of x, which will yield the value of y at a particular value of x
by direct substitution in the series solution.
• Values of y at specified values of x.
Let us take the point 𝑥 = 𝑥0, 𝑥1, 𝑥2, … 𝑤ℎ𝑒𝑟𝑒 𝑥1 − 𝑥𝑖−1 = ℎ 𝑖. 𝑒. , 𝑥𝑖 = 𝑥0 + 𝑖ℎ, 𝑖 = 0,1,2, ….
The equation of tangent at (𝑥0, 𝑦0) to curve is
𝑦 − 𝑦0 = 𝑦(𝑥0,𝑦0)
′
(𝑥 − 𝑥0)
= 𝑓(𝑥0, 𝑦0). (𝑥 − 𝑥0)
𝑦 = 𝑦0 + 𝑓(𝑥0, 𝑦0). (𝑥 − 𝑥0)
∴ 𝑦1 = 𝑦0 + ℎ𝑦0
′
𝑤ℎ𝑒𝑟𝑒 ℎ = 𝑥1 − 𝑥0.
Thus
𝒚 𝒏+𝟏 = 𝒚 𝒏 + 𝒉𝒇(𝒙 𝒏, 𝒚 𝒏); 𝒏 = 𝟎, 𝟏, 𝟐, …
This formula is called Euler’s algorithm
5. Using Euler’s method, solve numerically the equation, 𝒚′
= 𝒙 + 𝒚, 𝒚(𝟎) = 𝟏, 𝒇𝒐𝒓 𝒙 =
𝟎. 𝟎 (𝟎. 𝟐)(𝟏. 𝟎) Check your answer with the exact solution.
Solution. Here, h=0.2, 𝑓(𝑥, 𝑦) = 𝑥 + 𝑦, 𝑥0 = 0, 𝑦0 = 1 𝑥1 = 0.2, 𝑥2 = 0.4, 𝑥3 = 0.6, 𝑥4 =
0.8, 𝑥5 = 1.0
By Euler algorithm
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0, 𝑦0)
𝑦1 = 𝑦0 + ℎ[𝑥0 + 𝑦0]
= 1 + (0.2)(0 + 1) = 𝟏. 𝟐
𝑦2 = 𝑦1 + ℎ[𝑥1 + 𝑦1]
= 1.2 + (0.2)(0.2 + 1.2) = 𝟏. 𝟒𝟖
𝑦3 = 𝑦2 + ℎ[𝑥2 + 𝑦2]
= 1.48 + (0.2)(0.4 + 1.48) = 𝟏. 𝟖𝟓𝟔
𝑦4 = 1.856 + (0.2)(0.6 + 1.856) = 𝟐. 𝟑𝟒𝟕𝟐
𝑦5 = 2.3472 + (0.2)(0.8 + 2.3472) = 𝟐. 𝟗𝟒𝟔𝟔𝟒
6. Exact solution is 𝑦 = 2𝑒 𝑥
− 𝑥 − 1. Hence the tabular values are:
X 0 0.2 0.4 0.6 0.8 1.0
Euler y 1 1.2 1.48 1.856 2.3472 2.94664
Exact y 1 1.2428 1.5836 2.0442 2.6511 3.4366
6. Given 𝒚′
= −𝒚 𝒂𝒏𝒅 𝒚(𝟎) = 𝟏. determine the values of y at x = (0.01)(0.01)(0.04) by Euler
method.
Solution. 𝑦′
= −𝑦 𝑎𝑛𝑑 𝑦(0) = 1; 𝑓(𝑥, 𝑦) = −𝑦.
Here, 𝑥0 = 0, 𝑦0 = 1, 𝑥1 = 0.01, 𝑥2 = 0.02, 𝑥3 = 0.03, 𝑥4 = 0.04 ℎ = 0.01.
By Euler algorithm,
𝑦 𝑛+1 = 𝑦𝑛 + ℎ𝑦𝑛
′
= 𝑦𝑛 + ℎ𝑓(𝑥 𝑛, 𝑦𝑛)
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0, 𝑦0)
= 1 + (0.01)(−1) = 1 − 0.01 = 𝟎. 𝟗𝟗.
𝑦2 = 𝑦1 + ℎ𝑦1
′
= 0.99 + (0.01)(−𝑦1)
= 0.99 + (0.01)(−0.99) = 𝟎. 𝟗𝟖𝟎𝟏
𝑦3 = 𝑦2 + ℎ𝑓(𝑥2, 𝑦2)
= 0.9801 + (0.01)(−0.9801) = 𝟎. 𝟗𝟕𝟎𝟑
𝑦4 = 𝑦3 + ℎ𝑓(𝑥3, 𝑦3)
= 0.9703 + (0.01)(−0.9703) = 𝟎. 𝟗𝟔𝟎𝟔
Tabular values (step values) are
x 0 0.01 0.02 0.03 0.04
Y 1 0.9900 0.9801 0.9703 0.9606
Exact y 1 0.9900 0.9802 0.9704 0.9608
since 𝑦 = 𝑒−𝑥
is the exact solution.
Runge-Kutta Method
The use of the previous methods to solve the differential equation numerically is restricted due to
either slow convergence or due to labour involved, especially in Taylor series method. But, in
Runge-Kutta methods, the derivatives of higher order are not required and we require only the
given function values at different points. Since the derivation of fourth order Runge-Kutta method
is tedious, we will derive Runge-kutta method of second order.
Second order Runge-Kutta method (for first order O.D.E.)
𝑑𝑦
𝑑𝑥
= 𝑓(𝑥, 𝑦)𝑔𝑖𝑣𝑒𝑛 𝑦(𝑥0) = 𝑦0
By Taylor series
𝑦(𝑥 + ℎ) = 𝑦(𝑥) + ℎ𝑦′(𝑥) +
ℎ2
2!
𝑦′′(𝑥) + 𝑜 (ℎ3
)
𝑙𝑒𝑡 ∆1 𝑦 = 𝑘1 = 𝑓(𝑥, 𝑦). ∆𝑥 = ℎ𝑓(𝑥, 𝑦)
∆2 𝑦 = 𝑘2 = ℎ𝑓(𝑥 + 𝑚ℎ, 𝑦 + 𝑚𝑘1)
and le ∆𝑦 = 𝑎𝑘1 + 𝑏𝑘2
where a, b and m are constants to be determined to get the better accuracy of ∆𝑦.
𝑦 𝑛+1 = 𝑦𝑛 + (1 − 𝑏)ℎ𝑓(𝑥 𝑛, 𝑦𝑛) + 𝑏ℎ𝑓 (𝑥 𝑛 +
ℎ
2𝑏
, 𝑦𝑛 +
ℎ
2𝑏
𝑓(𝑥 𝑛, 𝑦𝑛)) + 𝑜(ℎ3
)
7. From this general second order Runge-Kutta formula, setting 𝑎 = 0, 𝑏 = 1, 𝑚 =
1
2
, we get the
second order Runge-Kutta algorithm as
𝑘1 = ℎ𝑓(𝑥, 𝑦)
𝑘2 = ℎ𝑓 (𝑥 +
1
2
ℎ, 𝑦 +
1
2
𝑘1)
and ∆𝑦 = 𝐾2 where ℎ = ∆𝑥.
Since the derivation of third and fourth order Runge-Kutta algorithms are tedious, we state them
below for use.
The third order Runge-Kutta method algorithm is given below:
The fourth order Runge-Kutta method algorithm is mostly used in problem unless other
mentioned. It is
7. Using Runge-Kutta method of fourth order, solve
𝒅𝒚
𝒅𝒙
=
𝒚 𝟐−𝒙 𝟐
𝒚 𝟐+𝒙 𝟐
given
y(0)=1 at x=0.2,0.4.
Solution. 𝑦′
= 𝑓(𝑥, 𝑦) =
𝑦2−𝑥2
𝑦2+𝑥2
Here 𝑥0 = 0, ℎ = 0.2, 𝑥1 = 0.2, 𝑥2 = 0.4, 𝑦0 = 1
𝑓(𝑥0, 𝑦0) = 𝑓(0,1) =
1 − 0
1 + 0
= 1
𝑘1 = ℎ𝑓(𝑥0, 𝑦0) = (0.2)(1) = 0.2
𝑘2 = ℎ𝑓 (𝑥0 +
1
2
ℎ, 𝑦0 +
1
2
𝑘1) = (0.2)𝑓(0.1,1.1)
= (0.2) [
(1.1)2
− (0.1)2
(1.1)2 + (0.1)2
] = (0.2) [
1.21 − 0.01
1.21 + 0.01
]
= 0.1967213
𝑘3 = ℎ𝑓 (𝑥0 +
1
2
ℎ, 𝑦0 +
1
2
𝑘2)
= (0.2)𝑓 (0.1, 1 +
1
2
(0.1967213))
= (0.2)𝑓(0.1,1.0983606)
= (0.2) [
(1.0983606)2
− (0.01)
(1.0983606)2 + (0.01)
] = 0.1967
Second order R.K. algorithm
𝑘1 = ℎ𝑓(𝑥, 𝑦)
𝑘2 = ℎ𝑓 (𝑥 +
1
2
ℎ, 𝑦 +
1
2
𝑘1)
𝑘3 = ℎ𝑓(𝑥 + ℎ, 𝑦 + 2𝑘2 − 𝑘1)
and ∆𝑦 =
1
6
(𝑘1 + 4𝑘2 + 𝑘3)
Third order
R.K. algorithm
𝑘1 = ℎ𝑓(𝑥, 𝑦)
𝑘2 = ℎ𝑓 (𝑥 +
1
2
ℎ, 𝑦 +
1
2
𝑘1)
𝑘3 = ℎ𝑓(𝑥 + ℎ, 𝑦 + 2𝑘2 − 𝑘1)
𝑘4 = ℎ𝑓(𝑥 + ℎ, 𝑦 + 𝑘3)
and ∆𝑦 =
1
6
(𝑘1 + 4𝑘2 + 2𝑘3) + 𝑘4)
𝑦(𝑥 + ℎ) = 𝑦(𝑥) + ∆𝑦
Fourth order
R.K. algorithm