1.
Interpolation Interpolation Polynomial Interpolation Polynomial Interpolation Piecewise Polynomial Interpolation Piecewise Polynomial Interpolation Outline Scientiﬁc Computing: An Introductory Survey Chapter 7 – Interpolation 1 Interpolation Prof. Michael T. Heath 2 Polynomial Interpolation Department of Computer Science University of Illinois at Urbana-Champaign 3 Piecewise Polynomial Interpolation Copyright c 2002. Reproduction permitted for noncommercial, educational use only. Michael T. Heath Scientiﬁc Computing 1 / 56 Michael T. Heath Scientiﬁc Computing 2 / 56 Interpolation Motivation Interpolation Motivation Polynomial Interpolation Choosing Interpolant Polynomial Interpolation Choosing Interpolant Piecewise Polynomial Interpolation Existence and Uniqueness Piecewise Polynomial Interpolation Existence and UniquenessInterpolation Purposes for Interpolation Basic interpolation problem: for given data (t1 , y1 ), (t2 , y2 ), . . . (tm , ym ) with t1 < t2 < · · · < tm determine function f : R → R such that Plotting smooth curve through discrete data points f (ti ) = yi , i = 1, . . . , m Reading between lines of table f is interpolating function, or interpolant, for given data Differentiating or integrating tabular data Additional data might be prescribed, such as slope of Quick and easy evaluation of mathematical function interpolant at given points Replacing complicated function by simple one Additional constraints might be imposed, such as smoothness, monotonicity, or convexity of interpolant f could be function of more than one variable, but we will consider only one-dimensional case Michael T. Heath Scientiﬁc Computing 3 / 56 Michael T. Heath Scientiﬁc Computing 4 / 56 Interpolation Motivation Interpolation Motivation Polynomial Interpolation Choosing Interpolant Polynomial Interpolation Choosing Interpolant Piecewise Polynomial Interpolation Existence and Uniqueness Piecewise Polynomial Interpolation Existence and UniquenessInterpolation vs Approximation Issues in Interpolation Arbitrarily many functions interpolate given set of data points By deﬁnition, interpolating function ﬁts given data points What form should interpolating function have? exactly How should interpolant behave between data points? Interpolation is inappropriate if data points subject to signiﬁcant errors Should interpolant inherit properties of data, such as monotonicity, convexity, or periodicity? It is usually preferable to smooth noisy data, for example by least squares approximation Are parameters that deﬁne interpolating function meaningful? Approximation is also more appropriate for special function libraries If function and data are plotted, should results be visually pleasing? Michael T. Heath Scientiﬁc Computing 5 / 56 Michael T. Heath Scientiﬁc Computing 6 / 56 Interpolation Motivation Interpolation Motivation Polynomial Interpolation Choosing Interpolant Polynomial Interpolation Choosing Interpolant Piecewise Polynomial Interpolation Existence and Uniqueness Piecewise Polynomial Interpolation Existence and UniquenessChoosing Interpolant Functions for Interpolation Families of functions commonly used for interpolation Choice of function for interpolation based on include How easy interpolating function is to work with Polynomials determining its parameters Piecewise polynomials evaluating interpolant Trigonometric functions differentiating or integrating interpolant Exponential functions Rational functions How well properties of interpolant match properties of data to be ﬁt (smoothness, monotonicity, convexity, periodicity, For now we will focus on interpolation by polynomials and etc.) piecewise polynomials We will consider trigonometric interpolation (DFT) later Michael T. Heath Scientiﬁc Computing 7 / 56 Michael T. Heath Scientiﬁc Computing 8 / 56
2.
Interpolation Motivation Interpolation Motivation Polynomial Interpolation Choosing Interpolant Polynomial Interpolation Choosing Interpolant Piecewise Polynomial Interpolation Existence and Uniqueness Piecewise Polynomial Interpolation Existence and UniquenessBasis Functions Existence, Uniqueness, and Conditioning Family of functions for interpolating given data points is spanned by set of basis functions φ1 (t), . . . , φn (t) Existence and uniqueness of interpolant depend on Interpolating function f is chosen as linear combination of number of data points m and number of basis functions n basis functions, n If m > n, interpolant usually doesn’t exist f (t) = xj φj (t) j=1 If m < n, interpolant is not unique Requiring f to interpolate data (ti , yi ) means If m = n, then basis matrix A is nonsingular provided data n points ti are distinct, so data can be ﬁt exactly f (ti ) = xj φj (ti ) = yi , i = 1, . . . , m j=1 Sensitivity of parameters x to perturbations in data depends on cond(A), which depends in turn on choice of which is system of linear equations Ax = y for n-vector x basis functions of parameters xj , where entries of m × n matrix A are given by aij = φj (ti ) Michael T. Heath Scientiﬁc Computing 9 / 56 Michael T. Heath Scientiﬁc Computing 10 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergencePolynomial Interpolation Monomial Basis Monomial basis functions Simplest and most common type of interpolation uses φj (t) = tj−1 , j = 1, . . . , n polynomials give interpolating polynomial of form Unique polynomial of degree at most n − 1 passes through pn−1 (t) = x1 + x2 t + · · · + xn tn−1 n data points (ti , yi ), i = 1, . . . , n, where ti are distinct with coefﬁcients x given by n × n linear system There are many ways to represent or compute interpolating polynomial, but in theory all must give same result 1 t1 · · · tn−1 1 x1 y1 1 t2 · · · tn−1 x2 y2 2 < interactive example > Ax = . . . . . = . = y . . . . .. . . . . . . 1 tn · · · tn−1 n xn yn Matrix of this form is called Vandermonde matrix Michael T. Heath Scientiﬁc Computing 11 / 56 Michael T. Heath Scientiﬁc Computing 12 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceExample: Monomial Basis Monomial Basis, continued Determine polynomial of degree two interpolating three data points (−2, −27), (0, −1), (1, 0) Using monomial basis, linear system is 1 t1 t2 1 x1 y1 Ax = 1 t2 t2 2 x = y = y 2 2 1 t3 t2 3 x3 y3 For these particular data, system is 1 −2 4 x1 −27 1 0 0 x2 = −1 < interactive example > 1 1 1 x3 0 whose solution is x = −1 5 −4 , so interpolating T Solving system Ax = y using standard linear equation polynomial is solver to determine coefﬁcients x of interpolating p2 (t) = −1 + 5t − 4t2 polynomial requires O(n3 ) work Michael T. Heath Scientiﬁc Computing 13 / 56 Michael T. Heath Scientiﬁc Computing 14 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceMonomial Basis, continued Monomial Basis, continued For monomial basis, matrix A is increasingly ill-conditioned Conditioning with monomial basis can be improved by as degree increases shifting and scaling independent variable t j−1 Ill-conditioning does not prevent ﬁtting data points well, t−c φj (t) = since residual for linear system solution will be small d where, c = (t1 + tn )/2 is midpoint and d = (tn − t1 )/2 is But it does mean that values of coefﬁcients are poorly half of range of data determined New independent variable lies in interval [−1, 1], which also Both conditioning of linear system and amount of helps avoid overﬂow or harmful underﬂow computational work required to solve it can be improved by using different basis Even with optimal shifting and scaling, monomial basis usually is still poorly conditioned, and we must seek better Change of basis still gives same interpolating polynomial alternatives for given data, but representation of polynomial will be different < interactive example > Michael T. Heath Scientiﬁc Computing 15 / 56 Michael T. Heath Scientiﬁc Computing 16 / 56
3.
Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceEvaluating Polynomials Lagrange Interpolation When represented in monomial basis, polynomial For given set of data points (ti , yi ), i = 1, . . . , n, Lagrange n−1 basis functions are deﬁned by pn−1 (t) = x1 + x2 t + · · · + xn t n n can be evaluated efﬁciently using Horner’s nested j (t) = (t − tk ) / (tj − tk ), j = 1, . . . , n evaluation scheme k=1,k=j k=1,k=j pn−1 (t) = x1 + t(x2 + t(x3 + t(· · · (xn−1 + txn ) · · · ))) For Lagrange basis, which requires only n additions and n multiplications 1 if i = j j (ti ) = , i, j = 1, . . . , n 0 if i = j For example, so matrix of linear system Ax = y is identity matrix 1 − 4t + 5t2 − 2t3 + 3t4 = 1 + t(−4 + t(5 + t(−2 + 3t))) Thus, Lagrange polynomial interpolating data points (ti , yi ) Other manipulations of interpolating polynomial, such as is given by differentiation or integration, are also relatively easy with monomial basis representation pn−1 (t) = y1 1 (t) + y2 2 (t) + · · · + yn n (t) Michael T. Heath Scientiﬁc Computing 17 / 56 Michael T. Heath Scientiﬁc Computing 18 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceLagrange Basis Functions Example: Lagrange Interpolation Use Lagrange interpolation to determine interpolating polynomial for three data points (−2, −27), (0, −1), (1, 0) Lagrange polynomial of degree two interpolating three points (t1 , y1 ), (t2 , y2 ), (t3 , y3 ) is given by p2 (t) = (t − t2 )(t − t3 ) (t − t1 )(t − t3 ) (t − t1 )(t − t2 ) y1 + y2 + y3 (t1 − t2 )(t1 − t3 ) (t2 − t1 )(t2 − t3 ) (t3 − t1 )(t3 − t2 ) < interactive example > Lagrange interpolant is easy to determine but more For these particular data, this becomes expensive to evaluate for given argument, compared with t(t − 1) (t + 2)(t − 1) monomial basis representation p2 (t) = −27 + (−1) (−2)(−2 − 1) (2)(−1) Lagrangian form is also more difﬁcult to differentiate, integrate, etc. Michael T. Heath Scientiﬁc Computing 19 / 56 Michael T. Heath Scientiﬁc Computing 20 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceNewton Interpolation Newton Basis Functions For given set of data points (ti , yi ), i = 1, . . . , n, Newton basis functions are deﬁned by j−1 πj (t) = (t − tk ), j = 1, . . . , n k=1 where value of product is taken to be 1 when limits make it vacuous Newton interpolating polynomial has form pn−1 (t) = x1 + x2 (t − t1 ) + x3 (t − t1 )(t − t2 ) + · · · + xn (t − t1 )(t − t2 ) · · · (t − tn−1 ) < interactive example > For i < j, πj (ti ) = 0, so basis matrix A is lower triangular, where aij = πj (ti ) Michael T. Heath Scientiﬁc Computing 21 / 56 Michael T. Heath Scientiﬁc Computing 22 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceNewton Interpolation, continued Example: Newton Interpolation Use Newton interpolation to determine interpolating polynomial for three data points (−2, −27), (0, −1), (1, 0) Using Newton basis, linear system is Solution x to system Ax = y can be computed by 1 0 0 x1 y1 forward-substitution in O(n2 ) arithmetic operations 1 t2 − t1 0 x2 = y2 Moreover, resulting interpolant can be evaluated efﬁciently 1 t3 − t1 (t3 − t1 )(t3 − t2 ) x3 y3 for any argument by nested evaluation scheme similar to For these particular data, system is Horner’s method 1 0 0 x1 −27 Newton interpolation has better balance between cost of 1 2 0 x2 = −1 computing interpolant and cost of evaluating it 1 3 3 x3 0 whose solution by forward substitution is T x = −27 13 −4 , so interpolating polynomial is p(t) = −27 + 13(t + 2) − 4(t + 2)t Michael T. Heath Scientiﬁc Computing 23 / 56 Michael T. Heath Scientiﬁc Computing 24 / 56
4.
Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceNewton Interpolation, continued Divided Differences If pj (t) is polynomial of degree j − 1 interpolating j given Given data points (ti , yi ), i = 1, . . . , n, divided differences, points, then for any constant xj+1 , denoted by f [ ], are deﬁned recursively by pj+1 (t) = pj (t) + xj+1 πj+1 (t) f [t2 , t3 , . . . , tk ] − f [t1 , t2 , . . . , tk−1 ] is polynomial of degree j that also interpolates same j f [t1 , t2 , . . . , tk ] = tk − t1 points where recursion begins with f [tk ] = yk , k = 1, . . . , n Free parameter xj+1 can then be chosen so that pj+1 (t) interpolates yj+1 , Coefﬁcient of jth basis function in Newton interpolant is yj+1 − pj (tj+1 ) given by xj+1 = xj = f [t1 , t2 , . . . , tj ] πj+1 (tj+1 ) Newton interpolation begins with constant polynomial Recursion requires O(n2 ) arithmetic operations to compute p1 (t) = y1 interpolating ﬁrst data point and then coefﬁcients of Newton interpolant, but is less prone to successively incorporates each remaining data point into overﬂow or underﬂow than direct formation of triangular interpolant < interactive example > Newton basis matrix Michael T. Heath Scientiﬁc Computing 25 / 56 Michael T. Heath Scientiﬁc Computing 26 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceOrthogonal Polynomials Orthogonal Polynomials, continued Inner product can be deﬁned on space of polynomials on For example, with inner product given by weight function interval [a, b] by taking w(t) ≡ 1 on interval [−1, 1], applying Gram-Schmidt b process to set of monomials 1, t, t2 , t3 , . . . yields Legendre p, q = p(t)q(t)w(t)dt polynomials a where w(t) is nonnegative weight function 1, t, (3t2 − 1)/2, (5t3 − 3t)/2, (35t4 − 30t2 + 3)/8, Two polynomials p and q are orthogonal if p, q = 0 (63t5 − 70t3 + 15t)/8, . . . Set of polynomials {pi } is orthonormal if ﬁrst n of which form an orthogonal basis for space of 1 if i = j polynomials of degree at most n − 1 pi , p j = 0 otherwise Other choices of weight functions and intervals yield other Given set of polynomials, Gram-Schmidt orthogonalization orthogonal polynomials, such as Chebyshev, Jacobi, can be used to generate orthonormal set spanning same Laguerre, and Hermite space Michael T. Heath Scientiﬁc Computing 27 / 56 Michael T. Heath Scientiﬁc Computing 28 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceOrthogonal Polynomials, continued Chebyshev Polynomials kth Chebyshev polynomial of ﬁrst kind, deﬁned on interval Orthogonal polynomials have many useful properties [−1, 1] by Tk (t) = cos(k arccos(t)) They satisfy three-term recurrence relation of form are orthogonal with respect to weight function (1 − t2 )−1/2 pk+1 (t) = (αk t + βk )pk (t) − γk pk−1 (t) First few Chebyshev polynomials are given by which makes them very efﬁcient to generate and evaluate 1, t, 2t2 − 1, 4t3 − 3t, 8t4 − 8t2 + 1, 16t5 − 20t3 + 5t, . . . Orthogonality makes them very natural for least squares approximation, and they are also useful for generating Equi-oscillation property : successive extrema of Tk are Gaussian quadrature rules, which we will see later equal in magnitude and alternate in sign, which distributes error uniformly when approximating arbitrary continuous function Michael T. Heath Scientiﬁc Computing 29 / 56 Michael T. Heath Scientiﬁc Computing 30 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceChebyshev Basis Functions Chebyshev Points Chebyshev points are zeros of Tk , given by (2i − 1)π ti = cos , i = 1, . . . , k 2k or extrema of Tk , given by iπ ti = cos , i = 0, 1, . . . , k k Chebyshev points are abscissas of points equally spaced around unit circle in R2 < interactive example > Chebyshev points have attractive properties for interpolation and other problems Michael T. Heath Scientiﬁc Computing 31 / 56 Michael T. Heath Scientiﬁc Computing 32 / 56
5.
Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceInterpolating Continuous Functions Interpolating Continuous Functions, continued If data points are discrete sample of continuous function, how well does interpolant approximate that function If |f (n) (t)| ≤ M for all t ∈ [t1 , tn ], and between sample points? h = max{ti+1 − ti : i = 1, . . . , n − 1}, then If f is smooth function, and pn−1 is polynomial of degree at M hn most n − 1 interpolating f at n points t1 , . . . , tn , then max |f (t) − pn−1 (t)| ≤ t∈[t1 ,tn ] 4n f (n) (θ) f (t) − pn−1 (t) = (t − t1 )(t − t2 ) · · · (t − tn ) Error diminishes with increasing n and decreasing h, but n! only if |f (n) (t)| does not grow too rapidly with n where θ is some (unknown) point in interval [t1 , tn ] < interactive example > Since point θ is unknown, this result is not particularly useful unless bound on appropriate derivative of f is known Michael T. Heath Scientiﬁc Computing 33 / 56 Michael T. Heath Scientiﬁc Computing 34 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceHigh-Degree Polynomial Interpolation Convergence Polynomial interpolating continuous function may not Interpolating polynomials of high degree are expensive to converge to function as number of data points and determine and evaluate polynomial degree increases In some bases, coefﬁcients of polynomial may be poorly Equally spaced interpolation points often yield determined due to ill-conditioning of linear system to be unsatisfactory results near ends of interval solved If points are bunched near ends of interval, more High-degree polynomial necessarily has lots of “wiggles,” satisfactory results are likely to be obtained with which may bear no relation to data to be ﬁt polynomial interpolation Polynomial passes through required data points, but it may Use of Chebyshev points distributes error evenly and oscillate wildly between data points yields convergence throughout interval for any sufﬁciently smooth function Michael T. Heath Scientiﬁc Computing 35 / 56 Michael T. Heath Scientiﬁc Computing 36 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Monomial, Lagrange, and Newton Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Orthogonal Polynomials Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Accuracy and ConvergenceExample: Runge’s Function Example: Runge’s Function Polynomial interpolants of Runge’s function at equally Polynomial interpolants of Runge’s function at Chebyshev spaced points do not converge points do converge < interactive example > < interactive example > Michael T. Heath Scientiﬁc Computing 37 / 56 Michael T. Heath Scientiﬁc Computing 38 / 56 Interpolation Monomial, Lagrange, and Newton Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Orthogonal Polynomials Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Accuracy and Convergence Piecewise Polynomial Interpolation Cubic Spline InterpolationTaylor Polynomial Piecewise Polynomial Interpolation Another useful form of polynomial interpolation for smooth Fitting single polynomial to large number of data points is function f is polynomial given by truncated Taylor series likely to yield unsatisfactory oscillating behavior in interpolant f (a) f (n) (a) pn (t) = f (a)+f (a)(t−a)+ (t−a)2 +· · ·+ (t−a)n Piecewise polynomials provide alternative to practical and 2 n! theoretical difﬁculties with high-degree polynomial Polynomial interpolates f in that values of pn and its ﬁrst n interpolation derivatives match those of f and its ﬁrst n derivatives Main advantage of piecewise polynomial interpolation is evaluated at t = a, so pn (t) is good approximation to f (t) that large number of data points can be ﬁt with low-degree for t near a polynomials We have already seen examples in Newton’s method for In piecewise interpolation of given data points (ti , yi ), nonlinear equations and optimization different function is used in each subinterval [ti , ti+1 ] Abscissas ti are called knots or breakpoints, at which < interactive example > interpolant changes from one function to another Michael T. Heath Scientiﬁc Computing 39 / 56 Michael T. Heath Scientiﬁc Computing 40 / 56
6.
Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationPiecewise Interpolation, continued Hermite Interpolation Simplest example is piecewise linear interpolation, in which successive pairs of data points are connected by In Hermite interpolation, derivatives as well as values of straight lines interpolating function are taken into account Although piecewise interpolation eliminates excessive Including derivative values adds more equations to linear oscillation and nonconvergence, it appears to sacriﬁce system that determines parameters of interpolating smoothness of interpolating function function We have many degrees of freedom in choosing piecewise To have unique solution, number of equations must equal polynomial interpolant, however, which can be exploited to number of parameters to be determined obtain smooth interpolating function despite its piecewise nature Piecewise cubic polynomials are typical choice for Hermite interpolation, providing ﬂexibility, simplicity, and efﬁciency < interactive example > Michael T. Heath Scientiﬁc Computing 41 / 56 Michael T. Heath Scientiﬁc Computing 42 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationHermite Cubic Interpolation Cubic Spline Interpolation Hermite cubic interpolant is piecewise cubic polynomial Spline is piecewise polynomial of degree k that is k − 1 interpolant with continuous ﬁrst derivative times continuously differentiable Piecewise cubic polynomial with n knots has 4(n − 1) For example, linear spline is of degree 1 and has 0 parameters to be determined continuous derivatives, i.e., it is continuous, but not smooth, and could be described as “broken line” Requiring that it interpolate given data gives 2(n − 1) equations Cubic spline is piecewise cubic polynomial that is twice continuously differentiable Requiring that it have one continuous derivative gives n − 2 additional equations, or total of 3n − 4, which still leaves n As with Hermite cubic, interpolating given data and free parameters requiring one continuous derivative imposes 3n − 4 constraints on cubic spline Thus, Hermite cubic interpolant is not unique, and remaining free parameters can be chosen so that result Requiring continuous second derivative imposes n − 2 satisﬁes additional constraints additional constraints, leaving 2 remaining free parameters Michael T. Heath Scientiﬁc Computing 43 / 56 Michael T. Heath Scientiﬁc Computing 44 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationCubic Splines, continued Example: Cubic Spline Interpolation Determine natural cubic spline interpolating three data Final two parameters can be ﬁxed in various ways points (ti , yi ), i = 1, 2, 3 Specify ﬁrst derivative at endpoints t1 and tn Required interpolant is piecewise cubic function deﬁned by separate cubic polynomials in each of two intervals [t1 , t2 ] Force second derivative to be zero at endpoints, which and [t2 , t3 ] gives natural spline Denote these two polynomials by Enforce “not-a-knot” condition, which forces two consecutive cubic pieces to be same p1 (t) = α1 + α2 t + α3 t2 + α4 t3 Force ﬁrst derivatives, as well as second derivatives, to p2 (t) = β1 + β2 t + β3 t2 + β4 t3 match at endpoints t1 and tn (if spline is to be periodic) Eight parameters are to be determined, so we need eight equations Michael T. Heath Scientiﬁc Computing 45 / 56 Michael T. Heath Scientiﬁc Computing 46 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationExample, continued Example, continued Requiring ﬁrst cubic to interpolate data at end points of ﬁrst Requiring second derivative of interpolant function to be interval [t1 , t2 ] gives two equations continuous at t2 gives equation α1 + α2 t1 + α3 t2 + α4 t3 = y1 1 1 2α3 + 6α4 t2 = 2β3 + 6β4 t2 α1 + α2 t2 + α3 t2 + α4 t3 = y2 2 2 Requiring second cubic to interpolate data at end points of Finally, by deﬁnition natural spline has second derivative second interval [t2 , t3 ] gives two equations equal to zero at endpoints, which gives two equations β1 + β2 t2 + β3 t2 + β4 t3 = y2 2 2 2α3 + 6α4 t1 = 0 β1 + β2 t3 + β3 t2 3 + β4 t3 3 = y3 2β3 + 6β4 t3 = 0 Requiring ﬁrst derivative of interpolant to be continuous at When particular data values are substituted for ti and yi , t2 gives equation system of eight linear equations can be solved for eight α2 + 2α3 t2 + 3α4 t2 = β2 + 2β3 t2 + 3β4 t2 2 2 unknown parameters αi and βi Michael T. Heath Scientiﬁc Computing 47 / 56 Michael T. Heath Scientiﬁc Computing 48 / 56
7.
Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationHermite Cubic vs Spline Interpolation Hermite Cubic vs Spline Interpolation Choice between Hermite cubic and spline interpolation depends on data to be ﬁt and on purpose for doing interpolation If smoothness is of paramount importance, then spline interpolation may be most appropriate But Hermite cubic interpolant may have more pleasing visual appearance and allows ﬂexibility to preserve monotonicity if original data are monotonic In any case, it is advisable to plot interpolant and data to help assess how well interpolating function captures behavior of original data < interactive example > Michael T. Heath Scientiﬁc Computing 49 / 56 Michael T. Heath Scientiﬁc Computing 50 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationB-splines B-splines, continued B-splines form basis for family of spline functions of given degree To start recursion, deﬁne B-splines of degree 0 by B-splines can be deﬁned in various ways, including 0 1 if ti ≤ t < ti+1 recursion (which we will use), convolution, and divided Bi (t) = 0 otherwise differences Although in practice we use only ﬁnite set of knots and then for k > 0 deﬁne B-splines of degree k by t1 , . . . , tn , for notational convenience we will assume k k k−1 k k−1 inﬁnite set of knots Bi (t) = vi (t)Bi (t) + (1 − vi+1 (t))Bi+1 (t) · · · < t−2 < t−1 < t0 < t1 < t2 < · · · 0 k 1 Since Bi is piecewise constant and vi is linear, Bi is Additional knots can be taken as arbitrarily deﬁned points piecewise linear outside interval [t1 , tn ] 2 Similarly, Bi is in turn piecewise quadratic, and in general, We will also use linear functions k Bi is piecewise polynomial of degree k k vi (t) = (t − ti )/(ti+k − ti ) Michael T. Heath Scientiﬁc Computing 51 / 56 Michael T. Heath Scientiﬁc Computing 52 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationB-splines, continued B-splines, continued k Important properties of B-spline functions Bi 1 k For t < ti or t > ti+k+1 , Bi (t) = 0 2 k For ti < t < ti+k+1 , Bi (t) > 0 ∞ k 3 For all t, i=−∞ Bi (t) =1 4 For k ≥ 1, k Bi has k − 1 continuous derivatives 5 k k Set of functions {B1−k , . . . , Bn−1 } is linearly independent < interactive example > on interval [t1 , tn ] and spans space of all splines of degree k having knots ti Michael T. Heath Scientiﬁc Computing 53 / 56 Michael T. Heath Scientiﬁc Computing 54 / 56 Interpolation Piecewise Polynomial Interpolation Interpolation Piecewise Polynomial Interpolation Polynomial Interpolation Hermite Cubic Interpolation Polynomial Interpolation Hermite Cubic Interpolation Piecewise Polynomial Interpolation Cubic Spline Interpolation Piecewise Polynomial Interpolation Cubic Spline InterpolationB-splines, continued B-splines, continued If we use B-spline basis, linear system to be solved for Properties 1 and 2 together say that B-spline functions spline coefﬁcients will be nonsingular and banded have local support Use of B-spline basis yields efﬁcient and stable methods Property 3 gives normalization for determining and evaluating spline interpolants, and many library routines for spline interpolation are based on Property 4 says that they are indeed splines this approach Property 5 says that for given k, these functions form basis B-splines are also useful in many other contexts, such as for set of all splines of degree k numerical solution of differential equations, as we will see later Michael T. Heath Scientiﬁc Computing 55 / 56 Michael T. Heath Scientiﬁc Computing 56 / 56
Views
Actions
Embeds 0
Report content