Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
76 views9 pages

Numerical Solution of ODE (Up To Improved Euler's Method)

This document discusses the numerical solutions of ordinary differential equations (ODEs), focusing on initial value problems (IVP) and boundary value problems (BVP). It outlines methods for solving IVPs, including single-step methods like Taylor's series and multi-step methods like Milne's Predictor-Corrector method. The document provides examples and detailed calculations for finding specific solutions using Taylor's series.

Uploaded by

prane.shhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views9 pages

Numerical Solution of ODE (Up To Improved Euler's Method)

This document discusses the numerical solutions of ordinary differential equations (ODEs), focusing on initial value problems (IVP) and boundary value problems (BVP). It outlines methods for solving IVPs, including single-step methods like Taylor's series and multi-step methods like Milne's Predictor-Corrector method. The document provides examples and detailed calculations for finding specific solutions using Taylor's series.

Uploaded by

prane.shhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

UNIT III - NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL

EQUATIONS

Introduction
The solution of an ordinary differential equation (ODE) is a specific
relation between the dependent variable and independent variable which
satisfies the original differential equation.
The general solution of an ODE of nth order has ‘n’ arbitrary
constants. So, to find the particular solution of nth order equation, ‘n’
conditions are required.
These ‘n’ conditions will be provided by the values of the dependent
variable (or) its derivative for ‘n’ specific values of the independent variable.
If all the ‘n’ conditions are specified only for the initial value of the
independent variable ‘x’ then the problem is called an initial value
problem. (IVP)
If all the ‘n’ conditions are specified for two or more values of the
independent variable ‘x’ then the problem is called a boundary value
problem. (BVP)
𝑑2 𝑦 𝑑𝑦
Example for IVP : = 𝑓 (𝑥, 𝑦, 𝑑𝑥 ) , 𝑠𝑢𝑏𝑗𝑒𝑐𝑡 𝑡𝑜 𝑦(𝑥0 ) = 𝑎 & 𝑦 ′ (𝑥0 ) = 𝑏
𝑑𝑥 2
𝑑2 𝑦 𝑑𝑦
Example for BVP : = 𝑓 (𝑥, 𝑦, 𝑑𝑥 ) , 𝑠𝑢𝑏𝑗𝑒𝑐𝑡 𝑡𝑜 𝑦(𝑥0 ) = 𝑎 & 𝑦(𝑥𝑛 ) = 𝑏
𝑑𝑥 2

The solution of IVP can be obtained by the following two methods.

1) Single step method: Here the information about the curve at one point
will be used and we do not iterate the solution. This method includes more
evaluations of the function.
Examples: Taylor’s series method, Euler & Improved Euler methods,
Runge-Kutta method.

2) Multi step method: Here fewer prior evaluations of the function are
required to find the solution at a point and iterations will be carried out till
sufficient accuracy is achieved.
Example: Milne’s Predictor Corrector method.
Taylor’s series method for first order ODE
𝑑𝑦
Aim : To find the solution of 𝑑𝑥
= 𝑦 ′ = 𝑓(𝑥, 𝑦) − − − − − − − − − (1)

Subject to the initial condition 𝑦(𝑥0 ) = 𝑦0−−−−−−−−−−(2)

Now, we expand y(x) about the point 𝑥 = 𝑥0 in a Taylor’s series in powers


of (𝑥 − 𝑥0 ).

Formula:

(𝑥−𝑥0 ) (𝑥−𝑥0 )2 (𝑥−𝑥0 )3


𝑦(𝑥) = 𝑦(𝑥0 ) + 𝑦 ′ (𝑥0 ) + 𝑦 ′′ (𝑥0 ) + 𝑦 ′′′ (𝑥0 ) + − − −(3)
1! 2! 3!

(or)

(𝑥−𝑥0 ) (𝑥−𝑥0 )2 (𝑥−𝑥0 )3


𝑦(𝑥) = 𝑦0 + 𝑦0 ′ + 𝑦0 ′′ + 𝑦0 ′′′ + − − − − − − −(3)
1! 2! 3!

