Elliptic PDE · Iterative solver

Laplace
Equation

∇²u = 0  ·  u(x,y) on boundary fixed

The Laplace equation describes steady-state heat, electrostatics, and fluid potential. The Gauss–Seidel method turns the PDE into a local average — each interior point becomes the mean of its four neighbours.

Heat diffusion Electrostatics Potential flow Image processing
Gauss–Seidel update
ui,j = ui+1,j + ui-1,j + ui,j+1 + ui,j-1 4
Sweep left→right, bottom→top  ·  use newest values immediately
⬆ top = 1 ⬇ bottom = 0 ⬅ left = 0 ➡ right = 0
Algorithm · Gauss–Seidel

How it works

Discrete Laplace equation
∇²u = 0 ui+1,j − 2ui,j + ui-1,jhx² + ui,j+1 − 2ui,j + ui,j-1hy² = 0
With uniform grid (hx = hy), the update is simply the average of four neighbours.
ui,j = ui+1,j + ui-1,j + ui,j+1 + ui,j-14
Convergence check
Stop when max(|uk+1 − uk|) < ε
Typical ε = 1e-6  ·  converges in ~1800 iterations for 50×50 grid

Set up the domain

Define [xmin,xmax]×[ymin,ymax] and fix boundary values.

Discretise

Create a grid with nx × ny points. Initialise interior to 0 (or any guess).

Gauss–Seidel sweep

Loop over every interior point, update using the newest neighbour values (in-place).

Check convergence

After each full sweep, compute the maximum change. If below tolerance, stop.

Visualise

Plot the solution as a contour or 3D surface — smooth harmonic function.

Interactive solver

Run Gauss–Seidel

contour (heatmap) 3D surface
Ready
laplace_gs.py python