Advanced maths

Finite element one dimensional Poisson equation calculator

Linear finite elements approximate a one-dimensional Poisson boundary-value problem through a weak formulation.

Your numbers

3–64 strictly increasing nodes.
f(x)=c0+c1x+…; degree ≤6.
Value at the first node.
Value at the last node.

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

Linear finite elements approximate a one-dimensional Poisson boundary-value problem through a weak formulation. This calculator assembles the stiffness matrix and polynomial-source load vector on your nonuniform mesh, imposes prescribed values at both endpoints and solves for the interior nodal coefficients. The diffusion coefficient is fixed at one.

THE FORMULAK_e=(1/h_e)[[1,−1],[−1,1]]; F_i=∫f(x)φ_i(x)dx; K_II u_I=F_I−K_IBu_B.

A worked example

For −u″=2 on [0,1] with zero endpoints, the exact solution is x(1−x). Nodes 0,0.25,0.5,0.75,1 give values 0,0.1875,0.25,0.1875,0. The finite-element function joins those values linearly, so between nodes it differs from the quadratic even though the nodal values agree in this example.

Good to know

Unit constant diffusion, polynomial source degree ≤6, linear elements, 3–64 increasing decimal nodes and Dirichlet conditions at both ends. Analytic element integration is evaluated in floating point. No adaptive refinement, variable diffusion, Neumann or mixed boundary conditions, or certified continuous error estimate.

The element length controls the local stiffness

A hat basis function is linear on each neighboring element and zero outside its support. Its derivative is constant on an element, making the local stiffness scale as one divided by element length. Short elements therefore contribute larger matrix entries. Unequal spacing is handled in assembly rather than replaced by a single average step.

The two local source integrals weight f(x) by the left and right shape functions. For polynomial f they are evaluated from power antiderivatives. This keeps the load vector tied to the weak equation and avoids sampling the source only at nodes, which would be a different approximation on a nonuniform mesh.

Piecewise linear elements join the quadratic solution at mesh nodesu(1/2) = 1/44 linear elementsf(x) = 2
For −u″=2 with u(0)=u(1)=0, mesh nodes 0,1/4,1/2,3/4,1 have nodal values 0,3/16,1/4,3/16,0. The straight segments are u_h; the dashed quadratic differs between nodes.

The Boundary value differential equation calculator with finite differences covers a related task. This page focuses on finite element one dimensional Poisson equation calculator with the method limits and worked example described below.

Boundary values modify the right-hand side

Prescribed endpoint coefficients are removed from the unknown vector. Their stiffness contributions move to the interior right-hand side with a minus sign. Nonzero boundary values are therefore supported directly; setting the endpoint matrix rows to zero without this correction would solve the wrong interior equation.

The reported residual uses the assembled interior rows after substituting both endpoint values. It tests algebraic equilibrium in the discrete space. A near-zero residual does not mean the true differential equation holds pointwise between nodes, where a piecewise-linear approximation has zero classical second derivative away from element joints.

Refinement should be judged against the modeled quantity

Increasing the node count enriches the trial space and generally improves a well-posed problem’s approximation, but the useful mesh depends on where curvature and source variation occur. The energy value summarizes the discrete functional evaluated at the solution; it should not be confused with a stand-alone error bound.

The existing finite-difference boundary solver enforces differential approximations on a stencil. Finite elements instead integrate against basis functions and assemble local contributions. Comparing both on a smooth problem is useful, but matching outputs does not make their formulations identical or justify using either outside its stated boundary assumptions.

A few questions, answered

Why does the quadratic example match all nodes?

For this one-dimensional constant-diffusion problem, the assembled linear-element equations reproduce those exact nodal values; the interpolated curve still differs between nodes.

Are nonuniform elements supported?

Yes. Each element has its own length and analytically integrated source contributions.

Find your calculator

Start typing to explore the library.