Fundamentals / Numerical mathematics

Approximation and quadrature

Reconstruct functions from samples or projections, derive deterministic and Monte Carlo quadrature rules, and test whether their error estimates are credible.

Prerequisites Derivatives and definite integrals.

Investigate with OneSimulation Measure what interpolation does to a heat integral

Read the subject in depth

Each volume develops its arguments in sequence, with worked problems and links to experiments.

How the course fits together

  1. Chapters 1–4

    Connect samples locally, choose polynomial nodes, then impose smooth joins to obtain splines. Integrating a reconstructed curve produces a quadrature rule with an error inherited from the approximation.

  2. Chapters 5–8

    Choose nodes to integrate moment conditions exactly or adapt intervals where estimates disagree. Divided differences make incremental interpolation possible, while minimax approximation controls the worst pointwise error.

  3. Chapters 9–12

    Represent functions by global frequencies or orthogonal projections. Endpoint regularity can limit convergence. Random quadrature replaces geometrical spacing with sampling and a statistical error estimate.

Chapters

  1. Piecewise interpolation and error bounds

    Construct a continuous profile from sensor values, prove a local interpolation bound and distinguish sampling error from measurement uncertainty.

  2. Polynomial interpolation and node placement

    Derive the Lagrange interpolant, diagnose amplification of sample noise and use cosine-distributed nodes to control a polynomial error factor.

  3. Hermite pieces and cubic splines

    Build a cubic from endpoint values and slopes, then determine missing curvature information by joining adjacent pieces smoothly.

  4. Composite quadrature and cancellation

    Derive midpoint, trapezoidal and Simpson formulas, and use the sign of curvature to interpret a pair of numerical integral estimates.

  5. Gaussian quadrature and exactness

    Choose quadrature nodes from moment conditions, prove the polynomial exactness of Gauss rules and map a reference rule to a finite element.

  6. Adaptive integration and error estimates

    Construct a local error estimate from nested Simpson panels, allocate an absolute error budget and recognise signals that defeat sampling-based adaptivity.

  7. Divided differences and derivative data

    Build an interpolating polynomial one measurement at a time and incorporate a measured slope at a repeated node.

  8. Uniform approximation and alternation

    Certify a best uniform polynomial by finding alternating errors and compare its guarantee with interpolation at fixed nodes.

  9. Fourier projection and sampled frequencies

    Recover periodic modes by projection and identify signals which become indistinguishable on a uniform sample grid.

  10. Weighted projections and Legendre polynomials

    Derive a best mean-square polynomial and determine how a change of weight changes what that polynomial predicts.

  11. Quadrature near singularities and oscillations

    Transform integrable endpoint singularities and use phase information to diagnose a misleading quadrature result.

  12. Monte Carlo integration and stratification

    Estimate an integral from random samples, attach a sampling uncertainty and derive the gain from stratification in a simple case.

Further chapters and interactive tutorials

  1. Evaluating an interpolant without rebuilding its polynomial

    Derive a quotient from the Lagrange basis, evaluate the removable singularity at a data point and separate rounding error from sensitivity to the data.

  2. When a trapezoidal sum counts the wrong frequency perfectly

    Use a finite geometric series to explain why a very accurate periodic quadrature rule can completely miss an oscillation.

  3. Deriving Romberg integration and recognising a broken error model

    Build an extrapolation table from nested trapezoidal sums and explain when cancelling a presumed leading error makes a poor estimate look precise.

  4. Summing a Chebyshev series by working backwards

    Derive a stable evaluation scheme directly from a three-term polynomial identity and diagnose the failure that occurs when a fitted law is used outside its calibrated interval.

  5. Where should a random quadrature spend its samples?

    Derive the weight that corrects a nonuniform sampling density and see why an unbiased quadrature can nevertheless have infinite variance.

  6. Integrating an infinite endpoint with a finite table of samples

    A density rises without bound near the edge of a specimen, yet the total inferred amount can be finite. Choose nodes that measure the edge contribution accurately. Derive the tanh–sinh transformation, split two different quadrature errors and detect when refining a grid can no longer answer the physical question.

