Mehmet Emre Tiryaki
Back to Notes

Interpolation

Polynomial Interpolation

Interpolation discretizes a function ff to finitely many values: given (ti,yi)(t_i, y_i), find pp with p(ti)=yip(t_i) = y_i. Through nn points (ti,yi)(t_i, y_i) there is a unique polynomial of degree n−1n - 1,

f(t)=c1+c2t+c3t2+⋯+cntn−1f(t) = c_1 + c_2 t + c_3 t^2 + \cdots + c_n t^{n-1}

with cc from yi=f(ti)y_i = f(t_i),

[1t1⋯t1n−11t2⋯t2n−1⋮⋮⋮1tn⋯tnn−1][c1c2⋮cn]=[y1y2⋮yn]or Vc=y\begin{bmatrix} 1 & t_1 & \cdots & t_1^{n-1} \\ 1 & t_2 & \cdots & t_2^{n-1} \\ \vdots & \vdots & & \vdots \\ 1 & t_n & \cdots & t_n^{n-1} \end{bmatrix} \begin{bmatrix} c_1 \\ c_2 \\ \vdots \\ c_n \end{bmatrix} = \begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_n \end{bmatrix} \qquad \text{or } Vc = y

with VV the Vandermonde matrix.

Piecewise Polynomials

Nodes a=t0<t1<⋯<tn=ba = t_0 < t_1 < \cdots < t_n = b, data y⃗\vec{y}, and a polynomial on each [tk−1,tk][t_{k-1}, t_k], k=1,…,nk = 1, \ldots, n. The result is a function on [a,b][a, b]. The interpolation map P(y⃗)=p\mathcal{P}(\vec{y}) = p with p(tk)=ykp(t_k) = y_k is linear,

P(αy⃗+βz⃗)=αP(y⃗)+βP(z⃗)\mathcal{P}(\alpha \vec{y} + \beta \vec{z}) = \alpha \mathcal{P}(\vec{y}) + \beta \mathcal{P}(\vec{z})

so if the data changes to y⃗+Δy⃗\vec{y} + \Delta \vec{y},

δP=P(y⃗+Δy⃗)−P(y⃗)=P(Δy⃗)=∑k=0n(Δy)k P(ek)\delta \mathcal{P} = \mathcal{P}(\vec{y} + \Delta \vec{y}) - \mathcal{P}(\vec{y}) = \mathcal{P}(\Delta \vec{y}) = \sum_{k=0}^n (\Delta y)_k \, \mathcal{P}(e_k)

With ∥f∥∞=max⁡x∈[a,b]∣f(x)∣\|f\|_\infty = \max_{x \in [a, b]} |f(x)|, the absolute condition number κ\kappa relates ∥δP∥∞\|\delta \mathcal{P}\|_\infty to ∥Δy⃗∥∞\|\Delta \vec{y}\|_\infty,

∥δP∥∞∥Δy⃗∥∞=∥∑k=0n(Δy)k∥Δy⃗∥∞P(ek)∥∞,max⁡0≤k≤n∥P(ek)∥∞≤κ≤∑k=0n∥P(ek)∥∞\frac{\|\delta \mathcal{P}\|_\infty}{\|\Delta \vec{y}\|_\infty} = \Big\| \sum_{k=0}^n \frac{(\Delta y)_k}{\|\Delta \vec{y}\|_\infty} \mathcal{P}(e_k) \Big\|_\infty, \qquad \max_{0 \le k \le n} \|\mathcal{P}(e_k)\|_\infty \le \kappa \le \sum_{k=0}^n \|\mathcal{P}(e_k)\|_\infty

(lower bound from Δy⃗=ej\Delta \vec{y} = e_j, upper bound from the triangle inequality). So the conditioning comes down to the effect of each node switched on one by one. The P(ek)\mathcal{P}(e_k) are the cardinal functions, 1 at tkt_k and 0 at every other node.

Piecewise Linear

p(x)=yk+yk+1−yktk+1−tk(x−tk),x∈[tk,tk+1]p(x) = y_k + \frac{y_{k+1} - y_k}{t_{k+1} - t_k}(x - t_k), \qquad x \in [t_k, t_{k+1}]

Instead, use the hat functions

