Poisson Equation Solver
Enter function and parameters.

The Poisson Equation

The Poisson equation 2u=f arises in electrostatics, gravitation, and many areas of physics and engineering. It describes how a source distribution f generates a potential field u. On a two-dimensional unit square with zero boundary conditions, the equation becomes

&partial;2u&partial;x2+&partial;2u&partial;y2=fx,y

Even for simple sources, closed-form solutions may be cumbersome. Iterative methods provide a practical way to approximate u. This calculator uses the Gauss–Seidel approach to relax the grid repeatedly until changes become small.

Discretization

We divide the unit square into n intervals in each direction, giving grid spacing h=1n. Interior grid points are indexed by i and j. The discrete Poisson equation with Dirichlet boundary conditions reads

ui,j = ui+1 + ui-1 + ui,j+1 + ui,j-1 - h2 fi,j 4

Starting with u 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.

Understanding the Algorithm

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 n 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.

Why Solve Poisson?

In electrostatics, u might represent an electric potential generated by a charge density f. 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.

Limitations

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.

Related Calculators

Bernoulli Equation Calculator - Fluid Flow Pressure and Velocity

Compute pressure differences and velocities in a flowing fluid using Bernoulli's principle. Explore energy conservation in liquids and gases.

Bernoulli equation calculator fluid dynamics pressure velocity relationship

Avogadro's Number Calculator - Convert Moles to Molecules

Use Avogadro's constant to convert between moles, molecules, and mass for any substance.

Avogadro's number calculator moles to molecules chemistry

Wave Equation Solver

Solve the one-dimensional wave equation with fixed ends using a finite difference method.

wave equation solver