The Poisson equation arises in electrostatics, gravitation, and many areas of physics and engineering. It describes how a source distribution generates a potential field . On a two-dimensional unit square with zero boundary conditions, the equation becomes
Even for simple sources, closed-form solutions may be cumbersome. Iterative methods provide a practical way to approximate . This calculator uses the Gauss–Seidel approach to relax the grid repeatedly until changes become small.
We divide the unit square into intervals in each direction, giving grid spacing . Interior grid points are indexed by and . The discrete Poisson equation with Dirichlet boundary conditions reads
Starting with zero everywhere, we repeatedly update each interior point according to this formula. The boundary remains fixed at zero. After enough iterations, the grid converges toward the true solution.
The Gauss–Seidel method updates points sequentially and uses the newest available values immediately. This tends to converge faster than the Jacobi method, which updates all points simultaneously from the previous step. The convergence rate depends on the grid spacing and the spectral properties of the discrete Laplacian. For smooth sources, doubling roughly quadruples the number of iterations needed for similar accuracy, illustrating the cost of finer grids.
One way to gauge convergence is to monitor the residual: the difference between the left-hand side and right-hand side of the discrete equation. As iterations proceed, the residual diminishes, indicating that the current grid closely satisfies the Poisson equation.
In electrostatics, might represent an electric potential generated by a charge density . In heat conduction, it describes the steady-state temperature distribution given an internal heat source. Gravitational potential, membrane deflection, and even image processing tasks rely on similar equations. Developing numerical intuition via a simple solver provides a gateway to more advanced simulation techniques.
While our calculator enforces zero boundary conditions for simplicity, real-world problems may have arbitrary boundaries or Neumann conditions on flux. Finite element methods and multigrid algorithms extend the same ideas to complex domains and improve efficiency dramatically.
This solver is intentionally straightforward. It uses a fixed number of iterations rather than a sophisticated convergence criterion, and it performs all computations in JavaScript, which may be slow for large grids. Nevertheless, it demonstrates the essence of solving elliptic partial differential equations numerically. Extending the code to support graphical output or more advanced acceleration would be a valuable exercise.
Compute pressure differences and velocities in a flowing fluid using Bernoulli's principle. Explore energy conservation in liquids and gases.
Use Avogadro's constant to convert between moles, molecules, and mass for any substance.
Solve the one-dimensional wave equation with fixed ends using a finite difference method.