Finding something worth knowing…

Science

Guessing the value between two measurements is harder than drawing a straight line

Suppose a function equals 0.9093 at 2 and 0.1411 at 3. The obvious guess at 2.5 is the midpoint, 0.5252. A smooth curve through seven known points says about 0.597 instead. Interpolation is the art of choosing which guess to trust, and each method trades speed against accuracy.

Scientists and engineers constantly hold a handful of sampled or measured values and need estimates for inputs in between. A related job is replacing a formula that is too costly to evaluate with a simpler stand-in built from a few of its values, accepting a little error for a big gain in speed. Methods differ in accuracy, cost, how many points they need and how smooth the result is.

The crudest approach copies the nearest known value. It is rarely worth it in one dimension, since a straight line is nearly as easy, but its speed makes it attractive for data in many dimensions. Linear interpolation, nicknamed lerp, joins neighbouring points with straight segments so that the slope from the left point to the estimate matches the slope between the two points. It is quick but imprecise: the error grows with the square of the gap between points, and the resulting graph has corners where it cannot be differentiated.

Polynomial interpolation fits a single curve through everything. Any n points pin down a unique polynomial, of degree n minus 1 or lower, that hits every one, here a sixth-degree polynomial through seven. Its error shrinks with the n-th power of the spacing and it is infinitely smooth. It can even locate peaks and troughs beyond the sampled values, such as a maximum near x of 1.566. The costs are heavier computation and wild wiggles near the ends, known as Runge's phenomenon, which can push estimates outside what the function could ever do, for instance going negative when the true values never are.

Splines offer a compromise: low-degree polynomial pieces on each interval, stitched so they join smoothly. A natural cubic spline has continuous first and second derivatives, with the second derivative equal to zero at both ends. Restricting to Chebyshev polynomials also tames the end wiggles. For easing between a start and end value, exponential interpolation follows a growth or decay curve instead.

Source: Interpolation

Related

More in Science · All topics