𝒉 𝒉𝟐 𝒉𝟑
i.e., 𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚𝟎 + 𝒚𝟎 ′ + 𝒚𝟎 ′′ + 𝒚𝟎 ′′′ + − − − − − − −(𝟒)
𝟏! 𝟐! 𝟑!

where 𝒉 = 𝒙 − 𝒙𝟎 and 𝒙𝟏 = 𝒙𝟎 + 𝒉

To find 𝒚′𝟎 , 𝒚′′


𝟎 , 𝒚𝟎 , − − − − we use (1) and its derivative at 𝒙 = 𝒙𝟎 .
′′′

Though (4) is an infinite series, we can truncate it at any convenient


term, if ‘h’ is small and the accuracy is obtained.

Using 𝒚𝟏 we can find 𝒚𝟐 , 𝒚𝟑,−−−−−−−

By expanding y(x) in a Taylor’s series about the point = 𝑥1 , we get


ℎ ℎ2 ℎ3
𝑦2 = 𝑦(𝑥2 ) = 𝑦1 + 1! 𝑦1 ′ + 𝑦 ′′ +
2! 1 3!
𝑦1 ′′′ + − − − − − − −(5)

Proceeding like this, we get the general formula

𝒉 𝒉𝟐 𝒉𝟑
𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒚𝒏 ′ + 𝒚𝒏 ′′ + 𝒚𝒏 ′′′ + − − − − − − −(𝟔)
𝟏! 𝟐! 𝟑!
Remark : The truncation error is 𝑂(ℎ𝑛+1 ).

By including more number of terms for calculation, the error can be


reduced further.

If ‘h’ is small and the term after ‘n’ terms are neglected, the error is
ℎ𝑛
𝑓 𝑛 (𝜃) 𝑤ℎ𝑒𝑟𝑒 𝑥0 < 𝜃 < 𝑥1 𝑖𝑓 𝑥1 − 𝑥0 = ℎ.
𝑛!

Problems:
𝑑𝑦
1) Solve = 𝑥 + 𝑦 given y(1)=0 and determine y(1.1) by Taylor’s series
𝑑𝑥
method.

Solution:

Compare the given condition y(1)=0 with 𝑦(𝑥0 ) = 𝑦0 we get 𝑥0 = 1 & 𝑦0 = 0

To find y(1.1)=y(x1)= 𝑦(𝑥0 + ℎ)

𝑦(𝑥0 + ℎ) = 𝑦(1 + ℎ) = 𝑦(1.1) ⟹ 1 + ℎ = 1.1 ⟹ ℎ = 0.1


ℎ ℎ2 ℎ3
Therefore 𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + 1! 𝑦0 ′ + 𝑦 ′′ +
2! 0 3!
𝑦0 ′′′ + − − − − − − −(1)

𝑦′ = 𝑥 + 𝑦 ⟹ 𝑦0 ′ = 𝑥0 + 𝑦0 = 1 + 0 = 1

𝑦 ′′ = 1 + 𝑦 ′ ⟹ 𝑦0 ′′ = 1 + 𝑦0 ′ = 1 + 1 = 2

𝑦 ′′′ = 𝑦 ′′ ⟹ 𝑦0 ′′′ = 𝑦0 ′′ = 2

𝑦 ′𝑣 = 𝑦 ′′′ ⟹ 𝑦0 ′𝑣 = 𝑦0 ′′′ = 2 etc.,

By substituting the above derived values in (1), we get

0.1 (0.1)2 (0.1)3 (0.1)4


𝑦1 = 𝑦(1.1) = 0 + (1) + (2) + (2) + (2) + − − − − − − −
1! 2! 3! 4!

i.e., 𝑦1 = 𝑦(1.1) = 0.11034

***********************************************************
2) Using Taylor’s series method, find the value of y(0.1), given
𝑑𝑦
𝑑𝑥
= 𝑥 2 + 𝑦 2 and y(0)=1, correct to four decimal places.

