Advanced maths

Two dimensional Poisson equation calculator on a unit square

Solve a five-point finite-difference Poisson problem with zero boundary values and mesh comparison.

Your numbers

Use x,y and supported real expressions. Domain is the unit square with zero boundary values.
Use a finite value within the stated calculator limits.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Solve a five-point finite-difference Poisson problem with zero boundary values and mesh comparison.

THE FORMULA−Δu=f on[0,1]²;4u_ij−sum_neighbors u=h²f_ij.

A worked example

For f=2π²sin(πx)sin(πy),the true center value is1;the fine13-node example gives≈1.005731203.

Good to know

Unit square,homogeneous Dirichlet values,finite source expression x,y,5–21 coarse nodes per axis;matrix-free conjugate gradient,doubled intervals. Residual and mesh difference are not continuum error bounds.

A spatial equation needs a spatial boundary model

The Poisson problem here is minus the two-dimensional Laplacian of u equal to a supplied source f on the unit square. The boundary value is zero on all four sides. These choices define a specific elliptic boundary-value problem,rather than an initial-value simulation evolving through time.

The page solves for a grid approximation and compares two mesh spacings. It is distinct from the site's one-dimensional finite-element problem because both coordinate directions contribute to the interior coupling. The static worked illustration shows a surface slice,but the returned table represents the whole coarse square grid.

Two dimensional Poisson equation worked example on a unit squareZero boundaryu=sin(πx)sin(πy)True center = 1
Scroll across to see the full diagram.
For f=2π²sin(πx)sin(πy),the true center value is1;the fine13-node example gives≈1.005731203.

Compare this with the Finite element one dimensional Poisson equation calculator. Solve a spatial2D elliptic boundary problem rather than a one-dimensional finite-element equation.

Enter a source and a coarse resolution

Use a finite real expression in x and y for f(x,y). The coarse node count is shared by both axes and includes the boundary nodes. The interface accepts five through twenty-one coarse nodes per side and computes a finer grid with twice as many subintervals in each direction.

Coordinates run from zero to one. A dimensional application must first scale its domain,equation and units consistently. The input does not include arbitrary nonzero boundary values,irregular geometry,holes or mixed derivative boundary conditions. Those would require a different assembly and should not be assumed from the general name Poisson equation.

The five-point stencil couples neighbors

At an interior node,the negative Laplacian is approximated by four times the center value minus its four axis-neighbor values,divided by the square of the spacing. With zero boundary values,the known boundary terms contribute zero to the right-hand side of the interior system.

This produces a symmetric positive-definite matrix for the stated rectangle and Dirichlet model. Each row is sparse because only nearby nodes interact directly. The calculator applies that stencil without storing every matrix entry,which keeps the doubled fine-grid check practical inside the browser.

A bounded iterative linear solve

Conjugate gradient solves the positive-definite system,starting from zero. The stopping condition monitors the residual in the assembled discrete equations. A fixed iteration cap protects the interface;failure to meet the residual target raises an unresolved-solve error instead of presenting a partial iterate as the final answer.

The residual is reported in the original stencil scale after dividing out the spacing factor. It measures satisfaction of the finite-difference equations,not error against the exact continuum solution. A tiny residual can coexist with a visible spatial discretization error on a coarse mesh.

A known sine solution checks the method

For f=2π²sin(πx)sin(πy),the continuum solution is u=sin(πx)sin(πy),which vanishes on every boundary. Its exact center value is one. The coarse seven-node example is solved again on a thirteen-node fine grid,whose center value is approximately1.0057312.

The finite-difference solution is slightly above one because the discrete sine eigenvalue differs from π² in each coordinate. This is expected truncation error,not a failed residual check. The example therefore distinguishes the linear-system certificate from the independent continuum benchmark.

Interpret mesh comparison cautiously

The page compares coarse values with fine values at matching spatial nodes. The largest difference is a useful refinement diagnostic. For smooth regular problems,the standard stencil has second-order spatial behavior,but this displayed difference alone is not a rigorous error bound for arbitrary entered sources.

A source with singularities,sharp localized features or invalid values between sample nodes may need adaptive meshing and mathematical analysis. The parser rejects nonfinite sampled values,but it cannot prove global smoothness from a finite set of evaluations. The user must preserve the regularity assumptions of the model.

Use the complete grid as the result

The center metric is a convenient summary,not the entire solution. The coarse grid includes boundary zeros and interior approximations so spatial variation can be inspected. For an even number of coarse nodes,the reported fine-grid midpoint still refers to the exact geometric center of the square.

The calculation does not infer physical material parameters or automatically change the sign convention to a positive Laplacian. Save the equation sign,unit-square domain,zero boundary model,source and node count together when comparing with another PDE implementation.

A few questions, answered

Which Laplacian sign is used?

The equation is minus the Laplacian of u equal to f.

Can I enter nonzero boundaries?

No. All four boundary values are fixed at zero.

What does the linear residual check?

The discrete grid equations,not exact continuum accuracy.

Is the refinement difference certified error?

No. It is a coarse/fine sensitivity diagnostic.

Find your calculator

Start typing to explore the library.