Interactive Educational Modules in
Scientific Computing

Laplace Equation

This module illustrates the numerical solution of Laplace's equation using iterative methods to solve the linear system resulting from a finite difference discretization. Laplace's equation (also called the potential equation) in two space dimensions is the partial differential equation uxx + uyy = 0, where the solution u(x, y) is a function of the spatial variables x and y, and subscripts indicate partial differentiation with respect to the given independent variable. This module considers Laplace's equation on the unit square [0, 1] × [0, 1] with Dirichlet boundary conditions, meaning that the solution value is prescribed along each side of the square. The solution u to Laplace's equation can be visualized as a surface over the unit square, whose height at a given point (x, y) is the solution value u(x, y). In a finite difference approach, the unit square is discretized by an n × n mesh of points in its interior, along with corresponding points along the sides of the square, and the corresponding approximate solution can be plotted as a piecewise linear surface in three dimensions.

The user begins by selecting from the menu provided a set of boundary conditions, whose values are displayed below the menu. Next the user specifies the number of interior grid points n to be used in each dimension of a two-dimensional grid discretizing the unit square. Finally, the user chooses an iterative method to solve the resulting system of n2 finite difference equations, with one equation and one unknown for each interior grid point. The menu of iterative methods is roughly ordered from slowest to fastest convergence rate. For the SOR method, the user can specify the relaxation parameter ω. Any choice allowed for ω will eventually converge, but the optimal ω indicated gives the best asymptotic convergence rate for this particular finite difference system. Here the SOR method is implemented using the "red-black" ordering, in which the mesh points are colored as in a checkerboard, and on each iteration the solution components corresponding to the red points are updated before those corresponding to the black points.

The initial guess for the solution is taken to be zero at each interior grid point. At any stage of the iterative solution process, the current approximate solution is represented in three dimensions as a surface over the unit square, including both the approximate solution values at interior points and the prescribed boundary values at boundary points. An iteration is performed each time the user clicks Iterate, and the resulting new approximate solution surface is updated in the graph. The residual displayed provides a means of monitoring convergence to the solution of the linear system. At convergence, the accuracy of the discrete approximation to the continuous solution of Laplace's equation depends on the number of grid points, with the error being proportional to 1 ⁄ n2 for this particular finite difference scheme.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 11.3.1, especially Example 11.5, and Section 11.5.

Developers: Evan VanderZee and Michael Heath