Professional Documents
Culture Documents
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.
1 of 4
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:
Reference:
4 of 4