Skip to main content

6.5 Data fitting — Lagrange interpolation

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §6.5–6.5.1. Rewritten in original wording. Continues 6.4b Magnetization labs (searching → fitting). Labs: 6.5b Lagrange interpolation labs.

Interpolation vs. fitting​

A table of measurements is not a function — it is nn isolated points, each carrying its own experimental error. Two different questions can be asked of it:

  1. Interpolate: find some smooth curve that passes through the tabulated values, so you can read off a value between them.
  2. Fit: assume a theoretical functional form and adjust its free parameters so the curve matches the data as well as possible in a statistical sense (least squares — covered separately).

Interpolation is simpler and doesn't require knowing the "correct" theory, but it also doesn't account for noise: it forces the curve through every point, warts and all. A worked example is neutron-nucleus resonant scattering. The tabulated cross section:

ii123456789
EiE_i (MeV)0255075100125150175200
g(Ei)g(E_i) (mb)10.616.045.083.552.819.910.88.254.7
Error (mb)9.3417.941.585.551.521.510.86.294.14

The theoretical Breit–Wigner shape this data is expected to follow is

f(E)=fr(E−Er)2+Γ2/4,f(E)=\frac{f_r}{(E-E_r)^2+\Gamma^2/4},

with unknown resonance energy ErE_r, width Γ\Gamma, and scale frf_r — but interpolation alone never needs to know this formula.

Local polynomials, one interval at a time​

Assume g(x)g(x) can be approximated on interval ii by a degree-(n−1)(n-1) polynomial

gi(x)≃a0+a1x+a2x2+⋯+an−1xn−1.g_i(x)\simeq a_0+a_1 x+a_2 x^2+\cdots+a_{n-1}x^{n-1}.

The fit is local: a different set of coefficients aka_k is used in each interval, rather than forcing one polynomial to cover the entire table. Multiple low-degree polynomials, stitched together, behave far better than a single high-degree one.

The Lagrange formula​

Lagrange found a closed form that fits an (n−1)(n-1)-degree polynomial through nn points directly, without solving for the aka_k by hand. Walk the construction — at each step pick the matching equation (lookalikes included).

Worked check. Given x1–4=(0,1,2,4)x_{1\text{–}4}=(0,1,2,4) and g1–4=(−12,−12,−24,−60)g_{1\text{–}4}=(-12,-12,-24,-60), expanding the four-point formula simplifies to g(x)=x3−9x2+8x−12g(x)=x^3-9x^2+8x-12. Checks: g(4)=−60g(4)=-60 ✓, and g(0.5)=−10.125g(0.5)=-10.125 off-node. Nodes need not be evenly spaced.

Why global fits misbehave​

The interpolant hits every node, but the remainder between nodes can explode when high derivatives are large (noisy tables). Pick the remainder formula and the practical remedy among lookalikes.

Rule of thumb: keep interpolation local (small nn, e.g. n=3n=3) and treat global high-degree fits with suspicion. Extrapolation outside the table is riskier still.

Quiz

Lagrange interpolation

1 / 4

An n-point Lagrange interpolation produces a polynomial of degree…

Pick an answer to see if you are right.

Next: 6.5b Lagrange interpolation labs.