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.
Define [xmin,xmax]×[ymin,ymax] and fix boundary values.
Create a grid with nx × ny points. Initialise interior to 0 (or any guess).
Loop over every interior point, update using the newest neighbour values (in-place).
After each full sweep, compute the maximum change. If below tolerance, stop.
Plot the solution as a contour or 3D surface — smooth harmonic function.