Hk(x)={x−tk−1tk−tk−1x∈[tk−1,tk]tk+1−xtk+1−tkx∈[tk,tk+1]0otherwise,k=0,…,nH_k(x) = \begin{cases} \frac{x - t_{k-1}}{t_k - t_{k-1}} & x \in [t_{k-1}, t_k] \\ \frac{t_{k+1} - x}{t_{k+1} - t_k} & x \in [t_k, t_{k+1}] \\ 0 & \text{otherwise} \end{cases}, \qquad k = 0, \ldots, n

They are linear on each interval and globally continuous, so their linear combinations are too, and they satisfy the cardinality condition Hk(ti)=1H_k(t_i) = 1 if i=ki = k, 0 otherwise. So P(ek)=Hk\mathcal{P}(e_k) = H_k and

p(x)=∑k=0nykHk(x)p(x) = \sum_{k=0}^n y_k H_k(x)

a basis that depends only on the node locations. The absolute condition number is 1 in the ∞\infty-norm, ∥P(y⃗+z⃗)−P(y⃗)∥∞=∥z⃗∥∞\|\mathcal{P}(\vec{y} + \vec{z}) - \mathcal{P}(\vec{y})\|_\infty = \|\vec{z}\|_\infty, since a piecewise linear function attains its max at a node.

For ti=a+iht_i = a + ih, h=b−anh = \frac{b - a}{n} and f∈C2[a,b]f \in C^2[a, b],

∥f−pn∥∞=max⁡x∈[a,b]∣f(x)−pn(x)∣≤Mh2,M=∥f′′∥∞\|f - p_n\|_\infty = \max_{x \in [a, b]} |f(x) - p_n(x)| \le Mh^2, \qquad M = \|f''\|_\infty

so the error is O(h2)O(h^2), and doubling the number of nodes is 4 times more accurate. pp is continuous but its derivative is not.

Cubic Splines

A cubic on each [tk−1,tk][t_{k-1}, t_k],

Sk(x)=ak+bk(x−tk−1)+ck(x−tk−1)2+dk(x−tk−1)3,k=1,…,nS_k(x) = a_k + b_k(x - t_{k-1}) + c_k(x - t_{k-1})^2 + d_k(x - t_{k-1})^3, \qquad k = 1, \ldots, n

4n4n unknown coefficients, with hk=tk−tk−1h_k = t_k - t_{k-1}. The constraints:

  1. Interpolation at both ends, Sk(tk−1)=yk−1S_k(t_{k-1}) = y_{k-1} and Sk(tk)=ykS_k(t_k) = y_k, i.e. ak=yk−1a_k = y_{k-1} and ak+bkhk+ckhk2+dkhk3=yka_k + b_k h_k + c_k h_k^2 + d_k h_k^3 = y_k (2n2n equations).
  2. S′S' continuous at the interior nodes, bk+2ckhk+3dkhk2=bk+1b_k + 2c_k h_k + 3d_k h_k^2 = b_{k+1}, k=1,…,n−1k = 1, \ldots, n - 1.
  3. S′′S'' continuous at the interior nodes, 2ck+6dkhk=2ck+12c_k + 6d_k h_k = 2c_{k+1}, k=1,…,n−1k = 1, \ldots, n - 1.
  4. Two end conditions: known S′S' or S′′S'' at the endpoints, or the natural spline S1′′(t0)=Sn′′(tn)=0S_1''(t_0) = S_n''(t_n) = 0, or not-a-knot, S′′′S''' continuous at t1t_1 and tn−1t_{n-1}, i.e. d1=d2d_1 = d_2 and dn−1=dnd_{n-1} = d_n (S1=S2S_1 = S_2 and Sn−1=SnS_{n-1} = S_n).

In block form, with H=diag(h1,…,hn)H = \mathrm{diag}(h_1, \ldots, h_n), JJ the n×nn \times n matrix with 1 on the diagonal and −1-1 on the superdiagonal, and EE the first n−1n - 1 rows of II (deletes the last row),

[I000IHH2H30EJ2EH3EH200EJ3EH][abcd]=[y0:n−1y1:n00]\begin{bmatrix} I & 0 & 0 & 0 \\ I & H & H^2 & H^3 \\ 0 & EJ & 2EH & 3EH^2 \\ 0 & 0 & EJ & 3EH \end{bmatrix} \begin{bmatrix} a \\ b \\ c \\ d \end{bmatrix} = \begin{bmatrix} y_{0:n-1} \\ y_{1:n} \\ 0 \\ 0 \end{bmatrix}

plus the two end conditions. The accuracy is ∥f−Sn∥∞≤Ch4\|f - S_n\|_\infty \le Ch^4, 4th order.