Interactive Educational Modules in
Scientific Computing

Finite Difference Method for Boundary Value Problems

This module illustrates the finite difference method for numerically solving boundary value problems for ordinary differential equations. A general boundary value problem (BVP) consists of an ordinary differential equation (ODE) with side conditions specified at more than one point. This module illustrates the solution of second-order scalar ODEs of the form u″ = f(t, u, u′) on an interval [a, b] with boundary conditions u(a) = α and u(b) = β. The finite difference method approximates the solution to the BVP by approximating the derivatives of the solution u at a set of mesh points within [a, b] using finite difference quotients, which transforms the BVP into a system of algebraic equations. Denote the fixed mesh points by ti, i = 0,…,n+1, where t0 = a, and tn+1 = b. Let yi denote the approximation to u(ti ), and let yi(1)( y) and yi(2)( y) denote finite difference approximations to u′(ti ) and u″(ti ), respectively, where y denotes the vector of approximate solution values at the mesh points, on which the finite difference approximations depend. The finite difference method seeks to find a y such that y0 = α, yn+1 = β, and yi(2)( y) = f(ti, yi, yi(1)( y)) for i = 1,…,n. The latter is a system of algebraic equations to be solved for y.

The user begins by selecting from the menu provided an ODE and a specific solution to be sought (if there is more than one). Boundary values u(a) = α and u(b) = β are indicated by black dots on the graph. Next the user specifies the order of the finite difference approximations and the number of mesh points (including boundary points). The mesh points are equally spaced, and the finite difference formulas used to approximate derivatives are centered (except near boundaries). The user clicks Initialize to begin the process of solving the BVP. A predetermined starting guess for the solution is drawn, represented as a piecewise linear function connecting the approximate solution values at the mesh points. The user clicks Iterate repeatedly to perform successive iterations of Broyden's Method to solve the system of algebraic equations. At each iteration, the piecewise linear representation of the next approximate solution is added to the graph, and the Euclidean norm of the residual is printed. The approximate solution curves are color coded according to their residuals, so as the solutions converge their colors change from blue to red.

To compare approximate solutions obtained using different method orders or different numbers of mesh points, see the alternative Finite Difference Method module.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 10.4.

Developers: Evan VanderZee and Michael Heath