Solution:

Compare the given condition y(0)=1 with 𝑦(𝑥0 ) = 𝑦0 we get 𝑥0 = 0 & 𝑦0 = 1

To find y(0.1)=y(x1)= 𝑦(𝑥0 + ℎ)

𝑦(𝑥0 + ℎ) = 𝑦(0 + ℎ) = 𝑦(0.1) ⟹ 0 + ℎ = 0.1 ⟹ ℎ = 0.1


ℎ ℎ2 ℎ3
Therefore 𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + 𝑦0 ′ + 𝑦0 ′′ + 𝑦0 ′′′ + − − − − − − −(1)
1! 2! 3!

𝑦 ′ = 𝑥 2 + 𝑦 2 --------------------⟹ 𝑦0 ′ = 𝑥0 2 + 𝑦0 2 = 0 + 1 = 1

𝑦 ′′ = 2𝑥 + 2𝑦𝑦 ′ ------------------⟹ 𝑦0 ′′ = 2𝑥0 + 2𝑦0 𝑦0 ′ = 2

𝑦 ′′′ = 2 + 2𝑦𝑦 ′′ + 2(𝑦 ′ )2----------⟹ 𝑦0 ′′′ = 2 + 2𝑦0 𝑦0 ′′ + 2(𝑦0 ′ )2 =8

𝑦 ′𝑣 = 2𝑦𝑦 ′′′ + 2𝑦 ′′ 𝑦 ′ + 4𝑦 ′ 𝑦 ′′

= 2𝑦𝑦 ′′′ + 6𝑦 ′′ 𝑦 ′ -------------⟹ 𝑦0 ′𝑣 = 2𝑦0 𝑦𝑜 ′′′ + 6𝑦𝑜 ′′ 𝑦0 ′ = 28

By substituting the above derived values in (1), we get

𝑦1 = 𝑦(0.1) = 1.1115

***********************************************************

3) Using Taylor’s series method , compute y(0.2) and y(0.4), correct to 4


𝑑𝑦
decimal places given 𝑑𝑥
= 1 − 2𝑥𝑦 and y(0)=0.

Solution:

Compare the given condition y(0)=1 with 𝑦(𝑥0 ) = 𝑦0 we get 𝑥0 = 0 & 𝑦0 = 1

To find y(0.2)=y(x1)= 𝑦(𝑥0 + ℎ)

𝑦(𝑥0 + ℎ) = 𝑦(0 + ℎ) = 𝑦(0.2) ⟹ 0 + ℎ = 0.2 ⟹ ℎ = 0.2


ℎ ℎ2 ℎ3
Therefore 𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + 1! 𝑦0 ′ + 𝑦 ′′ +
2! 0 3!
𝑦0 ′′′ + − − − − − − −(1)

𝑦 ′ = 1 − 2𝑥𝑦 -------------------⟹ 𝑦0 ′ = 1 − 2𝑥0 𝑦0 =1

𝑦 ′′ = −2(𝑥𝑦 ′ + 𝑦) ------------------⟹𝑦0 ′ ′=0

𝑦 ′′′ = −2(𝑥𝑦 ′′ + 𝑦 ′ + 𝑦 ′ )

= −2(𝑥𝑦 ′′ + 2𝑦 ′ ) -------------⟹𝑦0 ′′′ = −4


𝑦 ′𝑣 = −2(𝑥𝑦 ′′′ + 𝑦 ′′ + 2𝑦 ′′ )

