Spline Interpolation and Data Fitting
Learn piecewise polynomial interpolation to avoid Runge's phenomenon, construct smooth cubic splines, and apply least squares methods for data fitting.
- Understand piecewise interpolation and its advantages
- Construct cubic spline interpolating functions
- Apply different boundary conditions for splines
- Formulate and solve least squares fitting problems
- Understand orthogonal polynomials and their properties
- Compare interpolation versus fitting approaches
1. Piecewise Interpolation
High-degree polynomial interpolation can lead to oscillations (Runge's phenomenon). Piecewise interpolation uses low-degree polynomials on each subinterval.
Definition 3.1: Piecewise Polynomial Interpolation
Given a partition , a piecewise polynomial of degree k, denoted , is a function such that on each subinterval, is a polynomial of degree at most .
Example: Piecewise Linear Interpolation
On each subinterval :
Theorem 3.1: Piecewise Linear Error
If , the error in piecewise linear interpolation satisfies:
where .
Definition 3.2: Piecewise Cubic Hermite Interpolation
On each subinterval , use a cubic polynomial matching.
Error:
2. Cubic Spline Interpolation
Definition 3.3: Cubic Spline
A cubic spline on with nodes satisfies:
- for (interpolation)
- is a cubic polynomial on each
- (continuous second derivative)
Definition 3.4: Boundary Conditions
Common boundary conditions for cubic splines:
- Natural (Free):
- Clamped:
- Periodic:
Theorem 3.2: Spline System
Let and . The spline conditions give a tridiagonal system:
where and depends on the function values.
Note:
The tridiagonal system can be solved efficiently in time using theThomas algorithm (tridiagonal matrix algorithm).
Remark:
Cubic splines are widely used in computer graphics, CAD systems, and data visualization because they provide smooth curves with minimal oscillation.
3. Least Squares Fitting
Unlike interpolation (which passes through all points), fitting finds a function that best approximates the data in some sense, allowing for measurement errors.
Definition 3.5: Least Squares Problem
Given data for , find parameters for that minimize:
Theorem 3.3: Normal Equations
Setting partial derivatives to zero gives the normal equations. In matrix form with and :
The solution is .
Example: Linear Regression
For data :
Design matrix:
Normal equations: ,
Solution: , so
Definition 3.6: General Least Squares
For fitting where are basis functions:
where are weights.
4. Best Approximation
Definition 3.7: Best Square Approximation
For continuous functions with inner product , find minimizing:
Remark:
The Gram matrix for polynomial approximation on with is theHilbert matrix:
This matrix is extremely ill-conditioned, making the problem numerically unstable.
5. Orthogonal Polynomials
Using orthogonal polynomials as basis functions eliminates the ill-conditioning problem.
Definition 3.8: Orthogonal Polynomials
Polynomials are orthogonal on with weight if:
Legendre Polynomials
Orthogonal on with :
Recurrence:
Chebyshev Polynomials
Orthogonal on with :
Recurrence:
Laguerre Polynomials
Orthogonal on with :
Theorem 3.4: Three-Term Recurrence
Any sequence of orthogonal polynomials satisfies a three-term recurrence relation:
where and.
Practice Quiz
Frequently Asked Questions
What's the difference between interpolation and fitting?
Interpolation passes exactly through all data points, whilefitting finds the best approximation that may not pass through any point.
Use interpolation when data is exact; use fitting when data contains measurement errors.
Why are cubic splines preferred over higher-degree splines?
Cubic splines provide a good balance: they're smooth enough ( continuity) for most applications while avoiding the oscillations of higher-degree polynomials. They also have the minimum curvature property among all interpolating curves.
When should I use clamped vs natural boundary conditions?
Clamped (specified derivatives): When you know the slopes at endpoints, such as from physical constraints or additional measurements.
Natural (zero second derivatives): When no endpoint information is available. The spline behaves like a physical spline that relaxes at the ends.
Why use orthogonal polynomials for fitting?
Orthogonal polynomials diagonalize the Gram matrix, eliminating the ill-conditioning problem. Each coefficient can be computed independently, and adding higher-degree terms doesn't change previously computed coefficients.
How do I choose between different orthogonal polynomial families?
Choose based on the domain and weight function that matches your problem:
- Legendre: Uniform weight on finite interval
- Chebyshev: Minimizes maximum error, good for uniform approximation
- Laguerre: Semi-infinite domain with exponential decay
- Hermite: Entire real line with Gaussian weight