Boundary Value Problem Methods

Compare discretizations for the elliptic two-point problem \(-\,p\,u'' + b\,u' + c\,u = f(x)\) on \([a,b]\) - finite differences, finite elements, Chebyshev spectral collocation, discontinuous Galerkin, spline (B‑spline) FEM, and shooting. Slide the mesh \(h\) live, switch Dirichlet/Neumann/mixed boundary conditions, tune the DG penalty, inspect the discretization matrix, and measure convergence order. A time‑dependent mode extends the same spatial stencils to the heat and wave equations by the method of lines.

Problem

Each problem is a manufactured solution: \(f\) and the boundary data are derived from a known \(u(x)\), so the error is measured against truth for any coefficients.

Mode

1.00
0.0
0.0

Advection is discretized with an upwind flux (DG) / streamline term; large \(|b|\) relative to \(p\) makes the problem advection-dominated.

Mesh - number of elements \(N\)

N = 16
h = 0.0625

Graph height

380px
Results
Select methods and press Solve.
Solution & approximations
About this plotThe black curve is the exact (manufactured) solution. Coloured curves are the selected methods sampled on their nodes; discontinuous Galerkin is drawn element by element so its jumps at interfaces are visible. In Heat/Wave mode the plot animates the finite-difference solution profile \(u(x,t)\) over time - press Play or scrub the time slider; the dotted grey curve is the initial condition and the full space–time field is shown in the panel below.
About this plotAbsolute error against the exact solution on a logarithmic axis. Lower is better; higher-order methods sit further down. For DG and spline the error is sampled inside each element, not only at nodes. When a Postprocess mode is chosen in the Convergence panel, the postprocessed pointwise error is overlaid in the same colour (Richardson dotted, Bramble–Schatz dash-dot) - the Bramble–Schatz curve is drawn only on the interior where its symmetric kernel is fully supported, and drops well below the raw error there.
About this plotThe sparsity pattern of the assembled matrix \(A\) in \(A\mathbf{u}=\mathbf{f}\), with row index \(i\) (top to bottom) and column index \(j\). Colour shows the sign of each entry. The formula below states the stencil or element matrix with its indices. A small mesh is used here so the pattern stays legible.
Computing…
Axes: - log–log: straight ⇒ \(O(h^{p})\); semi–log y (vs \(N\)): straight ⇒ \(e^{-\alpha N}\) (spectral)
Postprocess: - Richardson: \(u_{\mathrm{ext}}=\dfrac{2^{p}u_{h/2}-u_h}{2^{p}-1}\) (nodal); Bramble–Schatz: B-spline kernel convolution \(u^\ast=\tfrac1H\!\int K(\tfrac{x-y}{H})u_h\,dy\) (interior, Galerkin methods)
About this plotError versus resolution as the mesh is refined. In log–log the error is plotted against \(h=(b-a)/N\); the fitted slope is the empirical order \(p\) (a straight line of slope \(p\) confirms \(O(h^p)\)), and the dashed slate guide marks that reference order. Spectral collocation beats every fixed power (exponential accuracy for smooth solutions), so it curves steeply instead of following a slope; switch to semi–log y (error vs \(N\), linear axis) to see that exponential decay \(e^{-\alpha N}\) straighten into a line, the guide showing the fitted \(Ce^{-\alpha N}\) rate. Levels at machine precision are dropped from the fit.

The Postprocess selector overlays a cheaply-improved error curve for each method:

• Richardson extrapolation (dotted diamonds) combines two consecutive meshes to cancel the leading error term,

\[ u_{\mathrm{ext}}=\dfrac{2^{p}u_{h/2}-u_h}{2^{p}-1}. \]
It sharpens the nodal values, so it is measured at the grid nodes (the between-node interpolant error would otherwise hide the gain): centred FD lifts from order 2 to 4, RK4 shooting from 4 to 6, and P\(_1\) FEM on pure diffusion drops straight to machine precision (its nodal values are already exact).

• Bramble–Schatz (dash-dot stars) is the genuine averaging post-processor of Bramble & Schatz (1977) - the SIAC filter. It convolves a Galerkin solution against a kernel \(K\) made of \(2k{+}1\) B-splines of order \(k{+}1\) whose coefficients reproduce polynomials up to degree \(2k\),

\[ u^{\ast}(x)=\dfrac1H\!\int K\!\big(\tfrac{x-y}{H}\big)\,u_h(y)\,dy. \]
This turns the solution's negative-order-norm superconvergence into interior accuracy of order \(2k\): continuous P\(_2\) FEM lifts from 3 to 4, while P\(_1\) (\(2k{=}2\)) shows no gain. Because the symmetric kernel needs its full support inside \([a,b]\), it is measured on the interior \([a+\tfrac{L}{4},\,b-\tfrac{L}{4}]\) and only meshes fine enough for the support to fit are drawn.
Cite this tool
Kapita, S. (2026). Boundary Value Problem Methods: A Computational Laboratory. Math Tools. https://doi.org/10.5281/zenodo.20981245