= −2(𝑥𝑦 ′′′ + 3𝑦 ′′ ---------------⟹𝑦0 ′𝑣 = 0

𝑦 𝑣 = −2(𝑥𝑦 ′𝑣 + 4𝑦 ′′′ --------------⟹𝑦0 𝑣 =32

By substituting the above derived values in (1), we get

𝑦1 = 𝑦(0.2) = 0.1948---------------------------(2)

To find y(0.4)=y(x2)= 𝒚(𝒙𝟏 + 𝒉) = 𝒚(𝟎. 𝟐 + 𝟎. 𝟐)

Therefore
ℎ ℎ2 ℎ3
𝑦2 = 𝑦(0.4) = 𝑦1 + 1! 𝑦1 ′ + 𝑦 ′′ +
2! 1 3!
𝑦1 ′′′ + − − − − − − −(3)

𝑦 ′ = 1 − 2𝑥𝑦 --------------⟹ 𝑦1 ′ = 1 − 2𝑥1 𝑦1 = 1 − 2(0.2)(0.1948) = 0.9221


=

𝑦 ′′ = −2(𝑥𝑦 ′ + 𝑦) ------------------⟹𝑦1 ′ = −2(𝑥1 𝑦1 ′ + 𝑦1 ) = −0.7583

𝑦 ′′′ = −2(𝑥𝑦 ′′ + 𝑦 ′ + 𝑦 ′ )

= −2(𝑥𝑦 ′′ + 2𝑦 ′ ) -------------⟹𝑦1 ′′′ = −3.3851

𝑦 ′𝑣 = −2(𝑥𝑦 ′′′ + 𝑦 ′′ + 2𝑦 ′′ )

= −2(𝑥𝑦 ′′′ + 3𝑦 ′′ ---------------⟹𝑦1 ′𝑣 = 5.9041

By substituting the above derived values in (3), we get

𝑦2 = 𝑦(0.4) = 0.3599

***********************************************************

Practice problems

1) Find y(0.1) given 𝑦 ′ = 𝑥 2 𝑦 − 1, 𝑦(0) = 1

2) Solve 𝑦 ′ = 𝑥𝑦 + 𝑦 2 , 𝑦(0) = 1 at x=0.1, 0.2, 0.3


𝑑𝑦 1
3) Obtain y(4.4) given = , 𝑦(4) = 4 by taking h=0.2
𝑑𝑥 𝑥 2 +𝑦

𝑦2
4) Solve 𝑦 ′ = 𝑥 + 10, y(1.8)=0 for y(2).
Euler’s method
𝑑𝑦
Aim : To find the solution of 𝑑𝑥
= 𝑦 ′ = 𝑓(𝑥, 𝑦) − − − − − − − − − (1)

Subject to the initial condition 𝑦(𝑥0 ) = 𝑦0−−−−−−−−−−(2)

Formula : 𝒚(𝒙 + 𝒉) = 𝒚(𝒙) + 𝒉𝒇(𝒙, 𝒚) (or) 𝒚𝒏+𝟏 = 𝒚𝒏 + 𝒉𝒇(𝒙𝒏 , 𝒚𝒏 )---------(I)

Remark : Error is of order ℎ2

Problems:

1) Given 𝑦 ′ = −𝑦 and y(0)=1. Determine the value of y at

x = (0.01) (0.01) (0.04) by Euler method.


𝑑𝑦
Solution : Comparing the given equation with = 𝑓(𝑥, 𝑦)𝑎𝑛𝑑 𝑦(𝑥0 ) = 𝑦0 we
𝑑𝑥
write, f(x,y)=−y and 𝑥0 = 0 𝑎𝑛𝑑 𝑦0 = 1

Given step size h= 0.01

To find 𝑦1 = 𝑦(𝑥1 ) = 𝑦(0.01), 𝑦2 = 𝑦(𝑥2 ) = 𝑦(0.02), 𝑦3 = 𝑦(𝑥3 ) = 𝑦(0.03), 𝑦4 =


𝑦(𝑥4 ) = 𝑦(0.04)

By putting n=0 in the formula (I),

𝒚𝟏 = 𝒚𝟎 + 𝒉𝒇(𝒙𝟎 , 𝒚𝟎 ) = 1 + 0.01(−𝑦0 ) = 1 + 0.01(−1) = 0.99

By putting n=1 in the formula (I),

