Interpolation 📈

Connecting the dots... ideally without the wiggle.
y = f(x)

Lecture 2-2

1. The Interpolation Problem

Slides 4-10

Given a set of data points $(t_1, y_1), (t_2, y_2), \dots, (t_n, y_n)$, find a function $y=f(t)$ such that:

$$ f(t_i) = y_i \quad \text{for all } i=1,\dots,n $$

Interpolation đŸŽ¯

Passing exactly through every data point. Used when data is precise (e.g., table values).

Approximation (Fitting) 📏

Getting "close" to points. Used when data is noisy (e.g., experimental measurements).

2. Monomial Basis

Slides 11-18

The most natural way to find a polynomial $p(t)$ of degree $n-1$ that passes through $n$ points is to write it as a linear combination of powers of $t$ (monomials):

$$ p(t) = x_1 + x_2 t + x_3 t^2 + \dots + x_n t^{n-1} $$

We want to find coefficients $x_1, \dots, x_n$ such that the polynomial matches our data points $(t_i, y_i)$:

$$ \begin{aligned} p(t_1) &= x_1 + x_2 t_1 + \dots + x_n t_1^{n-1} &= y_1 \\ p(t_2) &= x_1 + x_2 t_2 + \dots + x_n t_2^{n-1} &= y_2 \\ &\vdots \\ p(t_n) &= x_1 + x_2 t_n + \dots + x_n t_n^{n-1} &= y_n \end{aligned} $$

This system of linear equations can be written in matrix form $A \mathbf{x} = \mathbf{y}$, where $A$ is the Vandermonde Matrix:

$$ \underbrace{ \begin{bmatrix} 1 & t_1 & \dots & t_1^{n-1} \\ \vdots & \vdots & \ddots & \vdots \\ 1 & t_n & \dots & t_n^{n-1} \end{bmatrix} }_{A \text{ (Vandermonde)}} \underbrace{ \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix} }_{\mathbf{x}} = \underbrace{ \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix} }_{\mathbf{y}} $$

Algorithm & Implementation

2.1 The Problem: Ill-Conditioning

Slides 11-18 (Cont.)

The basis functions $t^k$ look very similar as $k$ increases.

2.2 Deriving Lagrange 🧠

Motivation

3. Lagrange Interpolation

Slides 19-24

Instead of solving a linear system, we can write the polynomial directly:

$$ p_{n-1}(t) = \sum_{j=1}^n y_j \ell_j(t) $$
$$ \ell_j(t) = \prod_{k=1, k \ne j}^n \frac{t - t_k}{t_j - t_k} $$

3.1 Interactive Lagrange đŸ•šī¸

Playground

3.2 SciPy Implementation

Slides 19-24 (Cont.)

SciPy Implementation

4. Newton Interpolation

Slides 25-30

Uses Divided Differences to build the polynomial incrementally.

$$ p_j(t) = p_{j-1}(t) + c_j \prod_{k=1}^j (t - t_k) $$

Benefit: Adding a new data point is cheap ($O(n)$) compared to Lagrange or Monomial ($O(n^2)$ or $O(n^3)$).

4.1 Interactive Newton đŸ•šī¸

Playground

5. Splines & The Wiggle

Slides 41+

Runge's Phenomenon ã€°ī¸

High-degree polynomials oscillate wildly near the edges.

5.1 B-Splines (Basis Splines)

Slides 41+ (Cont.)

Local basis functions ("hat functions") prevent global oscillation.