Laplace Equation Solver

Formula and introduction to the 2D Laplace equation on a rectangular grid

Laplace's equation on a rectangular grid describes a steady-state field whose value changes smoothly from one boundary to another without internal sources or sinks. In physical language, that could mean electric potential in a charge-free region, temperature after a plate has fully settled, or a velocity potential in an idealized incompressible flow. The calculator on this page takes fixed numbers along the edge of a grid and computes the interior values that best match that quiet, source-free balance.

The continuous equation is commonly written as โˆ‡2u=0. For a two-dimensional function of x and y, that becomes โˆ‚2uโˆ‚x2+โˆ‚2uโˆ‚y2=0. The meaning is simple once you step away from the notation: curvature in one direction is balanced by curvature in the other. A harmonic function bends just enough in opposite directions to remain in equilibrium.

On a uniform mesh, the browser solver replaces derivatives with finite differences and uses the familiar five-point averaging rule ui,j=ui-1,j+ui+1,j+ui,j-1+ui,j+14. In words, each interior cell is updated to the average of the cell above, below, left, and right. That one idea is the heart of the calculator: keep averaging until the interior settles into a consistent harmonic pattern.

Iterative approach for Gauss-Seidel relaxation of Laplace's equation

This Laplace equation solver uses the Gauss-Seidel relaxation method, which updates interior values in place as it sweeps through the grid. That matters because the newest values become available immediately to later cells in the same pass, so information travels through the domain faster than it would in a pure Jacobi update that waits until the next full iteration to use new numbers.

The boundary values you type are treated as fixed Dirichlet conditions. The edge cells never change, while only the interior cells are recalculated. If your grid has size mร—n, the solver computes m-2 by n-2 unknown interior values. On a very small grid, the answer appears quickly. On a larger grid, the same method still works, but you usually need more iterations before the interior stops changing enough to look settled.

This particular implementation asks you for a fixed number of iterations instead of a convergence tolerance. That design keeps the calculator simple and predictable, but it also means accuracy depends on the number you choose. Too few iterations can leave the interior under-relaxed, especially for large grids or sharply changing boundaries. More iterations usually improve the approximation, although returns diminish once the grid is already close to equilibrium.

Practical significance of steady-state Laplace solutions

This Laplace grid solver is a small browser version of a calculation that appears throughout engineering and applied science. If your boundary values are voltages, the output is an approximate electric potential field inside the domain. If your boundary values are temperatures, the output is the steady temperature distribution in a thin plate after transient effects have died away. If your boundary values represent a potential function in fluid mechanics, the interior values describe an idealized smooth flow potential.

The numerical values keep the same units from input to output. That means volts go in and volts come out, degrees go in and degrees come out, and dimensionless normalized potentials stay dimensionless. The result is a scalar field, not a field of gradients or forces. If you later want electric field or heat flux information, you would estimate it from differences between neighboring output cells rather than from the raw potential values alone.

Historical context for Laplace's equation and relaxation methods

Laplace's equation takes its name from Pierre-Simon Laplace, whose work in mathematical physics helped formalize potential theory long before digital computers existed. The equation became central because the same mathematical structure appears in many different physical problems, from gravitation and electrostatics to heat flow and probability. That universality is one reason students encounter it early and professionals keep using it later.

Gauss-Seidel relaxation arrived much later as part of the broader development of numerical linear algebra. The method is not flashy, but it is enduring: it is easy to explain, easy to code, and powerful enough to solve many modest grid problems directly in a web page. Using a browser calculator like this one can make the transition from textbook PDE theory to actual computation feel concrete instead of abstract.

How to use the Laplace equation solver

This Laplace equation calculator expects a rectangular matrix of numbers in the Boundary Values box, with one row per line and spaces between entries. Every row must contain the same number of values, and the grid must be at least 3 by 3 so there is at least one interior point to update. The outermost cells are the fixed boundary. Interior cells may start at zero, guessed values, or any other numbers, because the solver will overwrite them during the relaxation passes.

When you choose boundary values, think about the physical story you want the grid to represent. Constant edges model a wall held at one temperature or a conductor fixed at one voltage. A left-to-right gradient can represent a plate with one side cold and the other warm. Mixed positive and negative values are allowed, which makes it easy to explore sign-changing potentials. The only strict requirement is that each boundary cell be a valid finite number and the overall layout remain rectangular.

A quick starter example is shown below. It places the entire boundary at 10 while the interior begins at 0:

10 10 10 10
10 0 0 10
10 0 0 10
10 10 10 10

This Laplace boundary setup converges toward 10 everywhere because the only harmonic function matching a constant boundary is the same constant throughout the domain. That makes it a useful first test: if the output stays near 10 after enough iterations, you know the grid format is correct and the averaging behavior makes sense. After that, you can move on to more interesting patterns with competing hot and cold or high and low edges.