𝒚𝟐 = 𝒚𝟏 + 𝒉𝒇(𝒙𝟏 , 𝒚𝟏 ) = 0.99 + 0.01(−𝑦1 ) = 0.99 + 0.01(−0.99) = 0.9801

By putting n=2 in the formula (I),

𝒚𝟑 = 𝒚𝟐 + 𝒉𝒇(𝒙𝟐 , 𝒚𝟐 ) = 0.9801 + 0.01(−𝑦2 ) = 0.9801 + 0.01(−0.9801) = 0.9703

By putting n=3 in the formula (I),

𝒚𝟒 = 𝒚𝟑 + 𝒉𝒇(𝒙𝟑 , 𝒚𝟑 ) = 0.9703 + 0.01(−𝑦3 ) = 0.9703 + 0.01(−9703) = 0.9606

***********************************************************
2) Given 𝑦 ′ = 𝑥 + 𝑦 and y(0)=1. Determine the value of y at

x = (0.0) (0.2) (1.0) using Euler method.


𝑑𝑦
Solution: Comparing the given equation with 𝑑𝑥
= 𝑓(𝑥, 𝑦)𝑎𝑛𝑑 𝑦(𝑥0 ) = 𝑦0 we
write, f(x, y)=x + y and 𝑥0 = 0 𝑎𝑛𝑑 𝑦0 = 1

Given step size h= 0.2

To find 𝑦1 = 𝑦(𝑥1 ) = 𝑦(0.2), 𝑦2 = 𝑦(𝑥2 ) = 𝑦(0.4), 𝑦3 = 𝑦(𝑥3 ) = 𝑦(0.6), 𝑦4 = 𝑦(𝑥4 ) =


𝑦(0.8), 𝑦5 = 𝑦(𝑥5 ) = 𝑦(1.0)

By putting n=0 in the formula (I),

𝒚𝟏 = 𝒚𝟎 + 𝒉𝒇(𝒙𝟎 , 𝒚𝟎 ) = 1 + 0.2(𝑥0 + 𝑦0 ) = 1 + 0.2(0 + 1) = 1.2

By putting n=1 in the formula (I),

𝒚𝟐 = 𝒚𝟏 + 𝒉𝒇(𝒙𝟏 , 𝒚𝟏 ) = 1.2 + 0.2(𝑥1 + 𝑦1 ) = 1.2 + 0.2(0.2 + 1.2) = 1.48

By putting n=2 in the formula (I),

𝒚𝟑 = 𝒚𝟐 + 𝒉𝒇(𝒙𝟐 , 𝒚𝟐 ) = 1.48 + 0.2(𝑥2 + 𝑦2 ) = 1.2 + 0.2(0.4 + 1.48) = 1.856

By putting n=3 in the formula (I),

𝒚𝟒 = 𝒚𝟑 + 𝒉𝒇(𝒙𝟑 , 𝒚𝟑 ) = 1.856 + 0.2(𝑥3 + 𝑦3 ) = 1.856 + 0.2(0.6 + 1.856) = 2.3472

By putting n=4 in the formula (I),

𝒚𝟓 = 𝒚𝟒 + 𝒉𝒇(𝒙𝟒 , 𝒚𝟒 ) = 2.3472 + 0.2(𝑥4 + 𝑦4 ) = 2.3472 + 0.2(0.8 + 2.3472)


= 2.9467

***********************************************************
Improved Euler’s Method

Formula:
𝒉
𝒚𝒏+𝟏 = 𝒚𝒏 + [𝒇(𝒙𝒏 , 𝒚𝒏 ) + 𝒇(𝒙𝒏 + 𝒉, 𝒚𝒏 + 𝒉𝒇(𝒙𝒏 , 𝒚𝒏 ))] -----------(II)
𝟐

Problem 1: Given 𝑦 ′ = 𝑥 2 − 𝑦 and y (0) = 1. Find correct to 4 decimal


