0% found this document useful (0 votes)
93 views36 pages

Numerical Methods 15

The document discusses numerical methods for solving boundary value problems involving ordinary differential equations. It describes the finite difference method, which involves replacing derivatives in the differential equation and boundary conditions with finite difference approximations. This results in a system of linear equations that can be solved using standard methods. The document then derives the central difference approximations for the first four derivatives under Taylor's expansion, which provide more accurate approximations than forward or backward differences. It also gives an example of applying the method to solve a given boundary value problem, resulting in a tridiagonal system of equations.

Uploaded by

Aashish Singh
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)
93 views36 pages

Numerical Methods 15

The document discusses numerical methods for solving boundary value problems involving ordinary differential equations. It describes the finite difference method, which involves replacing derivatives in the differential equation and boundary conditions with finite difference approximations. This results in a system of linear equations that can be solved using standard methods. The document then derives the central difference approximations for the first four derivatives under Taylor's expansion, which provide more accurate approximations than forward or backward differences. It also gives an example of applying the method to solve a given boundary value problem, resulting in a tridiagonal system of equations.

Uploaded by

Aashish Singh
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/ 36

Numerical Methods

Prof. Shishir Gupta


Department of Mathematics & Computing
Indian Institute of Technology(Indian School of Mines)
Dhanbad

July 29, 2020

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Finite Difference Method for Boundary Value Problems
(ODE)

In this method, the derivatives appearing in the differential equation and the
boundary conditions are replaced by their finite-difference approximations
and the resulting linear system of equations are solved by any standard
procedure. These roots are the values of the required solution at the pivotal
points.
The finite difference approximations to the various derivatives are derived
under:

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
If y (x) and its derivatives are single-valued continous functions of x then by
Taylor’s expansion, we have,

h2 00 h3
y (x + h) = y (x) + hy 0 (x) + y (x) + y 000 (x) + .... (1)
2! 3!
and
h2 00 h3
y (x − h) = y (x) − hy 0 (x) + y (x) − y 000 (x) + .... (2)
2! 3!

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Eq. (1)gives,
1h i h
y 0 (x) = y (x + h) − y (x) − y 00 (x)
h 2
i.e.,
1h i
y 0 (x) =
y (x + h) − y (x) + o(h)
h
which is the forward difference approximation of y 0 (x) with an error of the
order h.

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
similarly Eq. (2) gives

1h i
y 0 (x) = y (x) − y (x − h) + o(h)
h
which is the backward difference approximations of y 0 (x) with an error of
the order h.

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
subtracting Eq. (2) from (1), we obtain,

1h i
y 0 (x) = y (x + h) − y (x − h) + o(h2 )
2h
which is the central difference approximation of y 0 (x) with an error of the
order h2 . Clearly this central difference approximation y 0 (x) is better than
forward or backward difference approximation and hence should be preferred.

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Adding Eq.(1) and Eq. (2), we get

1h i
y 00 (x) = y (x + h) − 2y (x) + y (x − h) + o(h2 )
h2
which is the central difference approximation of y 00 (x).
Similarly we can derive central difference approximation to higher deriva-
tives.

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Hence the working expression for the central difference approximation to the
first four derivatives of yi are as follows:
1
yi0 = (yi+1 − yi−1 )
2h
1
yi00 = (yi+1 − 2yi + yi−1 )
h2
1
yi000 = (yi+2 − 2yi+1 + 2yi−1 − yi−2 )
2h3
1
yiiv = (yi+2 − 4yi+1 + 6yi − 4yi−1 + yi−2 )
h4
−−−∗−−−∗−−−∗−−−

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Question 1. Obtain the tridiagonal system which will provide the solution
of (1 + x 2 )y 00 − 2xy 0 + x 2 y = x 2 at x=0.5, 1, 1.5, 2, 2.5, 3, 3.5 given that
y (0) = 5, y (4) = 2
Solution: By discretizing equation (1 + x 2 )y 00 − 2xy 0 + x 2 y = x 2 , we get

