#!/usr/local/bin/php Interactive Educational Modules in Scientific Computing

Interactive Educational Modules in
Scientific Computing

Finite Difference Method for Boundary Value Problems

This module enables the user to compare different approximate solutions computed using the finite difference method for 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). When the user clicks Solve, the resulting approximate solution to the BVP is drawn on the graph. To compare this solution with other approximate solutions, the user can make additional choices of difference order and number of mesh points, then click Solve to add each new approximate solution to the graph. The solutions for different parameters are color coded so that the color changes from blue to red as the number of mesh points increases and from light to dark as the difference order increases. To clear all of the solutions from the graph, click Reset.

To illustrate the details of the individual steps of the finite difference method for a particular choice of parameters, 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