places, the value of y (0.1) by Improved Euler method.
𝑑𝑦
Solution : Comparing the given equation with 𝑑𝑥
= 𝑓(𝑥, 𝑦)𝑎𝑛𝑑 𝑦(𝑥0 ) = 𝑦0 we
write, f(x,y)= 𝑥 2 − 𝑦 and 𝑥0 = 0 , 𝑦0 = 1

Let the step size h be 0.1 Then formula (II) becomes


𝟎.𝟏
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟏) = 𝒚𝟎 + 𝟐 [𝒇(𝒙𝟎 , 𝒚𝟎 ) + 𝒇(𝒙𝟎 + 𝒉, 𝒚𝟎 + 𝒉𝒇(𝒙𝟎 , 𝒚𝟎 ))]---(1)

𝑓(𝑥0 , 𝑦0 ) = 𝑥0 2 − 𝑦0 = 0 − 1 = −1 -----------------------------(i)

𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ) = 1 + (0.1)(−1) = 0.9 ----------------(ii)

𝑓(𝑥0 + ℎ, 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 )) = 𝑓(0.1, 0.9) = (0.1)2 − 0.9 = −0.89 ------(iii)

Substituting the values derived in (i), (ii), (iii) in (1) we get

𝟎. 𝟏
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟏) = 𝟏 + [−𝟏 − 𝟎. 𝟖𝟗] = 𝟎. 𝟗𝟎𝟓𝟓
𝟐
***********************************************************

Problem 2 :Given 𝑦 ′ = 𝑦 + 𝑒 𝑥 and y(0)=0. Find the value of y at x=0.2 by


Improved Euler method.
𝑑𝑦
Solution : Comparing the given equation with = 𝑓(𝑥, 𝑦)𝑎𝑛𝑑 𝑦(𝑥0 ) = 𝑦0 we
𝑑𝑥
write, f(x,y)= 𝑦 + 𝑒 𝑥 and 𝑥0 = 0 , 𝑦0 = 0

Let the step size h be 0.2 Then formula (II) becomes


𝟎.𝟐
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟐) = 𝒚𝟎 + 𝟐 [𝒇(𝒙𝟎 , 𝒚𝟎 ) + 𝒇(𝒙𝟎 + 𝒉, 𝒚𝟎 + 𝒉𝒇(𝒙𝟎 , 𝒚𝟎 ))]---(1)

𝑓(𝑥0 , 𝑦0 ) = 𝑦0 + 𝑒 𝑥0 = 0 + 𝑒 0 = 1 -----------------------------(i)

𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ) = 0 + (0.2)(1) = 0.2 ----------------(ii)


𝑓(𝑥0 + ℎ, 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 )) = 𝑓(0.2, 0.2) = 0.2 + 𝑒 0.2 = 1.4214 ------(iii)

Substituting the values derived in (i), (ii), (iii) in (1) we get

𝟎. 𝟐
𝒚𝟏 = 𝒚(𝒙𝟏 ) = 𝒚(𝟎. 𝟐) = 𝟎 + [𝟏 + 𝟏. 𝟒𝟐𝟏𝟒] = 𝟎. 𝟐𝟒𝟐𝟏𝟒
𝟐

Practice Problems:

1) Use Euler method to find y(0.4) given 𝑦 ′ = 𝑥𝑦, 𝑦(0) = 1

2) Compute y(0.2), y(0.4), y(0.6) by Euler’s method , given 𝑦 ′ =


log(𝑥 + 𝑦) , 𝑦(0) = 1

3) By improved Euler’s method, determine y(0.1) given


𝑦−𝑥
𝑦′ = , 𝑦(0) = 1
𝑦+𝑥

4) Find by improved Euler’s method to get y(1.4) given


𝑑𝑦 2𝑦
𝑑𝑥
= 𝑥
+ 𝑥 3 if y(1)=0.5

5) Using improved Euler’s method, find the value of y at x=0.2

Given 𝑦 ′ = −𝑥𝑦 2 , 𝑦(0) = 2

***********************************************************

You might also like