1. Errors and residuals
A solver can finish before your question is answered
Section titled “A solver can finish before your question is answered”Imagine predicting the temperature at the middle of a rod. The linear solver reports a tiny residual. That tells you something about a system of algebraic equations; it does not yet say whether the mesh resolves the temperature or whether the conductivity describes the material.
We will distinguish these questions using one matrix and one executable Poisson experiment. You need matrix multiplication and the idea of a vector length. The heat-transfer book supplies the physical interpretation if you want one.
Follow the approximations
Section titled “Follow the approximations”Let solve the continuous mathematical problem, solve its discretized equations exactly, and denote the field reconstructed from the computed coefficients. Then
The first term is spatial approximation error. The second includes incomplete algebraic solution and rounding. Neither term measures the difference between the mathematical model and the physical world.
| Source of discrepancy | A controlled investigation |
|---|---|
| Physical assumptions | Compare a neglected effect with the retained balance |
| Uncertain input | Vary that input within a justified range |
| Spatial approximation | Refine the mesh with the model and solver policy fixed |
| Temporal approximation | Change time accuracy while keeping the spatial problem fixed |
| Algebraic iteration | Tighten the stopping tolerance on the same mesh |
| Floating-point arithmetic | Examine scaling and sensitivity; refine with care |
These are different experiments. Refining a mesh cannot fix the wrong heat source, and tightening a solver cannot add missing spatial degrees of freedom.
What a residual measures
Section titled “What a residual measures”For , define the residual of a computed coefficient vector by
Subtraction gives , hence when is invertible. Taking compatible norms yields
for nonzero . The condition number describes how strongly residuals can be amplified into coefficient errors. Scaling and stopping criteria therefore matter together; see Barrett and coauthors’ discussion of stopping criteria.
A small residual with a large error
Section titled “A small residual with a large error”Take
Then , although one component of the solution is completely wrong. In the infinity norm, the relative residual is and the relative error is . Here , so the bound is attained.
If the two unknowns represent quantities with different units, a raw vector norm may itself be meaningless. Choose physical reference scales first: for example, measure temperature error relative to a chosen temperature difference.
Compute a spatial comparison
Section titled “Compute a spatial comparison”From the eqiora-source checkout created in Get started, run:
cargo run -p eqiora-numerics --example poisson_convergenceThe comparison program solves with zero endpoint values on the unit interval. Before inspecting its table, differentiate twice and check the boundary values. That gives you the answer without relying on the program.
Read the fem_l2 and fvm_l2 columns as field errors, and the two balance
columns as conservation discrepancies. Their magnitudes need not be similar:
a method can balance its source and boundary flux almost exactly while its
field remains visibly approximate. The following lessons derive both methods
and explain precisely which field each error measures.
The program assembles and solves the system itself. Open its source to see where the model is loaded and where the mesh counts enter the comparison.
Estimate spatial error from an accepted result
Section titled “Estimate spatial error from an accepted result”The development checkout provides result.discretization_error_indicators(field, quadrature_points=3) for a steady scalar P1 triangular diffusion problem with
constant positive diffusion and homogeneous essential boundaries. It returns
an immutable array in the Result mesh’s cell order and its physical Dimension.
The released 0.1.3 wheel predates this method.
For with constant , each triangle receives
Here is the longest triangle edge and is the edge length. Each interior-edge contribution is shared between its two triangles. The global estimate is and estimates the H1 error seminorm; in two spatial dimensions its units are the Field’s units. The source-squared integral uses the explicitly selected Duffy quadrature, so the caller must establish its integration accuracy. See the residual estimator derivation for the element residual, normal jump and shape-regularity assumptions.
These are estimates, not certified upper bounds with a known constant. They do not include model discrepancy, quadrature error or an independently bounded algebraic error. Other boundary laws, variable diffusion, reaction, transport, transient problems and other Spaces reject rather than silently omit their residual terms. Mesh marking, local refinement and field transfer are not yet provided by this query.
The mesh error estimation notebook defines the Geometry, equations, mesh and solver in its own cells. It compares three uniform refinements with exact manufactured-solution errors, then saves and reopens the Plans and Results. Use the development checkout; hosted Colab execution has not been verified.
A misleading improvement
Section titled “A misleading improvement”Suppose one run uses 16 cells and a relative solver tolerance of ; another uses 32 cells and . A smaller field error in the second run does not isolate spatial convergence: two controls changed. First compare tolerances on the 16-cell problem, then compare meshes using an adequately tight common tolerance.
Conversely, a flat error curve under mesh refinement may mean algebraic error has become dominant. It can also mean a wrong comparison function or norm. Identify which hypothesis a follow-up run would distinguish.
Exercises
Section titled “Exercises”- Replace by in the matrix example. Recompute the residual, condition number, and error without a solver.
- Let . Explain why residual and coefficient error now agree, and why this still says nothing about spatial discretization error.
- In the Poisson output, find a row with a small balance discrepancy and a larger field error. Explain how both can be correct.
- Design three runs that distinguish a solver-tolerance plateau from spatial error. State what stays fixed in each comparison.