Interactive Educational Modules in
Scientific Computing

Galerkin Method for Boundary Value Problems

This module illustrates the Galerkin 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 Galerkin method approximates the solution to the BVP by a linear combination of basis functions determined by requiring that the residual be orthogonal to each of the homogeneous basis functions, i.e., those that vanish on the boundary, and that the boundary conditions be satisfied. Let φ1,…,φn be a set of basis functions. We will approximate the solution to the boundary value problem by a linear combination v(t, x) = x1 φ1(t) + · · · + xn φn(t) of the basis functions, where the vector x of coefficents is to be determined. The coefficients of the homogeneous basis functions (i.e., φi(a) = φi(b) = 0) are determined by an orthogonality condition, while the coefficients of the inhomogeneous basis functions are chosen to satisfy the boundary conditions. The orthogonality condition requires that for each homogeneous basis function φi,

Integrating the left side by parts and using homogeneity, we can replace v″(t, x) φi(t)  by  v′(t, x) φi′(t), which lowers the differentiability requirements on the basis functions. The result is a system of equations that can be solved for the coefficients x of the approximate solution v(t, x). This system of equations will be nonlinear if the function f is nonlinear. The necessary integrals can be evaluated by numerical quadrature, and the accuracy of the solution will be affected by the accuracy of this numerical integration.

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 chooses a type and number of basis functions to be used. The available bases are piecewise polynomials with equally spaced breakpoints in the interval [a, b]. The user also chooses a quadrature method for evaluating the integrals. After the parameters for the Galerkin method have been specified, the user clicks Initialize to begin the process of solving the BVP. A predetermined starting guess x0 is used to initialize Broyden's method for solving the system of equations, and the corresponding approximate solution to the BVP, v(t, x0), is drawn in blue. The user then clicks Iterate repeatedly to execute successive iterations of Broyden's method to solve the system of equations. For each iterate xk, the corresponding approximate solution v(t, xk) is added to the graph, and the Euclidean norm of the residual of the system of equations is printed. The approximate solution curves are color coded according to their residuals, so as the approximate solutions converge their colors change from blue to red.

To compare approximate solutions obtained using different basis functions, numbers of elements, or quadrature rules, see the alternative Galerkin Method module.

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

Developers: Evan VanderZee and Michael Heath