Unit 1
Unit 1
Unit 1
Abstract
Finite difference method is very popular and important tool to solve the boundary value
problems. Those problems consist ordinary differential equation (ODE) and complicated
boundary conditions that appears in many areas of science and engineering. In this chapter three
types of boundary conditions like Dirichlet Boundary condition, Neumann boundary condition
and mixed boundary condition are discussed. Type of error, stability, convergence and truncation
error are also explained. 2nd and 4th order ordinary differential equations are solved by finite
difference scheme. Some numerical results are compared with analytical results and error is
calculated at each point.
Introduction
Many problems in science and engineering can be reduced to the problem of solving differential
equations satisfying certain given condition. The analytical methods of solution can be applied to
solve only a selected class of differential equations. Those problem consists differential equation
and complicated conditions which govern physical systems do not possess, in general closed
form solution, and hence recourse muse be made to numerical methods for solving such
differential equations.
Finite difference method is a very useful numerical tool to solve the boundary value problem.
Before we start off this chapter we have to know about the boundary value problem. When we
studied IVP s (Initial Value problem) we saw that a differential equation and the initial value of a
function (initial condition) were given. Now we consider the boundary value problem.
In this unit we begin by discussing various types of boundary conditions that can be imposed. A
BVP which only has one independent variable is an ODE but we consider BVP in dimensions we
need to use PDE.
Throughout this chapter we consider the linear second order ODE given by
Corresponding to ODE (1.1), there are three important boundary conditions. They are given by
If the values of the function are specified on the boundary in a BVP, this type of constraint is
called Dirichlet boundary condition.
For example, (𝑎) = 𝛼 , 𝑦(𝑏) = 𝛽 in domain [a, b], where α and β are constant.
If the derivatives of the unknown function are specified on the boundary in a BVP, this type of
constraint is called Neumann boundary condition.
For example, y′(a) = 𝘢, y′(𝑏) = 𝛽 in domain [a, b], where α and β are constant.
Mixed (Robin) Boundary Condition
If a weighted combination at the function value and its derivative at the boundary is called Robin
boundary condition or mixed boundary condition.
The finite difference method for the solution of a BVP consists in replacing the derivatives
occurring in the differential equation and in the boundary conditions. Their finite difference
approximations and then solving the resulting linear system of equations are solved by a standard
procedure.
A centre difference approximation for 𝑦′(𝑥) can be obtained by subtracting Eq.1.4 from Eq.1.2
𝑦(𝑥+ℎ)−𝑦(𝑥−ℎ)
𝑦′(𝑥) = + 𝑂(ℎ2) 1.6
2ℎ
It is clear that Eq.1.6 is a better approximation to 𝑦′(𝑥) than either Eq.1.3 or Eq.1.5.
𝑦(𝑥−ℎ)−2𝑦(𝑥)+𝑦(𝑥+ℎ)
𝑦′′(𝑥) = + 𝑂(ℎ2) 1.7
ℎ2
To solve the BVP defined by (1.1), we divide the range [x0, xn] into n equal subintervals of width
h so that
𝑥i = 𝑥0 + iℎ, i = 1, 2, 3,.......... 𝑛.
From Eqs. 1.6 & 1.7, values of 𝑦′(𝑥) and 𝑦′′(𝑥) at the point 𝑥 = 𝑥i can be written as
𝑦i+1−𝑦i−1 + 𝑂 (ℎ2)
𝑦i′ =
2ℎ
𝑦i−1−2𝑦i+ 𝑦i+1
ℎ2
+ fi 𝑦i+1−𝑦i−1
2ℎ
+ 𝑔i𝑦i = 𝑟i , i = 1, 2, …..n
Where 𝑦i = (𝑥 i) , 𝑔i = 𝑔(𝑥 i)
Error Analysis
Error Calculation
We first find exact solution. Solve the given differential equation, that means, find C.F
(Complementary function) and P.I. (Particular Integral). Then
Type of Errors
Numerical Stability
A numerical scheme is said to be stable if the difference between the numerical solution and the
exact solution remains bounded as the number of steps tends to infinity.
Numerical Convergence
For any iterative numerical technique, each successive iteration results in a solution that moves
progressively closer to the true solution. This is known as convergence. A numerical method is
not always guaranteed to produce converging results. Convergence is subject to satisfying certain
conditions. If these conditions are not met, each successive iteration produces a result that
progressively moves away from the true solution. This is known as divergence.
Numerical Consistency
Truncation error is the error made by truncating an infinite sum and approximating it by a finite
sum. For instance, if we approximate the sine function by the first two nonzero term of its
Taylor’s series, as in 𝑠i𝑛 (𝑥) ≈ 𝑥 − 1 𝑥3 for small 𝑥, the resulting error is truncation error.
6
To estimate the error in numerical solution, we define the local truncation error, 𝑟, by
𝑦i−1−2𝑦i+𝑦i+1 𝑦i+1−𝑦i−1
𝑟=( − 𝑦i′′) + fi ( − 𝑦′i)
ℎ2 2ℎ
2 3 4
𝑦 = 𝑦 + ℎ𝑦′ + ℎ 𝑦′′ + ℎ 𝑦′′′ + ℎ 𝑦i𝑣 + ............................ (since 𝑥 = 𝑥 + ℎ)
i+1 i i 2! i 3! i 4! i i+1 i
1 2
ℎ2𝑦𝘍𝘍+ ℎ4𝑦 i𝑣+ … 2ℎ𝑦𝘍+ ℎ3𝑦𝘍𝘍𝘍
𝑟= ( i 12 i − 𝑦′′) + fi ( i 3! i − 𝑦′)
ℎ2 i 2ℎ i
2
𝑟 = (𝑦′′ + 1 ℎ2𝑦i𝑣 + … … … … − 𝑦′′) + f (𝑦′ + ℎ 𝑦′′′ + … … … … … − 𝑦′)
i 12 i i i i 6 i i
2
𝑟= ℎ (𝑦i𝑣 + 2f 𝑦′′′) + (ℎ4)
12 i i i
It follows that 𝑟 → 0 as ℎ → 0 , implying that better accuracy in the result can be achieved by
using a smaller value of h. In such a case, of course, more computational effort would be
required since number of equations become larger.
We have explained the method with three types of boundary conditions. In many applied
problems, derivative boundary conditions may be prescribed, and this requires a modification of
the procedures described above. The following examples illustrate the application of finite-
difference method.
So 𝑥0 = 0, 𝑥1 = 𝑥0 + ℎ = 0.5 = 1/2, 𝑥2 = 𝑥0 + 2ℎ = 1
𝑦i−1−2𝑦i+ 𝑦i+1
ℎ2
+ 𝑦i + 1 = 0 1.8
𝑦1 = (0.5) = 1 = 0.142854.
7
𝑦′′ + 𝑦 + 1 = 0
(𝐷2 + 1)𝑦 = −1
A.E. 𝑚2 + 1 = 0 or, 𝑚 = ±i
C. F. 𝑦𝑐 = 𝐶1 cos 𝑥 + 𝐶2 sin 𝑥
P.I = 1
(−1) = −1
𝐷 2+1
𝐶1 = 1
𝐶2 = 0.5463 .
(0.5) = 0.139493
𝑥4 = 𝑥0 + 4ℎ = 1.
𝑦0 − 31 𝑦1 + 𝑦2 = − 1
16 16
𝑦1 − 31 𝑦2 + 𝑦3 = − 1
16 16
𝑦2 − 31 𝑦3 + 𝑦4 = − 1
16 16
− 31 𝑦1 + 𝑦2 = − 1
16 16
𝑦1 − 31 𝑦2 + 𝑦3 = − 1
16 16
31 1
𝑦2 − 𝑦3 = −
16 16
𝑦1 = (0.25) = 0.10476
𝑦2 = (0.5) = 0.14031
𝑦3 = (0.75) = 0.10476
Using Eq.1.11, Exact Solutions at each point are
𝑦1 = (0.25) = 0.1041
𝑦2 = (0.5) = 0.1395
𝑦3 = (0.75) = 0.1041
Since the ratio of two errors is about 4, it follows that the order of convergence is ℎ2.
These results show that the accuracy obtained by the finite difference method depends upon the
width of the subinterval chosen and also on the order of approximations. As ℎ is reduced, the
accuracy increases but the number of equation to be solved also increases.
𝑦i−1−2𝑦i+ 𝑦i+1
− 𝑦i = 0 1.13
ℎ2
We subdivided the interval [0, 2] into four equal parts since ℎ = 0.5. Let the values of 𝑦 at the
five points be 𝑦0, 𝑦1, 𝑦2, 𝑦3, 𝑦4. We have 𝑥0 = 0, 𝑥1 = 𝑥0 + ℎ = 0.5 = 1/2, 𝑥2 = 𝑥0 + 2ℎ = 1
𝑥3 = 𝑥0 + 3ℎ = 1.5, 𝑥4 = 𝑥0 + 4ℎ = 2.
4(𝑦0 − 2 𝑦1 + 𝑦2) = 𝑦1
4(𝑦1 − 2 𝑦2 + 𝑦3) = 𝑦2
4(𝑦2 − 2 𝑦3 + 𝑦4) = 𝑦3
-9𝑦1 + 4𝑦2 = 0
𝑦1 = (0.5) = 0.52635
𝑦2 = (1) = 1.18428
𝑦3 = (1.5) = 2.13829
𝑦1 = (0.5) = 0.5211
𝑦2 = (1) = 1.18428
𝑦3 = (1.5) = 2.13829
Therefore, ℎ = 1.
3
To solve the equation 𝑦′′ + (1 − 𝑥 i)′ + 𝑥i𝑦i = 𝑥 i use finite difference approximation
i i
𝑦′(0) = 0
𝑦0′ = 0
𝑦1−𝑦−1
=0
2ℎ
𝑦1 = 𝑦−1
(1) = 0
𝑦3 = 0
5𝑦 − 4𝑦0 + 3𝑦1 = 0
−1
3
104 2
17𝑦1 − 𝑦2 =
3 3
Solving above three equations, we get the numerical approximations
𝑦0 = −8.342 ,
𝑦1 = −7.15
𝑦2 = −3.986
Therefore, ℎ = 1.
3
𝑦i−1−2𝑦i+ 𝑦i+1
ℎ2
= 𝑥i𝑦i
𝑦−1 − 2𝑦0 + 𝑦1 = 0 (∴ 𝑥0 = 0)
𝑦0 − 55 𝑦1 + 𝑦2 = 0 ( ∴ 𝑥1 = 1) 1.18
27 3
𝑦1 − 56 𝑦2 + 𝑦3 = 0 ( ∴ 𝑥2 = 2)
27 3
(0) + 𝑦′(0) = 1
𝑦0 + 𝑦0′ = 1
𝑦0 + 𝑦1−𝑦−1 = 1 (use centre difference approximation)
2ℎ
(1) = 𝑦3 = 1
Using B.C.S, Eqs. 1.18 become the system of linear equations given by
−2𝑦0 + 3𝑦1 = 1
𝑦0 − 55 𝑦1 + 𝑦2 = 0
27
𝑦1 − 56 𝑦 2 = −1
27
𝑦0 = (0) = −0.9879
𝑦1 = (1/3) = −0.3253
𝑦2 = (2/3) = 0.3253
From the Taylor series 1.2 and 1.4 we get the finite difference approximation for 4th order
derivative.
Therefore, ℎ = 0.25
95 1
𝑦i−2 − 4𝑦i−1 + 𝑦i − 4𝑦i+1 + 𝑦i+2 = 𝑥i 1.16
16 256
Using B.C.S
𝑦0 = (0) = 0 1.17
𝑦 ′′ (0) = 𝑦 ′′ = *𝑦i−1−2𝑦i+𝑦i+1 + =0
0 ℎ2 i=0
𝑦−1 − 2𝑦0 + 𝑦1 = 0
𝑦−1 = −𝑦1 1.18
(1) = 𝑦4 = 0 1.19
𝑦 ′ (1) = 𝑦 ′ = *𝑦i+1−𝑦i−1 + =0
4 2ℎ i=4
𝑦5 = 𝑦3 1.20
Putting i = 1, 2, 3 in Eq. 1.16, using conditions 1.17, 1.18, 1.19, 1.20, we get
79 𝑦 − 4𝑦2 + 𝑦3 = 1
1
16 1024
−4𝑦1 + 95 𝑦2 − 4𝑦3 = 1
16 512
111 3
𝑦1 − 4𝑦2 + 𝑦3 =
16 1024
Exercise Problems
2
The boundary value problem is 𝑑 𝑦 = 𝑒𝑥2 with (0) = 0 and (1) = 0 . Estimate the
𝑑𝑥 2
Taking ℎ = 0.5. Exact solution of this problem is = 𝑠i𝑛ℎ . Also calculate error at each
point.
Solve the boundary value problem 𝑦′′ + (1 − 𝑥)𝑦′ + 𝑥𝑦 = 𝑥 with 𝑦(0) = 0 and 𝑦 (1) =
0. Taking ℎ = 0.25.
Solve the boundary value problem 𝑦′′ − 14 𝑦′ + 𝑥3𝑦 = 2𝑥 with 𝑦(0) + 𝑦′(0) = 0 and
𝑥
Solve the boundary value problem (1 + 𝑥2)𝑦′′ − 𝑦 = 1 with 𝑦′(0) = 0 and 𝑦(1) = 0,
using finite difference method. Taking ℎ = 1/3.
Solve the boundary value problem 𝑢′′ = 𝑥𝑢 with (0) + 𝑢′(0) = 1 and 𝑢(1) = 1, using
finite difference method. Taking ℎ = 1/3.
Solve the boundary value problem defined by
𝑦′𝑣 = 𝑥, 0 ≤ 𝑥 ≤ 1, for (𝑥i), 𝑥i = 0.25, 0.5, 0.75, given that 𝑦(0) = 0, 𝑦′′(0) = 0 and
(1) = 0, 𝑦′(1) = 0 using finite difference method.
Find the truncation error of the following differential equation
𝑦′′ + 2𝑥𝑦′ + 5𝑦 = 𝑥 3
Find the truncation error of the following differential equation
𝑦′′ + (1 − 𝑥)′ + 𝑦 = 5𝑥
Find the truncation error of the following differential equation
𝑦′′ + (1 − 𝑥 2) = 1
Answers:
Bibliography
Hildebrand, F. B., Introduction of Numerical Analysis, McGraw Hill, New York, 1956.
Jain M. K., Iyengar S. R. and Jain R. K., Numerical Methods for Scientific and Engineering
Computation, Wiley Eastern Limited, New Delhi, 1985.
Levy, H. and Baggott, E. A., Numerical Solution of Differential Equations, Dover, New York,
1950.
Sastry, S. S., Engineering Mathematics, 3rd eds., Vols., 1 and 2, Prentice-Hall of India, New
Delhi, 2004.
Sastry, S. S., Introductory Methods of Numerical Analysis, PHI, Fifth Edition, New Delhi, 2012.
Scheid, Francis, Theory and Problems of Numerical Analysis, Schaum Series, McGraw Hill,
New York, 1968.