Computational notebooks

Run the Python calculations in your browser and compare the figures with the derivations.

Problem sheets

Sheets 1–6 accompany the first twelve chapters. The final projects bring several methods together. Attempt each stage before opening its worked solution.

  1. Nodes and interpolationFor chapters 1 and 2

    Analyse local interpolation errors, demonstrate noise amplification under extrapolation and compare two sets of global interpolation nodes.

  2. Smooth pieces and integrated loadsFor chapters 3 and 4

    Build a constrained trajectory, infer a spline curvature, and check quadrature by energy conservation over a measured interval.

  3. Accuracy with few evaluationsFor chapters 5 and 6

    Derive mapped Gaussian weights, expose an underintegrated element and design a tolerance check for a sharply localised signal.

  4. Data and uniform errorFor chapters 7 and 8

    Update measurements in Newton form and certify a uniform approximation by following the signs of its error.

  5. Spectral measures of errorFor chapters 9 and 10

    Distinguish mean-square projections on continuous and sampled intervals and interpret the residual energy.

  6. Choosing where to sampleFor chapters 11 and 12

    Exploit endpoint structure, test aliasing and design a stratified random estimate with a known variance.

  7. Project · How many sensors measure the mean around a ring?

    Design, challenge and repair a quadrature for periodic temperature measurements. Distinguish a sampled mean, reconstruction of a continuous profile and error in a reference calculation.

  8. Integrate a rapidly oscillating signal without resolving every crest

    A lock-in detector measures the in-phase integral \(I(k)=\int_0^1 f(x)\cos(kx)\,dx\). The carrier frequency is known exactly from the instrument. The envelope is smooth and expensive to evaluate. Design a quadrature rule that spends those evaluations on the envelope, and find a case where even the improved method gives a deceptively small answer.

Final synthesis problem · Choose a quadrature variable before choosing a rule

Applied study

Reconstruct a field from samples and estimate how interpolation changes its integral.

What lies between two measurements?

A probe records temperatures at equally spaced positions along a rod. To estimate the mean temperature, first decide what profile those samples represent. For neighbouring points \(x_j,x_{j+1}\) at distance \(h\), write \(x=x_j+sh\) with \(0\leq s\leq1\). The straight line matching both readings is

\[(I_h f)(x)=(1-s)f(x_j)+sf(x_{j+1}).\]

The weights are nonnegative and sum to one. This reproduces every affine function, keeps interpolated values between their neighbours, and amplifies bounded sample errors by at most a factor of one. A finer display grid can draw this line more densely. Recovering new curvature requires new source information.

Use curvature to predict the sign and size of error

For twice continuously differentiable \(f\), the interpolation remainder on one panel is \(f(x)-I_h f(x)=\tfrac12 f''(\xi)(x-x_j)(x-x_{j+1})\) for some \(\xi\) on that panel. The product is nonpositive and reaches magnitude \(h^2/4\) at the midpoint. Thus the maximum error is bounded by \(h^2\max|f''|/8\). For positive curvature the chord lies above the curve.

Integrating the chord gives \(h[f(x_j)+f(x_{j+1})]/2\), the trapezoidal rule. Integrating the bound with the quadratic factor retained gives a panel integral error at most \(h^3\max|f''|/12\). On a fixed interval of length \(L\) there are \(L/h\) panels, so the composite error is bounded by \(Lh^2\max|f''|/12\). The pointwise and total error both decrease quadratically, for different reasons.

Integrate a curved temperature profile

Use the exact profile \(T(x)=300+20(x/L)^2\) K with \(L=1\) m. Four equal panels have \(h=0.25\) m. On the first panel the endpoints are 300 and 301.25 K. Their interpolated midpoint is 300.625 K, while the exact midpoint is 300.3125 K. The overestimate of 0.3125 K is the same on every panel because the curvature is constant.

