Finite Difference Solver Calculator

Solve 1D diffusion and Poisson problems precisely here. Tune grid size, sources, and units easily. See the full table, chart, and export options below.

Solver inputs
All fields support decimals. Bounds are enforced for stability.
Range: 1e-9 to 1e9
Total nodes = N + 2 (includes boundaries)
k > 0 keeps the system well-posed
Use the same unit for u(L)
Fixed endpoint value at x=L
Applies to table, exports, and stats
Defines the forcing on the right-hand side
Used as S0, a, or A
Used as b or φ (radians)
Notes are stored with your latest run for exports.
Reset
Example data table

Example settings: L=1, N=5, k=1, u0=0, uL=1, s(x)=0. Expected profile is linear.

x u(x) Comment
0.00000.0000Left boundary
0.16670.1667Interior node
0.33330.3333Interior node
0.50000.5000Midpoint
0.66670.6667Interior node
0.83330.8333Interior node
1.00001.0000Right boundary
Formula used

This calculator solves the steady one-dimensional diffusion/Poisson model:

-k \u00B7 d\u00B2u/dx\u00B2 = s(x),   u(0)=u0,   u(L)=uL

Using a uniform grid with spacing dx = L/(N+1), the second derivative is approximated by the central difference:

d\u00B2u/dx\u00B2 \u2248 (u_{i-1} - 2u_i + u_{i+1}) / dx\u00B2

This creates a tridiagonal linear system, solved efficiently with the Thomas algorithm in O(N) time.

How to use this calculator
  1. Set L and choose the distance unit.
  2. Pick N interior points; larger N improves accuracy.
  3. Enter boundary values u0 and uL.
  4. Select a source term and adjust parameters p1, p2.
  5. Press Solve to view stats, the table, and the chart.
  6. Use Download CSV or Download PDF to export results.
Professional notes on the finite difference solver

1) What this solver computes

This calculator computes a steady one-dimensional field u(x) on [0,L] where diffusion (or conductivity) balances a prescribed forcing. It targets engineering-style boundary value problems used in heat conduction, electrostatics, and pressure/deflection checks with fixed endpoints.

2) Governing equation and boundary data

The model is -k d²u/dx² = s(x) with u(0)=u0 and u(L)=uL. Here k is a positive coefficient that scales curvature. The source options include zero (Laplace), constant, linear, and sinusoidal forcing, each controlled by p1 and p2.

3) Grid resolution and step size

The grid uses N interior nodes plus two boundaries, so total nodes are N+2. The spacing is dx=L/(N+1). For quick exploration, N=25 is often sufficient. For smooth solutions, N=100 typically yields visually converged curves, while N=500–2000 supports mesh studies and stronger forcing.

4) Accuracy and truncation error

The second derivative uses a central difference that is second-order accurate, meaning the truncation error scales like O(dx²). If you halve dx (roughly doubling N), the discretization error often drops by about a factor of four for sufficiently smooth u(x). A practical check is to compare results at N, 2N, and 4N.

5) Conditioning and parameter limits

Because the matrix diagonal scales with 2k and the right-hand side scales with dx², extreme combinations of very small k and very large N can amplify roundoff. The form enforces safe bounds (for example k>0 and N≤5000) to reduce numerical issues while keeping realistic problem sizes.

6) Runtime and memory footprint

The tridiagonal system is solved with the Thomas algorithm in O(N) time. Internally, the method stores three diagonals and one right-hand side, so memory grows roughly with a few arrays of length N. Even at N=5000, this remains lightweight for typical server limits.

7) Reading the table and chart

The output table lists x, the solution u(x), and the forcing s(x) at every node. The chart overlays u(x) and s(x) to highlight how curvature follows the source. Use the min/max summary to detect overshoot, steep gradients, or unexpected boundary influences.

8) Exports and reporting

CSV exports all nodes for post-processing in spreadsheets or scripts. The PDF export is intentionally compact for documentation; it samples rows if the grid is dense so the report fits on one page (downsampling begins above roughly 45 printed rows). Add run notes to preserve context with your latest export.

FAQs

1) What problem type does this solver handle?

It solves steady 1D diffusion/Poisson boundary value problems with fixed endpoint values: -k d²u/dx² = s(x), u(0)=u0, u(L)=uL.

2) How do I choose a good N value?

Start with N=25 for a quick view. Increase to N=100 for smoother curves. For verification, run N, 2N, and 4N and compare changes in u(x).

3) Why must k be positive?

A positive k matches diffusion-like physics and produces a well-posed system with a stable tridiagonal matrix. Negative or zero k can invert the operator, making solutions non-physical or numerically unstable.

4) What do p1 and p2 mean for each source?

For constant forcing, p1=S0. For linear, p1=a and p2=b. For sinusoidal, p1=A and p2=φ (radians). For zero forcing, both are ignored.

5) How accurate are the computed values?

The central difference for d²u/dx² is second-order accurate, so discretization error typically scales like O(dx²). Accuracy improves quickly as you refine the grid, especially when the solution is smooth.

6) Why does the PDF show fewer rows than the CSV?

The PDF is designed to fit on one page for reporting. If the grid is dense, it samples rows so the table remains readable. The CSV always includes every node for full-resolution post-processing.

7) Can I use this for time-dependent diffusion?

This page solves the steady spatial problem only. For time dependence, you would add a time discretization (explicit, implicit, or Crank–Nicolson) and step forward in time while reusing the same spatial finite difference operator.

Related Calculators

markov chain monte carlometropolis monte carlokinetic monte carlodiscrete element methodconjugate heat transferquantum monte carlomultibody dynamicsstiff ode solveradaptive mesh refinementparticle in cell

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.