The Iterations field controls how many Gauss-Seidel sweeps the solver performs. On coarse grids, 50 to 200 steps often show the trend clearly. On finer grids, several hundred or even a few thousand steps may be needed for a smoother answer. The output is printed in the same row-by-row format as the input so you can paste it into a spreadsheet, contour plotter, or a separate visualization tool. Because the result is text, it is also easy to compare two runs after changing one boundary or increasing the iteration count.

For best interpretation, compare successive runs rather than assuming one output is exact. If raising the iteration count from 100 to 500 barely changes the central values, the discrete solution is likely close to settled for that grid. If the values still move noticeably, keep iterating or refine the grid design. Also remember that this page solves Laplace's equation, not Poisson's equation, so there is no interior source term built into the model.

Worked example: a linear boundary that reproduces an exact harmonic grid

This worked example for the Laplace equation solver uses a boundary chosen so the expected answer is easy to recognize. Enter the following 5 by 5 grid and set the iteration count to 60 or more:

0 25 50 75 100
0 0 0 0 100
0 0 0 0 100
0 0 0 0 100
0 25 50 75 100

This Laplace boundary pattern fixes the left edge at 0, the right edge at 100, and the top and bottom edges on a straight linear ramp from 0 to 100. The harmonic function that matches those edges is simply a left-to-right linear increase, so the exact discrete solution on the grid is the same pattern repeated through the interior. After enough iterations, the output should approach:

0.0000 25.0000 50.0000 75.0000 100.0000
0.0000 25.0000 50.0000 75.0000 100.0000
0.0000 25.0000 50.0000 75.0000 100.0000
0.0000 25.0000 50.0000 75.0000 100.0000
0.0000 25.0000 50.0000 75.0000 100.0000

This Laplace example is useful because it demonstrates more than mere convergence. It shows that linear functions already satisfy the averaging rule exactly on a uniform grid, so the solver is not only smoothing numbers mechanically; it is approximating a genuine harmonic field. If your result is close but not exact after a small number of steps, simply increase the iteration count and watch the interior rows settle toward the same evenly spaced values.

Method comparison for solving the Laplace equation numerically

This method comparison places the calculator's Gauss-Seidel update beside other standard approaches for Laplace-type problems. The table is not a ranking for every situation, but it gives a good mental model for why this page uses Gauss-Seidel as a teaching tool: it is faster than Jacobi, simpler than more advanced accelerations, and efficient enough for modest browser-based grids.

Common iterative methods for rectangular Laplace grids
Method Convergence Speed Memory Use
Jacobi Slow High (needs two grids)
Gauss-Seidel Moderate Low
SOR Fast when optimized Low

Jacobi is often the easiest scheme to derive, but it stores separate old and new grids and can require many steps. Gauss-Seidel reuses fresh values immediately, which usually cuts the iteration count. Successive over-relaxation, or SOR, pushes the update further with a relaxation factor and can be much faster when that factor is well chosen, though a poor choice can overshoot and hurt convergence. For large professional simulations, methods such as multigrid are often preferred, but they are beyond the scope of a lightweight single-page calculator.

Limitations and assumptions of this fixed-iteration Laplace solver

This Laplace solver makes several deliberate simplifications so it can stay transparent and fast inside a browser. It assumes a uniform rectangular grid, fixed-value boundary conditions, and a source-free interior. In other words, it solves a discrete Dirichlet problem for Laplace's equation, not an irregular-domain problem, not a Neumann boundary problem, and not a general Poisson equation with interior forcing terms.

This Laplace implementation also stops after the number of iterations you request, without reporting a residual norm or maximum update size. That means the page does not automatically tell you whether the answer has converged to the precision you need. For casual exploration, fixed iterations are fine. For design work, research, or validation, you would usually monitor convergence explicitly, compare solutions across multiple grid sizes, and check sensitivity to boundary discretization.

This Laplace grid input treats corner cells exactly as typed, so corners deserve attention when two boundaries meet with different intended values. If you imagine one edge at 100 and the adjacent edge at 0, the shared corner cannot be both; you must decide what single corner value belongs in the matrix. The calculator will honor that choice literally. Finally, coarse grids can blur steep changes, so smoother-looking answers are not automatically more accurate unless the grid is also refined appropriately.

This Laplace equation page pairs well with other math tools when you want to move between discrete systems and algebraic structure. Explore the Matrix Square Root Calculator for linear algebra experiments and the Linear Diophantine Equation Solver for exact integer-based equation solving. Together, they offer a broader sense of how numerical approximation and exact symbolic reasoning complement one another.

Enter a rectangular grid with spaces between values and one row per line. Use at least a 3ร—3 grid. Each row must contain the same number of values.

Higher iteration counts usually produce a closer steady-state approximation, especially on larger grids.

Provide boundary data for a grid.
Status messages will appear here.

Arcade Mini-Game: Laplace Equation Solver Calibration Run

Use this quick arcade run to practice separating useful Laplace-grid inputs from planning mistakes before you rely on the calculator output.

Score: 0 Timer: 30s Best: 0

Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.

Embed this calculator

Copy and paste the HTML below to add the Laplace Equation Solver for 2D Grids | Gauss-Seidel Relaxation Method to your website.