Interpolation Basics: A Comprehensive Guide

Interpolation is a powerful technique in numerical analysis used to estimate unknown values between known data points by constructing a function—typically a polynomial or piecewise curve—that passes through those points. This method is essential when dealing with discrete datasets, such as experimental measurements, time-series data, or tabulated values, where continuous behavior needs to be inferred.

Unlike extrapolation, which predicts values outside the known range, interpolation focuses on filling gaps within the data. Applications range from smooth graph plotting to approximating physical phenomena like temperature gradients or stock price movements. The accuracy of interpolation depends on the method chosen and the underlying behavior of the data—whether it’s linear, polynomial, or highly oscillatory.

At its core, interpolation assumes that the function between points can be modeled effectively. For instance, given points \( (x_0, y_0) \) and \( (x_1, y_1) \), we seek a function \( f(x) \) such that \( f(x_0) = y_0 \) and \( f(x_1) = y_1 \), and then evaluate \( f(x) \) for \( x_0 < x < x_1 \). This process bridges discrete mathematics with continuous analysis, making it a cornerstone of computational science.

Linear Interpolation: Theory and Application

Linear interpolation is the simplest and most intuitive interpolation method, assuming a straight line connects two adjacent data points. For points \( (x_0, y_0) \) and \( (x_1, y_1) \), the interpolated value \( y \) at \( x \) (where \( x_0 \leq x \leq x_1 \)) is given by:

\[ y = y_0 + \frac{(y_1 - y_0)(x - x_0)}{x_1 - x_0} \]

This formula represents the equation of a line passing through the two points, derived from the slope \( m = \frac{y_1 - y_0}{x_1 - x_0} \) and the point-slope form \( y - y_0 = m (x - x_0) \). It’s computationally lightweight and widely used when data changes gradually.

The error in linear interpolation is tied to the curvature of the true function. If the second derivative \( f''(x) \) is non-zero, the error can be approximated via Taylor’s theorem:

\[ \text{Error} \approx \frac{f''(\xi)}{2} (x - x_0)(x - x_1) \]
\[ \text{where } \xi \in [x_0, x_1] \]

This error is zero for linear functions but grows with curvature, prompting the use of higher-order methods for complex data.

Detailed Examples of Interpolation

Let’s dive into practical examples of interpolation, starting with linear methods and progressing to more sophisticated techniques.

Example 1: Linear Interpolation

Given points \( (0, 0) \) and \( (2, 4) \), find \( y \) at \( x = 1 \):

\[ y = 0 + \frac{(4 - 0)(1 - 0)}{2 - 0} \] \[ = \frac{4 \cdot 1}{2} \] \[ = 2 \]

The true function might be \( y = 2x \), so \( y(1) = 2 \), and the interpolation is exact here. For \( x = 1.5 \):

\[ y = 0 + \frac{(4 - 0)(1.5 - 0)}{2 - 0} \] \[ = \frac{4 \cdot 1.5}{2} \] \[ = 3 \]

Again, exact for a linear function.

Example 2: Linear Interpolation with Nonlinear Data

For \( (1, 1) \) and \( (3, 9) \) (from \( y = x^2 \)), at \( x = 2 \):

\[ y = 1 + \frac{(9 - 1)(2 - 1)}{3 - 1} \] \[ = 1 + \frac{8 \cdot 1}{2} \] \[ = 1 + 4 = 5 \]

True value: \( y = 2^2 = 4 \). Error: \( 5 - 4 = 1 \), due to the quadratic nature of \( y = x^2 \).

Example 3: Quadratic Interpolation

Using points \( (0, 0) \), \( (1, 1) \), \( (2, 4) \) (from \( y = x^2 \)), fit a quadratic polynomial \( p(x) = ax^2 + bx + c \):

  • \( p(0) = c = 0 \)
  • \( p(1) = a + b = 1 \)
  • \( p(2) = 4a + 2b = 4 \)

Solve: \( a + b = 1 \), \( 4a + 2b = 4 \). From the second, \( 2a + b = 2 \). Subtract: \( (2a + b) - (a + b) = 2 - 1 \), so \( a = 1 \), then \( b = 0 \). Thus, \( p(x) = x^2 \), exact for this data.

Advanced Interpolation Methods

For higher accuracy or smoother curves, advanced methods like Lagrange polynomials and cubic splines are employed.

Lagrange Interpolation

Given \( n+1 \) points, the Lagrange polynomial is:

\[ P(x) = \sum_{i=0}^n y_i \ell_i(x) \]
\[ \ell_i(x) = \prod_{\substack{j=0 \\ j \neq i}}^n \frac{x - x_j}{x_i - x_j} \]

For \( (0, 0) \), \( (1, 1) \), \( (2, 4) \), at \( x = 1.5 \):

\[ \ell_0(1.5) = \frac{(1.5 - 1)(1.5 - 2)}{(0 - 1)(0 - 2)} = \frac{0.5 \cdot (-0.5)}{(-1) \cdot 2} = -0.125 \]
\[ \ell_1(1.5) = \frac{(1.5 - 0)(1.5 - 2)}{(1 - 0)(1 - 2)} = \frac{1.5 \cdot (-0.5)}{1 \cdot (-1)} = 0.75 \]
\[ \ell_2(1.5) = \frac{(1.5 - 0)(1.5 - 1)}{(2 - 0)(2 - 1)} = \frac{1.5 \cdot 0.5}{2 \cdot 1} = 0.375 \]
\[ P(1.5) = 0 \cdot (-0.125) + 1 \cdot 0.75 + 4 \cdot 0.375 = 0.75 + 1.5 = 2.25 \]

True \( y = (1.5)^2 = 2.25 \), exact due to quadratic fit.

Cubic Splines

Cubic splines use piecewise cubic polynomials, ensuring continuity in value, first, and second derivatives. For \( n \) intervals, solve for coefficients via:

\[ S_i(x) = a_i + b_i (x - x_i) + c_i (x - x_i)^2 + d_i (x - x_i)^3 \]

Conditions include \( S_i(x_i) = y_i \), \( S_i(x_{i+1}) = y_{i+1} \), and derivative continuity. Natural splines set \( S''(x_0) = S''(x_n) = 0 \), yielding a tridiagonal system solvable numerically.

Newton’s Divided Difference

An alternative polynomial form:

\[ P(x) = f[x_0] + f[x_0, x_1] (x - x_0) + f[x_0, x_1, x_2] (x - x_0)(x - x_1) + \cdots \]
\[ f[x_i, x_j] = \frac{f[x_{i+1}, x_j] - f[x_i, x_{j-1}]}{x_j - x_i} \]

Efficient for adding points incrementally.