16-Splines and Piecewise Interpolation
16-Splines and Piecewise Interpolation
16-Splines and Piecewise Interpolation
Interpolation
ES 204
Numerical Methods in Engineering
What are linear splines?
spline functions - application of lower-order, connecting polynomials in a piecewise fashion
to subsets of data points
First-order splines are not smooth; slope changes abruptly at knots; discontinuous first derivative
Use higher order splines to ensure smoothness
What are quadratic splines?
Derive a second-order polynomial for each interval between data points
n data points, n 1 intervals, 3(n 1) unknown constants
3(n 1) equations/conditions
ai = fi
1. Functions pass through the points 2. first derivatives at the knots are equal
3. second derivatives at the knots are also equal
Natural spline - second derivatives at the first and last knots are equal to zero; straight line at
the end nodes
Other conditions: clamped condition and the not-a-knot conditions
How to derive cubic splines?
1. Spline must pass through all the data points
constant in each cubic must be equal to the value of the dependent variable at
the beginning of the interval
finite differences
Can be written for the interior knots, i = 2, 3, . . . , n 2; gives n 3 simultaneous tridiagonal
equations with n 1 unknown coefficients, c1, c2, . . . , cn-1
We need two more conditions to solve the cs, then determine b and d coefficients
Natural spline - assumes second derivatives at the end knots are equal to zero
Not-a-Knot End Condition - force continuity of the third derivative at the second and the
next-to-last knots; first internal knots no longer represent the junction of two different cubic
functions (no longer true knots)
Use Octaves interp1 function to fit these data with (a) linear interpolation, (b) nearest neighbor,
(c) cubic spline with not-a-knot end conditions, and (d) piecewise cubic Hermite interpolation.
Linear interpolation
Cubic spline
Physically realistic
Hold the y value (y1 and y2) fixed and apply one
dimensional linear interpolation in the x direction