Spline Interpolation
A Primer on the Basicsby
Don Allen
What are Splines?
• Splines interpolate data.• Lower degree curves are used.• Thus fewer points must be used.
Consequently, we obtain a piecewise curve, valid only over a specific interval.
• Splines allow matching conditions – not unlike Hermite interpolation – but different
Data: x i, y i, i 0, 1, , n
Linear SplineData: x i, y i, i 0, 1, , n
The Linear Spline
Data: x i, y i, i 0, 1, , n
Piecewise Polynomials
Linear Splines
Quadratic SplineData: x i, y i, i 0, 1, , n
Cubic SplineTo fit cubics to groups of four points.
Rarely done
Data: x i, y i, i 0, 1, , n
Cubic SplineTo fit cubics to successive pairs of points, with matching conditions.
Data: x i, y i, i 0, 1, , n
How it looks
Data: x i, y i, i 0, 1, , n
Splines vs. Polynomials
• Remember the function →•This function interpolated poorly at equally spaced points.
•Let’s compare with how well the natural cubic spline performs.
fx 1
1 5x 2
Function and Interpolant
12 equally spaced pointsFunction in RedInterpolant in blue
Function and Cubic Spline
12 equally spaced points;Function in RedSpline in blue
Function, Interpolant, Cubic Spline
12 equally spaced points;Function in GreenSpline in RedInterpolant in Blue
Cubic Spline – the equations
Cubic Spines
• Two types: both involve endpoint conditions– Natural S’’(endpoints) = 0– Clamped S’(endpoints) = f’(endpoints)
• The error in interpolating a function with a clamped cubic spline depends on the fourth derivative.
Cubic Spline – derivation
Cubic Splines
• There are natural and clamped types• They are very accurate in practice.• They avoid most of the pitfalls of general
polynomial interpolation.• It is remarkably easy to program for the
coefficients. • The error depends on the second derivative.• Full details are in the text and lecture notes.
Another Nasty Example
Another Nasty Example
Another Nasty Example
Another Nasty Example