Numerical Zoo · Interpolation

Runge's function

A smooth function that teaches high-degree polynomial interpolation some humility.

Why numerical analysts keep this one around

Runge's function, f(x) = 1 / (1 + 25x^2), is smooth and completely well behaved on [-1,1]. Sample it at equally spaced points, however, and a high-degree polynomial interpolant can oscillate badly near the ends of the interval.

That makes the example useful because the data are not noisy, the function is not discontinuous, and the polynomial really does pass through every sample. Nothing has gone wrong according to the interpolation condition. The unreasonable behavior appears between the points.

The lesson is therefore not 'polynomials are bad.' It is that satisfying the data exactly does not settle the modeling question. Node placement and locality matter.

R setup

Start with the actual object.

f <- function(x) 1 / (1 + 25*x^2)

x <- seq(-1, 1, length.out = 11)
y <- f(x)

plot(x, y)
curve(f, from = -1, to = 1, add = TRUE)

By hand first

Do enough arithmetic to see the trap.

1

With two points, linear interpolation is forced to be a line. Add more points and the global polynomial gains degrees of freedom.

2

Every new sample is another exact constraint on the same global polynomial. Near the interval endpoints, those constraints can produce large oscillations.

3

A piecewise linear interpolant and a cubic spline use the same data but distribute the modeling freedom differently.

What to look for

Now make it earn its reputation.

  • Begin with 5 or 7 equally spaced points, then increase the count.
  • Compare the global polynomial with the piecewise linear and spline curves. All hit the points. They do not agree between them.
  • Move the nodes away from equal spacing if you want to turn the example into a discussion about Chebyshev nodes.
Keep this distinction:

If an interpolant passes through every observation, that tells us exactly one thing: it passes through every observation.