You are on page 1of 4

Department of Electrical and Electronic Engineering

Bangladesh University of Engineering and Technology


EEE 424: Numerical Methods Laboratory
Experiment # 06: Solving Boundary Value Problems Using Finite
Difference Method (FDM)
Objective
The objective of this experiment is to practice the finite difference method for solving
two-point boundary value problems comprising of ordinary differential equations.
In two-point boundary value problems the auxiliary conditions associated with the
differential equation, called the boundary conditions, are specified at two different values
of x. This makes boundary value problems considerably more difficult to solve. In an
initial value problem, we were able to start at the point where the initial values were
given and march the solution forward as far as needed. This technique does not work for
boundary value problems, because there are not enough starting conditions available at
either end point to produce a unique solution.
One way to overcome the lack of starting conditions is to guess the missing values. The
resulting solution is very unlikely to satisfy boundary conditions at the other end, but by
inspecting the discrepancy we can estimate what changes to make to the initial conditions
before integrating again. This iterative procedure is known as the shooting method. The
name is derived from analogy with target shootingtake a shot and observe where it hits
the target, then correct the aim and shoot again. Another means of solving two-point
boundary value problem is the finite difference method, where the differential equations
are approximated by finite differences at evenly spaced mesh points. As a consequence, a
differential equation is transformed into set of simultaneous algebraic equations. The two
methods have a common problem: they give rise to nonlinear sets of equations if the
differential equation is not linear. All methods of solving nonlinear equations are iterative
procedures that can consume a lot of computational resources. Thus, solution of nonlinear
boundary value problems is not cheap. Another complication is that iterative methods
need reasonably good starting values in order to converge. Since there is no set formula
for determining these, an algorithm for solving nonlinear boundary value problems
requires intelligent input; it cannot be treated as a black box.

Theory
In the finite difference method, we divide the range of integration (a, b) into n1 equal
subintervals of length h each, as shown in Fig. 1. The values of the numerical solution at
the mesh points are denoted by yi, i = 1, 2 . . . , n; the two points outside (a, b) will be
explained shortly. We then make two approximations:
1. The derivatives of y in the differential equation are replaced by the finite
difference expressions. It is common practice to use the first central difference
approximations:
y y
y 2 yi + yi +1
yi = i +1 i 1 , yi = i 1
, etc.
h2
2h
2. The differential equation is enforced only at the mesh points.

As a result, the differential equations are replaced by n simultaneous algebraic equations,


the unknowns being yi, i = 1, 2, . . . . n. If the differential equation is nonlinear, the
algebraic equations will also be nonlinear and must be solved by the NewtonRaphson
method. Since the truncation error in a first central difference approximation is O(h2), the
finite difference method is not as accurate as the shooting methodrecall that the
RungeKutta method has a truncation error of O(h5). Therefore, the convergence
criterion in the NewtonRaphson method should not be too severe.

1 of 4

Fig. 1: Finite difference mesh.

Example:

2 of 4

Note that the coefficient matrix is tridiagonal, so that the equations can be solved
efficiently by the functions LUdec3 and LUsol3 given below. Recalling that these
functions store the diagonals of the coefficient matrix in vectors c, d and e, we arrive at
the sample program like:

3 of 4

Assignments:
(1) Develop an algorithm and write a program in MATLAB for solving a second
order boundary value problem using the finite difference method.
(2) Solve the following problems using your program:
## Solve the boundary value problem y = 3 y y , with y(0) = 0 and y(2) = 1, using the
finite difference method. Use n = 11.
Algorithm:

Derive the given interval into n subintervals.


At each point of x, obtain difference equation using a suitable difference formula.
This will result in (n-1) equations with (n-1) unknowns, y1, y2, ., yn-1.
Solve the system for yi using any of the standard methods.

Reference:

[1] J. Kiusallas, Numerical Methods in Engineering with MATLAB, Cambridge


University Press, 2005.

4 of 4

You might also like