This document provides an overview of numerical methods for solving ordinary differential equations. It begins with introducing the content, which includes initial value problems, boundary value problems, linear systems, variational methods, eigenproblems, and partial differential equations. It then discusses four main topics: introduction to ordinary differential equations, methods for solving initial value problems, methods for solving boundary value problems, and types of problems in initial value problems. For initial value problems, it covers single-step methods like Taylor series, Euler's method, and Runge-Kutta as well as multi-step methods and extrapolation. It also discusses error analysis and higher-order methods.
5. 1) Introduction
1- Sources of errors
1.1- Initial data error
1.2- Round off error
1.3- Truncation error
2- Type of problems
2.1- well – behaved
2.2- ill – conditioned
3- Stability
4- Big Oh
٥
6. 2) Methods of solving IVP
1- Introduction
2- Taylor series method
3- Single step methods
4- Multi step methods
5- Extrapolation methods
٦
7. 3) Methods of solving BVP
1- Shooting methods
2- Finite difference methods
3- Variational methods
4- Eigen Value Problems (EVP)
٧
8. Types of problems in IVP
Single first order equation
System of n first order equations
Single n th order equation
٨
9. Single first order equation
, with initial condition (IC),
)
,
( y
x
f
y =
′
0
0 )
( y
x
y =
To find y at x1 to a specified accuracy.
٩
10. System of n first order equations
),
,...,
,
(
)
,...,
,
(
1
1
1
1
n
n
n
n
y
y
x
f
y
y
y
x
f
y
=
′
=
′
With initial conditions
0
0
10
0
1
)
(
)
(
n
n y
x
y
y
x
y
=
=
To find y1,…yn at x1 to a specified accuracy.
١٠
11. Where [ ]t
n
1 y
,
,
y
Y
=
and [ ]t
n
1 f
,
,
f
F
=
In matrix form
0
0 Y
)
Y(x
Y)
F(x,
Y
=
=
′
١١
12. Single n th order equation
),
,
,
,
,
,
( )
1
(
)
( −
′
′
′
= n
n
y
y
y
y
x
f
y
with initial conditions
0
0
)
1
(
10
0 )
(
,
,
)
( n
n
y
x
y
y
x
y =
= −
This equation with the given initial conditions can be
transformed into a system of n first order equations
as follows,
١٢
13. Let n
n
y
y
y
y
y
y =
=
′
= − )
1
(
2
1 then
( )
n
n y
y
y
x
f
y ,
,
,
, 2
1
=
′
and
0
0
10
0
1 )
(
,
)
( n
n y
x
y
y
x
y =
=
The whole system can be written in the matrix form
0
0 )
(
)
,
(
Y
x
Y
Y
x
F
Y
=
=
′
Where [ ] [ ]t
n
t
n f
y
y
y
F
y
y
Y ,
,
,
,
,
, 3
2
1
=
= and
١٣
14. Finally we are dealing with the form
0
0 )
(
)
,
(
y
x
y
y
x
f
y
=
=
′ as a single first order equation or
as a system of n first order equations
١٤
15. Taylor series method
0
0 )
(
)
,
(
y
x
y
y
x
f
y
=
=
′ To find y at x1 correct to md
Let x1 – x0 = h then the Taylor expansion of y about
x = x0 is
( ) ( )
+
′
′
′
+
′
′
+
′
+
=
+
= y
h
y
h
y
h
y
h
x
y
x
y
!
3
!
2
3
0
2
0
0
0
1
١٥
17. ( )
( ) 2
0
1
0
3 2
−
=
′
=
−
+
=
′
′
y
y
y
x
y
Given
:
Example
on
so
and
Find y(h) correct to 2d where h=0.1, 0.5,1 and 2.
١٧
18. ( )
( ) 14
)
0
(
3
2
12
)
0
(
2
5
)
0
(
2
1
2
)
0
(
)
5
(
)
5
(
)
4
(
2
)
4
(
=
⇒
′
′
′
+
′
′
′
−
=
−
=
⇒
′
′
+
′
−
=
=
′
′
′
⇒
′
−
=
′
′
′
=
′
′
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
have
we
( )
+
+
−
+
+
−
= 5
4
3
2
60
7
2
1
6
5
2
1 h
h
h
h
h
h
y
١٨
19. Taking number of terms n=6
When h=0.1 y(0.1)=.8107845000
h=0.5 y(0.5)=.3265625000
h=1 y(1)=.4500000000
h=2 y(2)=3.400000000
Taking number of terms n=7
y(0.1)= .8107846111
y(0.5)= .3282986111
y(1)= .5611111111
y(2)= 10.51111111
١٩
21. Single step methods
Def.:
Local truncation error
Global truncation error
Order of a method
First order method (Euler's method)
Statement of the problem
( )
( ) 0
0
,
y
x
y
y
x
f
y
=
=
′
given
٢١
22. To find y at x=b correct to md
Let b-x0=h then
( ) ( ) ( )
2
0
0
0
0
0 , h
y
x
f
h
y
y
h
y
b
y o
+
+
=
′
+
=
Here O(h2) is the local truncation error
In the standard form
( )
,
1
,
0
,
1
1
1
=
=
+
=
+
n
y
x
f
h
k
k
y
y
n
n
n
n where
٢٢
23. Second order methods
( )
( )
( ) error
truncation
global
the
is
and
where
1.
2
1
2
1
2
2
1
2
,
2
,
h
O
k
y
h
x
f
h
k
y
x
f
h
k
h
O
k
y
y
n
n
n
n
n
n
+
+
=
=
+
+
=
+
٢٣
24. ( )
( )
( )
( ) g.t.e.
before
as
where
2.
2
1
2
1
2
2
1
1
,
,
2
1
2
1
h
O
k
y
h
x
f
h
k
y
x
f
h
k
h
O
k
k
y
y
n
n
n
n
n
n
+
+
=
=
+
+
+
=
+
٢٤
25. A third order method
( ) ( )
( )
( )
1
2
3
1
2
1
3
3
2
1
1
2
,
2
,
2
,
,
2
,
1
4
6
1
k
k
y
h
x
f
h
k
k
y
h
x
f
h
k
y
x
f
h
k
n
h
O
k
k
k
y
y
n
n
n
n
n
n
n
n
−
+
+
=
+
+
=
=
=
+
+
+
+
=
+
where
٢٥
26. A 4th order method (runge – kutta)
( ) ( )
( )
( )
3
4
2
3
1
2
1
4
4
3
2
1
1
,
2
,
2
2
,
2
,
2
2
6
1
k
y
h
x
f
h
k
k
y
h
x
f
h
k
k
y
h
x
f
h
k
y
x
f
h
k
h
O
k
k
k
k
y
y
n
n
n
n
n
n
n
n
n
n
+
+
=
+
+
=
+
+
=
=
+
+
+
+
+
=
+
where
٢٦
27. Example:
( )
( ) ( ) 2
0
,
1
0
2
sin
=
′
=
′
+
+
=
′
′
y
y
y
y
x
y
Find y(0.1) and y’(0.1) using h=0.1 and a 2nd order
method.
( )
( )
( ) 2
0
1
0
2
sin
=
=
+
+
=
′
=
′
p
y
p
y
x
p
p
y then
Let
٢٧
28. Take k for the slope of y and l for the slope of p
then
( )
( )
( )
( ) ( ) ( ) ( )
[ ]
1
0
1
0
0
2
1
0
2
0
0
0
1
0
1
2
1
0
1
2
1
0
1
2
sin
2
sin
2
1
2
1
l
p
k
y
h
x
h
l
l
p
h
k
p
y
x
h
l
p
h
k
l
l
p
p
k
k
y
y
+
+
+
+
+
=
+
=
+
+
=
=
+
+
=
+
+
=
where
Now calculate [Note the argument of sine must the in
radiance].
٢٨
29. Modified Euler's method
( )
( ) ( )
[ ] ( )
( ) g.t.e.
the
is
where
2
2
1
1
1
1
,
,
2
,
h
O
h
O
y
x
f
y
x
f
h
y
y
y
x
f
h
y
y
p
n
n
n
n
n
c
n
n
n
n
p
n
+
+
+
=
+
=
+
+
+
+
( ) ( )
( ) error.
truncation
local
the
is
where
2
2
1 ,
2
h
O
h
O
y
x
hf
y
y n
n
n
n +
+
= −
+1
Mid - Point rule
٢٩
30. How to control the truncation error
1) By lowering the step size and repeat the
whole calculations: Runge-Kutta method
2) By considering the 1st neglected term in
the Taylor expansion:
Merson’s method
A 2nd and third order method
Fehlberge’s method
٣٠
31. A single-step method with error estimator
Merson’s method
( ) ( )
( )
( )
5
4
3
1
4
3
1
5
3
1
4
2
1
3
1
2
1
5
5
4
1
1
8
9
2
30
1
2
2
3
2
,
8
3
8
,
2
6
6
,
3
3
,
3
,
4
6
1
k
k
k
k
E
k
k
k
y
h
x
hf
k
k
k
y
h
x
hf
k
k
k
y
h
x
hf
k
h
y
h
x
hf
k
y
x
hf
k
h
O
k
k
k
y
y
n
n
n
n
n
n
n
n
n
n
n
n
−
+
−
=
+
−
+
+
=
+
+
+
=
+
+
+
=
+
+
=
=
+
+
+
+
=
+
where
٣١
36. Extrapolation methods
1.Introduction:
Consider calculating π as the area of a unit circle
(Fig.1), by calculation of the area of n sided
polygon inscribed in the circle.
n
θ
1
Fig. 1
n
A0
Let be the area of n sided polygon.
=
=
n
n
n
A n
n π
θ
2
sin
2
sin
2
0
٣٦
37. Using Taylor expansion of Sin x
+
+
+
+
=
+
−
+
−
=
6
6
4
4
2
2
7
5
3
0
!
7
2
!
5
2
!
3
2
2
2
n
a
n
a
n
a
n
n
n
n
n
An
π
π
π
π
π
Where a2, a4, a6, … are constants, do not depend on n.
Now if we double n then
+
+
+
+
= 6
6
4
4
2
2
2
0
64
16
4 n
a
n
a
n
a
A n
π
٣٧
38. To form a linear combination of
in such away that in the linear combination
the first term be π and the second term
vanishes, that is, for some α and β
n
n
A
A 2
0
0 and
+
+
+
+
=
=
+ 8
8
6
6
4
4
1
2
0
0
n
b
n
b
n
b
A
A
A n
say
n
n
π
β
α
Where b4, b6, b8, … are constants, do not depend on n.
0
4
1 =
+
=
+
β
α
β
α and
Then
The implies that
3
4
3
1 =
−
= β
α and
٣٨
39. To go further we can repeat the same procedure
by doubling the sides again and hence.
+
+
+
+
= 8
8
6
6
4
4
2
1
256
64
16 n
b
n
b
n
b
A n
π
Again to form a linear combination of
in such away that in the linear combination the first term be
p and the second term vanishes, that is for some α and β.
n
n
A
A 2
1
1 and
,
8
8
6
6
2
2
1
1
+
+
+
=
=
+
n
c
n
c
A
A
A n
say
n
n
π
β
α
٣٩
40. Where c6, c8, … are constants, do not depend
on n.
,
8
8
6
6
2
2
1
1
+
+
+
=
=
+
n
c
n
c
A
A
A n
say
n
n
π
β
α
1,2,
n
for
and
general
In
and
that
implies
this
and
Then
=
−
=
−
−
=
=
−
=
=
+
=
+
1
4
4
1
4
1
15
16
15
1
,
0
16
1
n
n
n
β
α
β
α
β
α
β
α
٤٠
41. The result of above operations can be
presented in an extrapolation table as
follows.
n
n
n
n
n
n
n
n
n
n
A
A
A
A
A
A
A
A
A
A
3
2
2
4
1
8
0
2
2
1
4
0
1
2
0
0 3
1
−
3
4
15
1
−
15
16
Note that truncation error of the columns respectively are
on.
so
and
,
1
,
1
,
1
6
4
2
n
O
n
O
n
O
63
1
−
63
64
٤١
42. Numerically
1. Starting with a triangle (the least accuracy),
we have
Are these coefficients (α and β) general?
=
3
0
A
=
6
0
A
=
12
0
A
=
24
0
A
=
48
0
A
1.299038
2.598077
3.000001
3.105829
3.132629
3.03109
3.133975
3.141105
3.141563
3.140834
3.141581
3.141593
3.141593
3.141593 3.141593
٤٢
46. 1. yes, whenever the accuracy parameter
is changed by factor of 2. and the terms
of the Taylor expansion are alternatively
zero.
2. No otherwise
٤٦
47. Extrapolation in differentiation
Starting with central difference formula for
the first and second derivative
( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) )
2
(
2
)
1
(
2
2
2
2
h
O
h
h
x
f
x
f
h
x
f
x
f
h
O
h
h
x
f
h
x
f
x
f
+
−
+
−
+
=
′
′
+
−
−
+
=
′
Denote the RHS of (1) as and the RHS of (2) as
h
F0
h
S0
٤٧
48. Similar extrapolation table looks like
h
h
h
h
h
h
F
F
F
F
F
F
2
2
1
4
0
1
2
0
0 3
1
−
3
4
15
1
−
15
16
The truncation error of the columns in order are
( ) ( ) ( ) .
on
so
and
and
6
4
2
, h
O
h
O
h
O
Similarly for the second derivative
٤٨
49. Extrapolation in integration
Consider the trapezoidal rule
( ) ( )
+
+
=
+
=
∑
∫
−
=
1
1
0
0
2
0
2
2
n
i
i
n
h
h
b
a
f
f
f
h
T
h
O
T
dx
x
f
where
h
h
h
h
h
h
T
T
T
T
T
T
2
2
1
4
0
1
2
0
0 3
1
−
3
4
15
1
−
15
16
٤٩
50. Extrapolation in IVP
Suppose y'=f(x,y) , y(x0)=y0 to find y(b)
correct to md, with extrapolation method.
Start with Mid-Point rule
( ) ( )
2
0
0
1
1 ,
2 h
O
y
x
hf
y
y +
+
= −
Either y-1is known previously or it should be
calculated by, say, Euler's method and corrected by
modified Euler's method to have the same accuracy
as O(h2)
٥٠
51. therefore with h<0
( )
( ) ( )
[ ]
E
c
E
y
x
f
y
x
f
h
y
y
y
x
hf
y
y
1
1
0
0
0
1
0
0
0
1
,
,
2
,
−
−
−
−
+
−
=
−
=
and
If we denote then in extrapolation notation
h
Y
y 0
1 by
h
h
h
h
h
h
Y
Y
Y
Y
Y
Y
2
2
1
4
0
1
2
0
0 3
1
−
3
4
15
1
−
15
16
٥١
52. And so on.
Compare this method with single step
methods and multi step methods.
٥٢
53. Example
Consider y'=y , y(0)=1 . To find y(1)
correct to 3d .
start with h=1 , y0=1 , x0=0
[ ]
2
1
0
2
1
1
1
1
0
1
1
8
21
8
13
1
8
13
1
8
5
8
5
2
1
1
4
1
1
2
1
2
1
1
2
1
5
.
2
2
2
1
2
1
0
1
2
1
1
,
0
Y
y
y
y
y
h
Y
y
y
c
E
c
E
=
=
+
=
=
+
=
=
+
−
=
=
−
=
=
=
+
=
=
+
−
=
=
−
−
−
−
with
٥٣
54. To continue calculate and and
extrapolate.
6666
.
2
6
16
2
7
6
5
8
21
3
4
2
5
3
1
3
4
3
1 2
1
0
1
0
1
1
=
=
+
−
=
+
−
=
+
−
= Y
Y
Y
4
1
0
Y 8
1
0
Y
٥٤
55. Shooting methods
Statement of a boundary value problem
( )
( ) ( )
=
=
′
=
′
′
β
α b
y
a
y
y
y
x
f
y
,
,
,
Given
Find y for a<x<b correct to md.
Shooting method changes the BVP into an IVP by assuming
a value for y'(a) , say S, then using a root finder to find the
root of y(b,S)-β=0 up to a desired accuracy.
1. Secant method
2. Newton’s method
٥٥
56. Let us start with secant method as the root finder
Step 1. Guess S0=y'(a)
Step 2. Solve the IVP
( ) ( ) ( ) ,
,
,
,
, 0
S
a
y
a
y
y
y
x
f
y =
′
=
′
=
′
′ α
to find y(b, S0) .
Is y(b, S0)=β ? if yes then stop, otherwise continue
( ) ( )
( ) ( ) β
β
>
<
′
=
<
>
′
=
0
0
1
0
0
1
,
,
S
b
y
if
S
a
y
S
S
b
y
if
S
a
y
S otherwise
Guess
Step 4. Solve the IVP
( ) ( ) ( ) ,
,
,
,
, 1
S
a
y
a
y
y
y
x
f
y =
′
=
′
=
′
′ α
to find y(b, S1).
Step 3.
٥٦
57. Is y(b, S1)=β ? If yes then stop, otherwise continue.
Step 5. Find the next Sn+1 ,using secant method.
( )
[ ]( )
( ) ( )
,
2
,
1
,
,
,
1
1
1 =
−
−
−
−
=
−
−
+ n
S
b
y
S
b
y
S
S
S
b
y
S
S
n
n
n
n
n
n
n
β
Step 6. Solve the IVP
( ) ( ) ( )
( )
1
1
,
,
,
,
,
,
+
+
=
′
=
′
=
′
′
n
n
S
b
y
S
a
y
a
y
y
y
x
f
y
find
to
α
Step 7. Test for convergence
( ) stop
then
yes
if
Is Tol
S
b
y n <
−
+ β
1
,
Step 8. Go to step 5.
٥٧
58. Example 1:
Given ( )
( ) 3
1
,
3
2
1
2
2
=
=
−
′
−
=
′
′
y
y
y
x
y [note that this is a linear differential equation]
To find y for 1
2
1
<
< x correct to 3d.
( )
( )
[ ]
( ) 0001
.
3
,
1
2
7500
.
3
6250
.
3
2
1
3
6250
.
3
2
1
6250
.
3
,
1
2
1
7500
.
3
,
1
1
2
2
0
1
0
0
=
−
=
−
−
−
−
=
=
=
=
=
S
y
S
S
y
S
S
y
S
٥٨
59. x y
0.5 3
0.6 2.8667
0.7 2.8287
0.8 2.8501
0.9 2.9112
1 3.0001
٥٩
60. Example 2:
Given
( ) ( ) 8
2
,
4
1
2
1
=
=
′
+
′
=
′
′
y
y
y
y
x
y
y [this is a nonlinear differential equation]
To find y for 1<x<2 correct to 3d.
( ) ( )
( )
[ ]( )
( ) ( )
,
2
,
1
,
2
,
2
8
,
2
0
8
,
2
1
1
1 =
−
−
−
−
=
=
−
=
−
−
+ n
S
y
S
y
S
S
S
y
S
S
S
y
S
F
n
n
n
n
n
n
n
٦٠
61. ( )
( )
( )
( )
( )
( )
( ) 000000
.
8
,
2
333333
.
1
9902356
.
7
,
2
3331706
.
1
9688716
.
7
,
2
328125
.
1
2580645
.
8
,
2
375
.
1
111111
.
7
,
2
16667
.
1
4
.
6
,
2
1
16
,
2
2
6
6
5
5
4
4
3
3
2
2
1
1
0
0
=
=
=
=
=
=
=
=
=
=
=
=
=
=
S
y
S
S
y
S
S
y
S
S
y
S
S
y
S
S
y
S
S
y
S
٦١
62. x y
1 4
1.1 4.1450
1.2 4.3165
1.9 7.0793
2 7.9994
٦٢
63. In case of Newton's method as the root finder the steps will be
as follows
Step 1. Guess S0=y'(a)
Step 2. Solve the system
( )
( )
( )
( )
( )
=
∂
′
∂
=
∂
∂
=
′
=
∂
′
∂
⋅
′
∂
∂
+
∂
∂
⋅
∂
∂
=
∂
′
′
∂
′
=
′
′
1
0
,
,
0
S
a
y
S
a
y
S
a
y
a
y
S
y
y
f
S
y
y
f
S
y
y
y
x
f
y
α (1)
٦٣
64. By any IVP method find y(b, S0), y' (b, S0) and
( ) ( )
0
0 ,
,
, S
b
S
y
S
b
S
y
∂
′
∂
∂
∂
Step 3. Find a new Sn using Newton’s method
( )
( )
,
1
,
0
,
,
1 =
∂
∂
−
−
=
+ n
S
b
s
y
S
b
y
S
S
n
n
n
n
β
Step 4. Solve the system(1) with new Sn=y'(a)
Step 5. Test for convergence, i.e.
( ) stop
then
yes
if
Tol
S
b
y n <
− β
,
٦٤
65. Step 6. Go to step 3.
Example: Find y for 1<x<2, given
( ) ( )
then
and
denote
us
let
system(1)
solve
to
now
guess
U
S
y
Y
S
y
S
y
y
y
y
x
y
y
=
∂
′
∂
=
∂
∂
=
=
=
′
+
′
=
′
′
2
8
2
,
4
1
2
1
0
٦٥
66. if
( )
( )
( )
( ) 1
1
0
1
1
4
1
4
1
2
2
1
0
2
2
=
=
=
=
⋅
+
+
⋅
−
=
′
=
′
+
=
′
=
′
U
Y
S
p
y
U
y
p
x
Y
y
p
U
U
Y
y
p
x
p
p
p
y then
٦٦
67. Solve by 4th order Runge-Kutta with h=0.01 (say) then
( ) ( )
66666667
.
1
24
,
2
16
,
2
1
0
0
=
=
∂
∂
=
S
S
S
y
S
y
implies
this
and
Next five iterations yields
( ) ( )
( ) ( )
( ) ( )
( ) ( )
( ) ( ) 000000
.
6
,
2
000000
.
8
,
2
33333333
.
1
00018279
.
6
,
2
00012208
.
8
,
2
333353689
.
1
04715063
.
6
,
2
03137248
.
8
,
2
33854166
.
1
82666667
.
6
,
2
5333333
.
8
,
2
416666667
.
1
6666667
.
10
,
2
6666667
.
10
,
2
66666667
.
1
5
5
5
4
4
4
3
3
3
2
2
2
1
1
1
=
∂
∂
=
=
=
∂
∂
=
=
=
∂
∂
=
=
=
∂
∂
=
=
=
∂
∂
=
=
S
S
y
S
y
S
S
S
y
S
y
S
S
S
y
S
y
S
S
S
y
S
y
S
S
S
y
S
y
S
٦٧
68. Finite difference methods
Statement of the problem:
Given the BVP
( )
( ) ( ) β
α =
=
′
=
′
′
b
y
a
y
y
y
x
f
y
,
,
,
Find y for a<x<b correct to md.
There are two cases:
1. Linear equation, in general
( ) ( ) ( )
( ) ( ) β
α =
=
+
+
′
=
′
′
b
y
a
y
x
r
y
x
q
y
x
p
y
,
٦٨
69. 2. Non linear equation
( )
( ) ( ) β
α =
=
′
=
′
′
b
y
a
y
y
y
x
f
y
,
,
,
The above two cases are called BVPs with separated
boundary conditions.
BVP with general linear boundary values are of the
form
( )
( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) 5
4
3
2
1
5
4
3
2
1
,
,
B
b
y
B
b
y
B
a
y
B
a
y
B
A
b
y
A
b
y
A
a
y
A
a
y
A
y
y
x
f
y
=
′
+
+
′
+
=
′
+
+
′
+
′
=
′
′
٦٩
70. BVP with general boundary conditions are of
the form
( )
( ) ( ) ( ) ( )
( )
( ) ( ) ( ) ( )
( ) 0
,
,
,
,
0
,
,
,
,
,
,
2
1
=
′
′
=
′
′
′
=
′
′
b
y
b
y
a
y
a
y
b
g
b
y
b
y
a
y
a
y
a
g
y
y
x
f
y
The idea of finite difference methods is to discretise
the equation by dividing the interval [a,b] into n
equal divisions, i.e.
h
n
a
b say
==
−
٧٠
71. b
x
n
i
ih
x
x
a
x n
i =
−
=
+
=
= ,
1
,
,
1
, 0
0
then
The BVP becomes
( )
β
α =
=
=
′
=
′
′
n
i
i
i
i
y
y
a
x
y
y
x
f
y
,
,
,
,
0
0
Now we replace the derivatives by an approximate
value of finite difference such as:
٧١
73. Central-difference expressions with error of order h4
4
3
2
1
1
2
3
3
3
2
1
1
2
3
2
2
1
1
2
2
1
1
2
6
12
39
56
39
12
8
8
13
13
8
12
16
30
16
12
8
8
h
y
y
y
y
y
y
y
y
h
y
y
y
y
y
y
y
h
y
y
y
y
y
y
h
y
y
y
y
y
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
−
−
−
+
+
+
−
−
−
+
+
+
−
−
+
+
−
−
+
+
−
+
−
+
−
+
−
=
′
′
′
′
+
−
+
−
+
−
=
′
′
′
−
+
−
+
−
=
′
′
+
−
+
−
=
′
٧٣
74. Forward-difference expressions with error of order h
4
1
2
3
4
3
1
2
3
2
1
2
1
4
6
4
3
3
2
h
y
y
y
y
y
y
h
y
y
y
y
y
h
y
y
y
y
h
y
y
y
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
+
−
+
−
=
′
′
′
′
+
+
−
=
′
′
′
+
−
=
′
′
−
=
′
+
+
+
+
+
+
+
+
+
+
٧٤
76. Backward-difference expressions with error of order h
4
4
3
2
1
3
3
2
1
2
2
1
1
4
6
4
3
3
2
h
y
y
y
y
y
y
h
y
y
y
y
y
h
y
y
y
y
h
y
y
y
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
i
−
−
−
−
−
−
−
−
−
−
+
−
+
−
=
′
′
′
′
−
+
−
=
′
′
′
+
−
=
′
′
−
=
′
٧٦
78. In linear case we have, using the central difference
forms with truncation error of O(h2),
( ) ( ) ( )
1
,
,
1
,
2
2
0
1
1
2
1
1
−
=
=
=
+
+
−
=
+
− −
+
−
+
n
i
y
y
x
r
y
x
q
h
y
y
x
p
h
y
y
y
n
i
i
i
i
i
i
i
i
i
β
α
After some simplifications
1
,
,
1
,
0
1
1
−
=
=
=
=
+
+ +
−
n
i
y
y
D
y
C
y
B
y
A
n
i
i
i
i
i
i
i
β
α
Where
i
i
i
i
i
i
i
i
r
h
D
hp
C
q
h
B
hp
A
2
2
2
2
2
4
2
=
+
=
−
−
=
−
=
٧٨
82. In non linear case, using central difference
formulas with truncation error O(h2)
( )
( )
1
,
,
1
,
,
2
/
,
,
2
0
1
1
2
1
1
−
=
=
=
−
=
+
− −
+
−
+
n
i
y
y
h
y
y
y
x
f
h
y
y
y
n
i
i
i
i
i
i
i
β
α
Using simple iteration method, with suitable initial
guess
( )
,
1
,
0
1
,
,
1
,
2
,
,
2
2
1
0
)
1
(
1
)
(
1
)
(
2
)
(
1
)
1
(
1
1
=
−
=
=
=
−
−
+
=
+
−
+
+
+
−
+
k
n
i
y
y
h
y
y
y
x
f
h
y
y
y
n
k
i
k
i
k
i
i
k
i
k
i
k
i
β
α
٨٢
83. Example:
( ) ( ) 8
2
,
4
1
2
1
=
=
′
+
′
=
′
′
y
y
y
y
x
y
y
Find y for 1<x<2 correct to 5d.
Upon discritisation we have,
( )
,
1
,
0
,
1
,
,
1
8
,
4
1
2
2
2
1
0
)
(
)
1
(
1
)
(
1
)
1
(
1
)
(
1
2
)
(
1
)
1
(
1
)
1
(
=
−
=
=
=
−
+
−
−
+
=
+
−
+
+
−
+
+
+
−
+
k
n
i
y
y
y
h
y
y
x
h
y
y
h
y
y
y
n
k
i
k
i
k
i
i
k
i
k
i
k
i
k
i
k
i
٨٣
84. Now, take
N=5 ⇒ h=0.2 ⇒
After k= 50 iterations and Tol=
6
10−
1.2 4.30868851
1.4 4.74347837
1.6 5.37398310
1.8 6.34221887
i
x i
y
٨٤
85. Take N=10 ⇒ h=0.1
After k= iterations
1.1
1.2 4.31464627
1.3
1.4 4.75747894
1.5
1.6 5.39795103
1.7
1.8 6.37355180
1.9
i
x i
y
٨٥
86. To improve the accuracy
1. Either increase n smaller h
Larger system of equations
2. Use extrapolation,
In the above example
⇒ ⇒
Improved ( )
3
1
4
.
1 −
=
y less accurate ( )
3
4
4
.
1 +
y more accurate y(1.4)
( ) ( )
( )
4
762145797
.
4
75747894
.
4
3
4
74347837
.
4
3
1
h
O
+
=
+
−
=
Continue to improve accuracy.
٨٦
87. Iterative methods for system of linear equations.
To solve
1) Ax=b
Where
=
=
=
n
n
nn
n
n
b
b
b
x
x
a
a
a
a
A
1
1
1
1
11
,
,x
2)
n
n
nn
n
n
n
b
x
a
x
a
b
x
a
x
a
=
+
+
=
+
+
1
1
1
1
1
11
3)
n
i
b
x
a
n
i
b
x
a
x
a
n
j
i
j
ij
i
n
in
i
,
,
1
,
,
1
1
1
1
=
=
=
=
+
+
∑
=
4)
٨٧
88. Pivoting , Scaling
Jacobi’s method: guess n
i
xi ,
,
1
)
0
(
=
=
=
−
= ∑
≠
=
+
,
1
,
0
,
,
1
1
1
)
(
)
1
(
k
n
i
x
a
b
a
x
n
i
j
j
k
j
ij
i
ii
k
i
Test for convergence at each iteration
Tol
x
x k
j
k
j <
−
+ )
(
)
1
(
For all j=1,…,n
٨٨
89. Guess – Seidel method
,
1
,
0
,
,
,
1
1
,
,
1
1
)
(
1
1
)
1
(
)
1
(
)
0
(
=
=
−
−
=
=
∑
∑ +
=
−
=
+
+
k
n
i
x
a
x
a
b
a
x
n
i
x
n
i
j
k
j
ij
i
j
k
j
ij
i
ii
k
i
i
Guess
Test for convergence
٨٩
90. Successive Over Relaxation (SOR)
method
,
1
,
0
,
,
,
1
,
,
1
)
(
1
1
)
1
(
)
(
)
1
(
)
0
(
=
=
−
−
+
=
=
∑
∑ =
−
=
+
+
k
n
i
x
a
x
a
b
a
x
x
n
i
x
n
i
j
k
j
ij
i
j
k
j
ij
i
ii
k
i
k
i
i
ω
Guess
Test for convergence
required?
is
or b
opt ω
ω .
٩٠
91. 1. No general formula for
2. depends on the form of A.
3. 0< <2
When 1< <2 we have over relaxation and when
0< <1 we have under relaxation
4. to be calculated numerically.
b
ω
b
ω
b
ω
b
ω
b
ω
b
ω
٩١
93. Variational methods
Introduction
Distance between two points
[ ] ( ) ( )
∫ ∫
+
=
+
=
2
1
2
1
2
2
2
1
x
x
x
x
dx
dx
dy
dy
dx
y
I
To minimize I[y] set its derivative to zero.
There are certain restrictions on each y which must
pass through ,etc.
( ) ( )
2
2
1
1 ,
, y
x
y
x &
2
y
1
y
1
x 2
x
4
y
3
y 2
y
1
y
٩٣
94. E-L eqn. ( ) ( )
y
y
x
F
y
y
y
x
F
y
dx
d
′
∂
∂
=
′
′
∂
∂
,
,
,
,
If F is independent of 0
=
∂
∂
⇒
′
y
F
y
If F is independent of C
y
F
y
F
dx
d
y =
′
∂
∂
⇒
=
′
∂
∂
⇒ 0
If F is independent of
0
=
′
∂
∂
′
−
=
′
∂
∂
′
−
⇒
y
F
y
F
dx
d
C
y
F
y
F
x
or
٩٤
95. Now to solve the BVP
( )
[ ] ( ) ( )
( ) ( ) 0
1
0 =
=
=
+
′
′
−
y
y
x
f
y
x
q
y
x
p
The Rayleigh - Ritz method minimizes the E-L
equation
[ ] ( ) ( )
[ ] ( ) ( )
[ ] ( ) ( )
{ }
∫ −
+
′
=
1
0
2
2
2 dx
x
u
x
f
x
u
x
q
x
u
x
p
u
I
Choose u to be a linear combination of some basis
function such as few first terms of Taylor expansion
or in general ∑
= i
i
c
u φ
٩٥
96. Where are chosen in such away to satisfy the
boundary conditions
Now for minimization find
and equate to zero
These are called the normal equations which can be
solved by a method of linear systems.
i
φ
( ) ( )
[ ]
0
1
0 =
= i
i φ
φ
n
i
c
I
i
,
,
1
=
∂
∂
n
i
c
I
i
,
,
1
0
=
=
∂
∂
٩٦
97. Example:
Let us choose the basis to be the linear functions
( )
≤
<
≤
<
−
<
<
−
≤
≤
=
+
+
+
−
−
−
−
1
0
0
0
1
1
1
1
1
1
1
x
x
x
x
x
h
x
x
x
x
x
h
x
x
x
x
x
i
i
i
i
i
i
i
i
i
i
i
i
φ
( )
x
i
φ
x
0
1
1
−
i
x i
x 1
+
i
x 1
٩٧
98. The normal equations yield a tridiagonal linear
system which can be solved by previously
introduced methods.
Example:
( ) ( ) 0
1
0
4
2
2 2
2
=
=
−
=
+
′
−
′
′
−
y
y
x
y
y
x
y
x
Given
Use h=0.1 and linear approximation.
Now given
( )
( ) ( ) 0
=
=
=
+
′
′
b
y
a
y
x
f
Qy
y
٩٨
99. Then E-L equation
[ ] [ ]
{ }
∫ +
−
′
=
b
a
dx
fu
Qu
u
u
I 2
2
2
to be minimized.
B.C.
&
If
2
2
1
0 x
c
x
c
c
u +
+
=
2
1
0
2
1
0
,
0
,
0
,
0 c
c
c
c
I
c
I
c
I
gives
then =
∂
∂
=
∂
∂
=
∂
∂
B.C.
&
If
3
3
2
2
1
0 x
c
x
c
x
c
c
u +
+
+
=
on.
so
&
gives
then 3
,
2
,
1
,
0
3
,
2
,
1
,
0
0 =
=
=
∂
∂
i
c
i
c
I
i
i
٩٩
100. Eigen Value Problems
(Homogeneous BVP)
Consider the problem:
( ) ( ) 0
1
0
2
=
=
−
=
′
′
y
y
y
y λ
To find the nontrivial solution of the above system
( )
( )
{ }
,
2
,
1
,
2
,
1
0
sin
0
sin
0
1
sin
0
0
sin
cos
=
=
∴
=
=
⇒
=
⇒
=
⇒
=
=
⇒
=
+
=
k
k
k
k
B
y
x
B
y
y
x
B
x
A
y
k π
λ
π
λ
λ
λ
λ
λ
λ
B.C.
&
B.C.
&
١٠٠
101. The Eigen Values are
and are the Eigen functions.
Let us use finite difference method
2
2
2
π
λ k
k =
x
B
y k
k
k λ
sin
=
1
,
,
1
0
2
0
2
2
1
1
−
=
=
=
−
=
=
− −
+
n
i
y
y
y
h
y
y
y
n
i
i
i
i
λ
In matrix form, let t
h =
+
− 2
2
2 λ
=
− 0
0
1
1
1
1
1
1
1
1
n
y
y
t
t
t
O
O
١٠١
102. This homogeneous linear system has nontrivial
solution when
( ) 0
1
1
1
1
1
det =
=
t
t
t
A
O
O
Choosing n=2 then 2
1
=
h
and an approximation
to the analytical value
8
0 2
=
⇒
= λ
t
8696
.
9
2
2
1 =
= π
λ
١٠٢
103. Choosing n=4 then 4
1
=
h
=
+
=
=
=
−
=
⇒
=
6274
.
54
2
2
32
3726
.
9
2
2
0
1
0
1
1
0
1
2
3
2
2
2
1
λ
λ
λ
t
t
t
and
The analytical value of
8264
.
88
4784
.
39
8696
.
9
2
3
2
2
2
1
=
=
=
λ
λ
λ
١٠٣
104. Again for improvement there are two
methods
1) To increase n and have smaller h leading
to a higher degree polynomial equation
and hence more round off error.
2) To use extrapolation technique.
In this case
Improved ( ) ( )
( ) ( )
8301
.
9
3726
.
9
3
4
8
3
1
3
4
3
1 2
1
2
1
2
1
=
+
−
=
+
−
= λ
λ
λ accurate
more
accurate
less
١٠٤
105. Numerical Solution of PDE
(Finite difference method)
We are going to consider
1) Heat equation
2) Steady – State equation
3) Wave equation
١٠٥
106. Consider the heat equation in the form
( ) ( )
( ) ( )
( ) ( )
x
f
t
x
u
t
t
b
u
t
t
a
u
t
b
x
a
x
u
D
t
u
=
=
=
>
<
<
∂
∂
=
∂
∂
,
,
,
0
,
2
2
ψ
φ
To find u(x,t) using finite difference method.
1. Explicit method
As before let n
i
x
i
x
x
a
x i ,
,
1
,
0
, 0
0
=
∆
+
=
=
and
١٠٦
107. ( ) ij
j
i
j
u
t
x
u
j
t
j
t
t
t
=
=
∆
+
=
=
,
,
1
,
0
,
0 0
0
denote
The partial derivatives will be as,
( )
( )
( )
( ) )
difference
(central
)
difference
(forward
2
2
1
2
2
1
2
x
O
x
u
u
u
x
u
t
O
t
u
u
t
u
j
i
ij
ij
i
ij
ij
ij
ij
∆
+
∆
+
−
=
∂
∂
∆
+
∆
−
=
∂
∂
−
+
+
Finally, let
( )2
.
x
D
t
r
∆
∆
=
Upon substitution in the equation,
( ) ( )
( )
2
1
1
1 2 x
t
O
u
u
u
r
u
u j
i
ij
j
i
ij
ij ∆
+
∆
+
+
−
=
− −
+
+
١٠٧
109. In the whole problem
ij
u
a b
x
t
Problem: show that when the local
truncation error will reduce to
The restriction on r causes higher number of
operations which leads to higher round off error.
Hence we move to implicit procedures.
6
1
=
r
( ) ( )
( )
4
2
x
t
O ∆
+
∆
١٠٩
110. 2.Implicit methods
Let us replace by a linear combination of
the known time step and the unknown (next)
time step as follows,
∂
∂
2
2
x
u
( )
1
0
1
1
2
2
2
2
≤
≤
∂
∂
−
+
∂
∂
=
∂
∂
+
θ
θ
θ
where
ij
ij
ij x
u
x
u
D
t
u
When θ=1 then we have the Explicit method.
When θ= then we have the Implicit Crank -
Nicolson method
2
1
١١٠
111. When θ=0 then we have the fully implicit method
(backward difference method)
Implicit Crank – Nicolson method
[ ]
1
1
1
1
1
1
1
1 2
2
2
+
+
+
+
−
+
−
+ +
−
+
+
−
=
− j
i
ij
j
i
j
i
ij
j
i
ij
ij u
u
u
u
u
u
r
u
u
The diagram of this method looks like
i-1j+1 ij+1 i+1j+1
i-1j ij i+1j
Rearrangement of the equation yields ١١١
112. ( )
( )
,
1
,
0
,
1
,
,
2
,
1
2
1
2
2
1
2
1
1
1
1
1
1
1
=
−
=
+
−
+
=
=
−
+
+
−
+
−
+
+
+
+
−
j
n
i
u
r
u
r
u
r
b
b
u
r
u
r
u
r
j
i
ij
j
i
ij
ij
j
i
ij
j
i
where
This system of (n-1) equation in (n-1) unknown must
be solved for each time step j . Therefore j can be
omitted at each time step, that is
For each j=0,1,…
( )
1
,
,
2
,
1
2
1
2
1
1
−
=
=
−
+
+
− +
−
n
i
b
u
r
u
r
u
r
i
i
i
i
١١٢
113. Taking into consideration the boundary conditions
then in matrix form,
+
+
=
+
−
−
+
−
−
+
−
− n
n
n u
r
b
b
u
r
b
u
u
r
r
r
r
r
r
r
O
O
2
2
1
2
2
1
2
2
1
1
2
0
1
1
1
١١٣
114. This system can be solved by SOR method,
For each j=0,1,…
( )
,
1
,
0
;
1
,
,
2
,
1
2
1
2
1
)
(
1
)
(
)
1
(
1
)
(
)
1
(
=
−
=
+
+
−
+
+
+
= +
+
−
+
k
n
i
u
r
u
r
u
r
b
r
u
u k
i
k
i
k
i
i
k
i
k
i
ω
k is the number of iterations
In this special case is found to be
.
opt
ω
n
r
r
b
π
µ
µ
ω cos
1
,
1
1
2
2 +
=
−
+
=
١١٤
115. Example
Given
( )
( )
( )
( )
<
<
−
<
<
=
>
=
=
>
=
>
<
<
∂
∂
=
∂
∂
20
10
20
10
0
0
,
0
100
,
20
16
.
0
,
0
0
,
0
0
,
20
0
2
2
x
x
x
x
x
u
t
t
u
D
t
t
u
t
x
x
u
D
t
u
Find at x=4,8,12,16
and at x=2,4,…,18
( )
∞
,
x
u
١١٥
116. As you know
Take r=1 and then and for
each j
( )2
16
.
0
x
t
r
∆
∆
=
4
=
∆x 100
=
∆t
0
0
4
6
6
4
2
5
.
0
0
0
5
.
0
2
5
.
0
0
0
5
.
0
2
5
.
0
0
0
5
.
0
2
5
0
4
3
2
1
=
=
=
−
−
−
−
−
−
u
u
u
u
u
u
&
that
note
١١٦
119. Elliptic Problems
Consider the Poisson equation
( ) ( )
( ) ( )
m
j
n
i
jk
c
y
ih
a
x
y
x
g
y
x
u
d
y
c
b
x
a
y
x
f
y
u
x
u
y
x
u
j
i
,
,
1
,
0
,
,
1
,
0
,
,
,
,
, 2
2
2
2
2
=
=
+
=
=
=
=
<
<
<
<
=
∂
∂
+
∂
∂
=
∇
and
for
and
let
boundaries
the
on
with
on
١١٩
120. a
x =
0 1
x 2
x 3
x 4
x n
x
b =
c
y =
0
1
y
2
y
d
ym =
y
x
١٢٠
121. Let us use the central differential formula for both
derivatives, then
( ) ( ) ( )
1
,
,
1
;
1
,
,
1
2
2
2
2
2
2
2
1
1
2
1
1
2
2
1
1
2
1
1
−
=
−
=
=
+
−
+
+
+
=
+
−
+
+
−
+
−
+
−
+
−
+
−
m
j
n
i
f
k
h
u
k
h
u
u
h
u
u
k
f
k
u
u
u
h
u
u
u
ij
ij
ij
ij
j
i
j
i
ij
ij
ij
ij
j
i
ij
j
i
or
The diagram looks like
١٢١
123. This linear system of (n-1)(m-1) equations and
unknowns can be solved by Gauss – Seidel
method or by SOR method with
+
=
−
+
=
m
n
c
c
b
π
π
ω
cos
cos
2
1
1
1
2
2
where
١٢٣
124. Example:
Find , given the Poisson equation
( )
j
i y
x
u ,
8
0
,
6
0
2
2
2
2
2
<
<
<
<
−
=
∂
∂
+
∂
∂
y
x
y
u
x
u
u=0 on the boundaries.
Take a) h=k=2
b) h=k=1
For the case a) there are
6 unknowns ij
u
i=1,2 ; j=1,2,3
21
11
22
21
23
31
u
u
u
u
u
u
8
6 x
y
١٢٤
125. [ ]
3
,
2
,
1
,
2
,
1
8
4
1
1
1
1
1
=
=
+
+
+
+
= +
−
+
−
j
i
u
u
u
u
u ij
ij
j
i
j
i
ij
Using the symmetric property (in this particular
problem) we have
56
.
4
56
.
4
72
.
5
72
.
5
56
.
4
56
.
4
23
13
22
12
21
11
=
=
=
=
=
=
u
u
u
u
u
u
For the case b) there are 35 linear equations in
35 unknowns 7
,
,
1
;
5
,
,
1
?
=
=
= j
i
uij
١٢٥
126. Using the symmetric property the system will be
reduced to 12 equations in 12 unknowns.
x x x
x x x
x x x
x x x
8
6 x
y
١٢٦
127. Preparing the system to be solved by SOR it looks
like
[ ]
=
=
=
−
+
+
+
+
+
= +
+
−
+
+
−
+
b
k
ij
k
ij
k
ij
k
j
i
k
j
i
b
k
ij
k
ij
j
i
u
u
u
u
u
u
u
ω
ω
7
,
,
1
5
,
,
1
4
8
4
)
(
)
(
1
)
1
(
1
)
(
1
)
1
(
1
)
(
)
1
(
The results are as follows
647
.
6
960
.
5
181
.
3
335
.
6
686
.
5
657
.
3
319
.
5
794
.
4
123
.
3
353
.
3
047
.
3
042
.
2
١٢٧
131. Given a set of data
To construct a cubic spline which fits the data.
To find
.
,
,
,
)
,
( n
1
0
i
y
x i
i
=
)
(
)
(
)
( i
i
i
2
i
i
3
i
i d
x
x
c
x
x
b
x
x
a
y +
−
+
−
+
−
=
,
,
, i
i
i
i d
c
b
a
for each subinterval [ ]
1
i
i x
x +
+
We should find
for .
,
,
, 1
n
1
0
i −
=
١٣١
132. Choosing the second derivatives at the data
Points as auxiliary unknowns.
i
s
writing for
in terms of .
1
n
1
0
i −
= ,
,
,
i
s
i
i
i
i d
c
b
a ,
,
,
In
.
)
(
)
(
)
( i
i
i
2
i
i
3
i
i d
x
x
c
x
x
b
x
x
a
y +
−
+
−
+
−
=
Let then
i
x
x =
.
i
i d
f = 1
١٣٢
133. Let then
1
i
x
x +
=
.
i
i
i
2
i
i
3
i
i
1
i f
h
c
h
b
h
a
f +
+
+
=
+
where .
i
1
i
i x
x
h −
= +
Denote
.
)
( i
i
i b
2
x
x
a
6
y
s +
−
=
′
′
=
2
Then at i
x
x =
2
s
b
b
2
s i
i
i
i =
⇒
= 3
١٣٣
134. .
)
( i
i
1
i
i
i
i
i
1
i h
6
s
s
a
s
h
a
6
s −
=
⇒
+
= +
+
and at 1
i
x
x +
=
4
6
s
h
s
h
2
h
f
f
c 1
i
i
i
i
i
i
1
i
i
+
+ +
−
−
=
Replace and in we get
i
a i
b 2
Now to calculate all ‘s we use the continuity
Of the slope at that is
i
s
i
x
١٣٤
135. i
x
right
y
left
y )
(
)
( ′
=
′ at
For the interval
[ ] .
)
(
)
(
:
, i
i
i
2
i
i
1
i
i c
x
x
b
2
x
x
a
3
y
x
x +
−
+
−
=
′
+
For the interval
[ ] 1
i
1
i
1
i
2
1
i
1
i
i
1
i c
x
x
b
2
x
x
a
3
y
x
x −
−
−
−
−
− +
−
+
−
=
′ )
(
)
(
:
,
Let in both left and right slopes yields:
i
x
x =
.
١٣٥
136. Upon substitution of ‘s and rearrangements,
we‘ll have
i
s
i
1
i
1
i
1
i
2
1
i
1
i c
c
h
b
2
h
a
3 =
+
+ −
−
−
−
−
Here
and the unknowns are
)
(
,
, equations
1
n
1
n
1
i −
−
=
).
(
,
,
, unknowns
1
n
s
s
s n
1
0 +
−
−
−
=
+
+
+
−
−
+
+
−
−
−
1
i
1
i
i
i
i
1
i
1
i
i
i
i
1
i
1
i
1
i
h
f
f
h
f
f
6
s
h
s
h
2
h
2
s
h )
(
١٣٦
137. For the extra two unknowns we consider the end
Point conditions.
1.Take and
This condition is called Natural Spline or Free Spline
0
s0 = 0
sn =
−
−
=
+ A
h
f
f
6
s
h
s
h
2
0
0
1
1
0
0
0
2. If and are given then
A
x
f 0 =
′ )
( B
x
f n =
′ )
(
١٣٧