(1 + xi )2 yi00 − 2xi yi0 + xi2 yi = xi2 (3)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
1
yi00 = (yi+1 − 2yi + yi−1 (4)
h2
1
yi = (yi+1 − yi−1 )
2h
From Eqs. (3) & (4) we get,

(yi+1 − 2yi + yi−1 ) (yi+1 − yi−1 )


(1 + xi2 ) 2
− 2xi + xi2 yi = xi2
h 2h

(yi+1 − yi−1 )
4(1 + xi2 )(yi+1 − 2yi + yi−1 ) − 2xi 1
+ xi2 yi = xi2
2× 2

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
(4 + 4xi2 + 2xi )yi−1 + (−8 − 7xi2 )yi + (4 + 4xi2 − 2xi )yi+1 = xi2 (5)

Puting i=1 in equation (5), we get

(4 + 4x12 + 2x1 )y0 + (−8 − 7x12 )y1 + (4 + 4x12 − 2x1 )y2 = x12

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
∵ x1 = 0.5
⇒ 9.75y1 − 4y2 = 29.75 (6)
Puting i=2 in equation (5), we get

(4 + 4x22 + 2x2 )y1 + (−8 − 7x22 )y2 + (4 + 4x22 − 2x2 )y3 = x22
⇒ 10y1 − 15y2 + 6y3 = 1(∵ x2 = 1) (7)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Puting i=3 in equation (5), we get

(4 + 4x32 + 2x3 )y2 + (−8 − 7x32 )y3 + (4 + 4x32 − 2x3 )y4 = x32
⇒ 16y2 − 23.75y3 + 10y4 = 2.25 (∵ x3 = 1.5) (8)

Puting i=4 in equation (5), we get

(4 + 4x42 + 2x4 )y3 + (−8 − 7x42 )y4 + (4 + 4x42 − 2x4 )y5 = x42
⇒ −36y4 + 24y3 + 16y5 = 4 (∵ x4 = 2) (9)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Puting i=5 in equation (5), we get

(4 + 4x52 + 2x5 )y4 + (−8 − 7x52 )y5 + (4 + 4x52 − 2x5 )y6 = x52
⇒ 34y4 − 51.75y5 + 24y6 = 6.25 (∵ x5 = 2.5) (10)

Puting i=6 in equation (5), we get

(4 + 4x62 + 2x6 )y5 + (−8 − 7x62 )y6 + (4 + 4x62 − 2x6 )y7 = x62
⇒ 46y5 − 71y6 + 34y7 = 9 (∵ x6 = 3) (11)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Puting i=7 in equation (5), we get

(4 + 4x72 + 2x7 )y6 + (−8 − 7x72 )y7 + (4 + 4x72 − 2x7 )y8 = x72
⇒ 60y6 − 93.75y7 = −79.95 (∵ x7 = 3.5) (12)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
From equations (6)-(12)

9.75y1 − 4y2 = 29.75


10y1 − 15y2 + 6y3 = 1
16y2 − 23.75y3 + 10y4 = 2.25
−36y4 + 24y3 + 16y5 = 4
34y4 − 51.75y5 + 24y6 = 6.25
46y5 − 71y6 + 34y7 = 9
60y6 − 93.75y7 = −79.95

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
The above equations can be written into tridiagonal system of equations as:

9.75 −4
    
0 0 0 0 0 y1 29.75
 10 −15 6 0 0 0 0   y2   1 
   

 0
 16 −23.75 10 0 0 0   y3   2.25 
   
 0
 0 24 −36 16 0 0  y4  =  4 
   

 0
 0 0 34 −51.75 24 0   y5   6.25 
   
 0 0 0 0 46 −71 34  y6   9 
0 0 0 0 0 60 −93.75 y7 −79.95

−−−∗−−−∗−−−∗−−−

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Question 2. Solve xy 00 + xy 0 − 2y = 2(x + 1) given y(0)= 0; y 0 (1) = 0,
taking h = 31 .
Solution: By discretizing equation xy 00 + xy 0 − 2y = 2(x + 1), we get
xi yi00 + xi yi0 − 2yi = 2(xi + 1).
Replacing the derivative by central difference approximation, we get,

(yi−1 − 2yi + yi+1 ) (yi+1 − yi−1 )


xi 2
+ xi − 2yi = 2(xi + 1)
h 2h

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
1
Putting h = 3 and arranging the equation, we have,

15xi yi−1 − 4(9xi + 1)yi + 21xi yi+1 = 4(xi + 1) (13)

Now, given y(0)=0, ⇒ x0 = 0, y0 = 0,


y 0 (1) = 0, ⇒ y30 = 0 at x3 = 1,
Putting i=1, in Eq. (13), we have,

48y1 − 21y2 = −16 (14)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Putting i=2, in Eq. (13), we have,

15y1 − 42y2 + 21y3 = 10 (15)

Putting i=3, in Eq. (13), we have,

15y2 − 40y3 + 21y4 = 8 (16)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Now from boundary conditions, we have y 0 (1) = 0, y30 = 0
∵ We get
yi+1 + yi−1
yi0 =
2h
put i=3,
y4 − y2
y30 =
2 × 13
⇒ y4 − y2 = 0 ⇒ y4 = y2
From Eq.(16),

9y2 − 10y3 = 2 (17)

Solving (14), (15) & (17) we get,

y1 = −.84, y2 = −1.16, y3 = −1.24

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Question 3. Solve y 00 − 2xy 0 + 2y = 0 given y (0) + y 0 (0) = 5, y (1) = 0
and taking h = 21
Solution: By discretizing the given equation y 00 − 2xy 0 + 2y = 0 we get
yi00 − 2xi yi0 + 2yi = 0.
Replacing the derivatives by central difference approximation we have,
yi−1 − 2yi + yi+1 yi−1 + yi+1
2
− 2xi + 2yi = 0
h 2h

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
1
⇒ (4 + 2xi )yi−1 − 6yi + (4 − 2xi )yi+1 = 0 (∵ h = ) (18)
2
Put i=0, in Eq. (18)

2y1 − 3y0 + 2y−1 = 0 (19)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Put i=1, in Eq. (18)

5y0 − 6y1 = 0 (As y2 = 0) (20)

From boundary condition, we have

y (0) + y 0 (0) = 5 ⇒ y0 + y00 = 5 (21)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
We have yi0 = 2h
1
(yi+1 − yi−1 )
1 0
put i=0, h = 2 y0 = y1 − y−1
From Eq.(21)

y0 + y1 − y−1 = 5, ⇒ y−1 = y0 + y1 − 5 (22)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
∵ From Eq. (19), we have,

2y1 − 3y0 + 2y0 + 2y1 − 10 = 0 ⇒ 4y1 − y0 − 10 = 0 (23)

Solving Eq. (20) & (23), we get y0 = 4.28, y1 = 3.57

−−−∗−−−∗−−−∗−−−

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Question 4. Determine the value of y at the pivotal of the interval (0,1)if
y satisfies the boundary value problem. y iv + 81y = 81x 2 , y (0) = y (1) =
y 00 (0) = y 00 (1) = 0, take h=1/3.
Solution:

y iv + 81y = 81x 2 (24)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
1h i
2
yi+2 − 4y i+1 + 6yi − 4yi−1 + yi−2 + 81yi = 81xi
h4
1
for i=1, y3 − 4y2 + 7y1 − 4y0 + y−1 =
9
4
for i=2, y4 − 4y3 + 7y2 − 4y1 + y0 =
9
using y0 = 0, y3 = 0, the above equations becomes
1
−4y2 + 7y1 + y−1 = (25)
9
4
y4 + 7y2 − 4y1 = (26)
9

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
00
Given y 00 (0) = 0 ⇒ y = 0 & y 00 (1) = 0 ⇒ y300 = 0
Now
1h i
yi00 = y i+1 − 2yi + yi−1 (27)
h2
for i=0, h = 31 ⇒ y 00 0 = 9(y1 − 2y0 + y−1 ) ⇒ y−1 = −y1 and i=3 in
equation (27),

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
y300 = 9(y4 − 2y3 + y2 ) ⇒ y4 = −y2

Using Eq.(26) in Eq.(24), −4y2 + 6y1 = 1/9


Using Eq.(26) in Eq.(24),6y2 − 4y1 = 4/9
11 7
By solving we get y1 = 90 and y2 = 45 . ⇒ y ( 13 ) = 0.1222 & y ( 32 ) =
0.1556
−−−∗−−−∗−−−∗−−−

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
4
Question 5. The deflection of a beam is governed by the equation ddxy4 +
81y = φ(x) , where φ(x) is given by the table and the boundary condition
y (0) = y 0 (0) = y 00 (1) = y 000 (1) = 0. Evaluate the deflection at the pivotal
points of the beam using three sub-interval.
Solution:Here h = 31 and the pivotal points are x0 = 0, x1 = 1/8, x2 = 2/3
and x3 = 1. The corresponding y-values are y0 , y1 , y2 , y3 .
The given differential equation is approximated to
1
(yi+2 − 4yi+1 + 6yi − 4yi−1 + yi−2 ) + 81yi = φ(xi )
h4

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
at i=1,

y3 − 4y2 + 7y1 − 4y0 + y−1 = 1 (28)

at i=2,

y4 − 4y3 + 7y2 − 4y1 + y0 = 2 (29)

at i=3,

y5 − 4y4 + 7y3 − 4y2 + y1 = 3 (30)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
We have,

y0 = 0 (31)

Since
1
yi0 =
(yi+1 − yi−1 )
2h
1
∵ for i = 0, 0 = y00 = (y1 − y−1 )
2h
⇒ y−1 = y1 (32)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Since
1
yi00 = (yi+1 − 2yi + yi−1 )
h2
∵ for i=3, 0 = y300 = 1
(y
h2 4
− 2y3 + y2 ) i.e.,

y4 = 2y3 − y2 (33)

Also
1
yi000 = (yi+2 − 2yi+1 + 2yi−1 − yi−2 )
2h3
∵ for i = 3, 0 = y3000 = 1
(y
2h3 5
− 2y4 + 2y2 − y1 ) i.e.,

y5 = 2y4 − 2y2 + y1 (34)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
Using Eq. (31) and Eq.(32), the equation (28) reduces to

y3 − 4y2 + 8y1 = 1 (35)

Using Eq.(31) and Eq.(33), the equation (29) reduces to

−y3 + 3y2 − 2y1 = 1 (36)

Using Eq. (33) and Eq. (34), the equation (30) reduces to

3y3 − 4y2 + 2y1 = 3 (37)

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad
8 22 37
Now, solving Eq.(35), (36) and (37) y1 = 13 , y2 = 13 , y3 = 13

Hence, y (1/3) = 0.6154, y (2/3) = 1.6923, y (1) = 2.8462.

−−−∗−−−∗−−−∗−−−

Prof. Shishir Gupta Department of Mathematics & Computing Indian


Numerical
Institute
Methods
of Technology(Indian School of Mines) Dhanbad

You might also like