![Page 1: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/1.jpg)
Natural Cubic Interpolation
Jingjing Huang
10/24/2012
![Page 2: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/2.jpg)
Interpolation
• Construct a function crosses known points
• Predict the value of unknown points
![Page 3: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/3.jpg)
Interpolation in modeling
3
![Page 4: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/4.jpg)
Interpolation
• Polynomial Interpolation – Same polynomial for all points
– Vandermonde Matrix, ill-conditioned
• Lagrange Form – Hard to evaluate
• Piecewise Interpolation – Different polynomials for each interval
![Page 5: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/5.jpg)
Lagrange form Given k+1 points Define: where
![Page 6: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/6.jpg)
Lagrange form
![Page 7: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/7.jpg)
Lagrange form
• Example: interpolate f(x) = x2, for x = 1,2,3
![Page 8: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/8.jpg)
How to represent models • Specify every point along a model?
– Hard to get precise results
– Too much data, too hard to work with generally
• Specify a model by a small number of “control points”
– Known as a spline curve or just spline
8
![Page 9: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/9.jpg)
Spline Interpolation
• For some cases, polynomials can lead to erroneous results because of round off error and overshoot.
• Alternative approach is to apply lower-order polynomials to subsets of data points. Such connecting polynomials are called spline functions.
9
![Page 10: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/10.jpg)
Spline Interpolation Definition
• Given n+1 distinct knots xi such that:
with n+1 knot values yi find a spline function
with each Si(x) a polynomial of degree at most n.
![Page 11: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/11.jpg)
Tangent
• The derivative of a curve represents the tangent vector to the curve at some point
11
dx
dtt( )
x t( )
![Page 12: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/12.jpg)
(a)Linear spline
– Derivatives are not continuous
– Not smooth
(b) Quadratic spline
– Continuous 1st derivatives
(c) Cubic spline
– Continuous 1st & 2nd derivatives
– Smoother
12
![Page 13: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/13.jpg)
• Why cubic?
– Good enough for some cases
– The degree is not too high to be easily solved
13
![Page 14: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/14.jpg)
Natural Cubic Spline Interpolation
• Si(x) = aix3 + bix
2 + cix + di (Given n points) – 4 Coefficients with n-1 subintervals = 4n-4 equations
– There are 4n-6 conditions
• Interpolation conditions
• Continuity conditions
• Natural Conditions
– S’’(x0) = 0
– S’’(xn) = 0
– O(n3)
![Page 15: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/15.jpg)
Natural Cubic Spline Interpolation
• A clever method
– Construct S(x)
Lagrange Form thought
– Solve tridiagonal matrix
Using decompt & solvet (2-1)
– Evaluate of S(z)
Locate z in some interval (using binary search)
Using Horner’s rule to evaluate
![Page 16: Natural Cubic Interpolation - McMaster Universityqiao/courses/cs4xo3/tutorials/CubicSpline.pdfNatural Cubic Interpolation Jingjing Huang 10/24/2012 . Interpolation •Construct a function](https://reader034.vdocuments.us/reader034/viewer/2022042200/5ea02ee24f178c0f894b7601/html5/thumbnails/16.jpg)
Thanks