Temperature rise along the rod’s first 0.25 m. A straight chord lies above the quadratic profile. At 0.125 m it predicts 0.625 K instead of 0.3125 K. Two shorter chords follow the curve more closely.
The shaded area is the extra integral from the first of four trapezoids on the 1 m rod. Sampling its midpoint splits that trapezoid into two. Subtracting 300 K from both curves makes their separation easier to read.

The exact integral is \(300+20/3=306.6667\) K·m on this unit-length rod. Here \(T''=40\) K/m² and the trapezoidal overestimate equals \(Lh^2 T''/12=0.20833\) K·m. Dividing the integral by length gives mean temperature. To obtain thermal energy above a reference temperature, additional material properties and cross-sectional area are needed.

Problem class

Choose the sensor spacing

For the quadratic rod, select the minimum number of equal intervals so the midpoint error never exceeds 0.05 K. How many measurements are needed including both endpoints?

Show the calculation

With \(N\) intervals on a metre, the bound is

\[40/(8N^2)=5/N^2\,\mathrm{K}.\]

Requiring \(5/N^2\leq0.05\) gives \(N\geq10\), hence 11 measurements. At constant curvature this bound is attained at the midpoints.

Infer an integral from two estimates

Four and eight panels give 306.875 and 306.71875 K·m. Assume \(Q_h=Q+c h^2\). Eliminate \(c\) and estimate \(Q\). Would adding sensors only to the display grid make this correction possible?

Show the calculation

Multiply \(Q_{h/2}=Q+c h^2/4\) by four and subtract \(Q_h\). This gives \(Q=(4Q_{h/2}-Q_h)/3=306.66667\) K·m. For the quadratic profile the error law is exact. Subdividing the same source chords on screen preserves their total area and supplies no second source approximation.

OneSimulation laboratory

Measure what interpolation does to a heat integral

Compare recorded OneSimulation runs on this page. To test your own inputs, download the Python model and run the model in an activated OneSimulation environment.

OneSimulation maps source samples to the original nodes and their midpoints. Integrating those segments gives the area under the interpolant. Keep the quadratic temperature law and double the number of source intervals. Then restore four intervals and replace the quadratic law with \(300+20x/L\). Download the Python experiment · OneSimulation point interpolation.

python approximation-and-quadrature.py
python approximation-and-quadrature.py --cells 8
python approximation-and-quadrature.py --law linear
Errors against the exact source function and its integral.
Profile, intervalsMax. midpoint error (K)Integral (K·m)Integral error (K·m)
Quadratic, 40.3125306.875+0.208333
Quadratic, 80.078125306.71875+0.0520833
Linear, 403100
For a quadratic field, doubling the sampling density cuts the integral bias by four. The linear field has zero interpolation bias at the coarser spacing.
For a quadratic field, doubling the sampling density cuts the integral bias by four. The linear field has zero interpolation bias at the coarser spacing.

Halving the spacing divides both quadratic-profile errors by four. The linear-profile result tests exactness on the function space represented by the interpolant.

Change parameters · Change the laboratory inputs

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Problem sheet 2 · Recover an integral using two biased readings

Advanced study across the subject

Each sequence connects the course to detailed chapters in neighbouring subjects. The complete course PDF includes their derivations, examples and exercises.

  1. Approximating a measured field

    Reconstruct a potential from weighted modes. Compare orthogonality in a rectangle, cylinder and sphere, and determine which coefficients can be recovered from noisy measurements.

  2. Sampling, propagation and unresolved scales

    Apply quadrature and spectral approximation to a real aperture, a decaying field and a radiated-power measurement. Look for an observed convergence rate and explain any plateau.

Compute a diffraction integral on successively finer apertures and use its nulls to distinguish integration error from spatial truncation.

Separate diffraction from a finite observation window

Further reading

Compare specific topics with the university sources