Interpolation & Splines

Interpolation

The basic problem of interpolation

Given a set of data points from an (unknown) function y=p(x), can we approximate p’s value at other points?

e.g. Given p(x1)=y1,p(x2)=y2,,p(xn)=yn
Estimate y=p(x) for any point x such that x1xxn

Theorem (Unisolvence Theorem)

Given n data pairs (xi,yi),i=1,,n with distinct xi, there is a unique polynomial p(x) of degree n1 that interpolates the data.

Vandermonde Matrices

Pasted image 20250302203411.png
V is called a Vandermonde matrix

Polynomial interpolation reduces to solving systems of equations

The monomial basis

The familiar form p(x)=c1+c2x+c3x2++cnn1 is called the monomial form, and can also be written as

p(x)=i=1ncixi1

The sequence, 1,x,x2, is called the monomial basis.
Monomial form is a sum of coefficients ci times basis functions xi.

The Lagrange basis

We will define the Lagrange basis functions, Li(x), to construct a polynomial as

p(x)=y1L1(x)+y2L2(x)++ynLn(x)=i=1nyiLi(x)

where yi are the coefficients and also our data values, yi=p(xi).

Given n data points (xi,yi), we define

Li(x)=(xx1)(xxi1)(xxi+1)(xxn)(xix1)(xixi1)(xixi+1)(xixn)

When i=j, Li(xj) has same numerator and denominator.
When ij, Li(xj) has numerator = 0, denominator 0
Ensures p(x) must interpolate each xi

Monomial vs Langrangian basis

  1. They give the same interpolating polynomial
  2. We can directly write down the polynomial from the Lagrange basis functions
  3. No need to solve a linear system

Polynomial Interpolation for many points

Fitting a “high degree” (n7,8,9) polynomial often gives excessive oscillation

Piecewise Interpolation

Hermite Interpolation

The problem of fitting a polynomial given function values and derivatives

Closed-form Solution

Defining the polynomial on the ith interval, pi(x), as

pi(x)=ai+bi(xxi)+ci(xxi)2+di(xxi)3

We saw that the direct formulas for the polynomial coefficients are:

ai=yi,bi=si,ci=3yi2sisi+1Δxi,di=si+1+si2yiΔxi2

where we define

Δxi=xi+1xi

and

yi=yi+1yiΔxi

Pasted image 20250302214032.png

Some Terminology

Knots: Points where the interpolant transitions from one polynomial/interval to another
Nodes: Points where some control points/data is specified

More common problem: no derivative information si is given, only values yi

Can we still fit a piecewise cubic to the set of points?

  • Yes, but each “piece” needs data from more than just its 2 endpoints

Cubic Splines

Fit a cubic, Si(x), on each interval, but now require matching first and second derivatives between intervals.
Require interpolating conditions on each interval [xi,xi+1],

Si(xi)=yi,Si(xi+1)=yi+1

and derivative conditions at each interior point xi+1

Si(xi+1)=Si+1(xi+1),Si(xi+1)=Si+1(xi+1)

Counting Unknowns

Assuming n data points, we have 4(n1) unknowns

Counting Equations

Assuming n data points, we have 2(2n3) equations

4n6 equations, 4n4 unknowns, can we solve the system?

No! Not enough information for unique solution!
Need 2 more equations

  • Usually at domain endpoints
  • Boundary conditions or end conditions

Boundary Conditions

Clamped

Slope set to specific value

Free/natural/variational

S(x1)=S(xn)=0

If both boundaries are free, called a natural cubic spline.

Periodic boundary

“Not-a-knot” boundary conditions

Hermite vs. Cubic Splines

Hermite Interpolation: each interval can be found independently
Cubic Spline: must solve for all polynomials together at once!

Basic cubic spline approach

For n points, we have n1 intervals / cubic polynomials, so 4n4 unknowns.
Write down:

Cubic Splines via Hermite Interpolation

Use Hermite interpolation as a stepping stone to build a cubic spline!

  1. Express unknown polys with closed form Hermite equations
  2. Treat the si as unknowns
  3. Solve for si that gives continuous 2nd derivates
  4. Given si, plug into closed form Hermite equations to recover poly coefficients.

Efficient Splines Summary

Interior nodes (i=2,,n1):

Δxisi1+2(Δxi1+Δxi)si+Δxi1si+1=3(Δxiyi1+Δxi1yi)

where we define

Δxi=xi+1xi

and

yi=yi+1yiΔxi

Clamped BC:

s1=s1,sn=sn

Free BC:

s1+s22=32y1,sn12+sn=32yn1

Matrix Form

We can write this linear system for the slopes in matrix/vector form
Pasted image 20250303081103.png
New system has one equation per node, no matrix size is n×n. This system is smaller in size by a constant factor 4.

Matrix Structure

The matrix is tridiagonal. Only the entries on the diagonal and its two neighbours are ever non-zero!
Pasted image 20250303081502.png

Shortcomings So Far

Cannot handle curve that has different y for same x.
Pasted image 20250303081735.png

Parametric Curves

Lets us handle more general curves

Solution

Let x and y each be separate functions to a new parameter, t.
Then a point’s position is given by the vector P(t)=(x(t).y(t)).
Pasted image 20250303082110.png
Parameter t increases monotonically along the curve, but x and y may increase and decrease as needed to describe any shape.

Parametric curves are a more powerful/flexible way of describing curves in general

Non-Uniqueness

A given curve can be “parameterized” in different ways, while yielding the exact same shape.

Speeds

2 parameterizations can also traverse the curve in the same direction, but at different speeds/rates

Repeated Points

Curves with self-intersections are supported easily

Piecewise Parametric Curves

Arc-Length Parameterization

Common to choose t as the distance along the curve
Pasted image 20250303083024.png
This gives unit speed traversal of the curve

Parametric Curves using Interpolation

Parametric curves are just the general concept
We can combine existing interpolant types with parametric curves by considering x(t) and y(t) separately

Parameterizations for Piecewise Polynomials

Given ordered (xi,yi) point data, we don’t yet have a parameterization.