Technische Universität München Fakultät für Mathematik Prof. Dr. M. Mehl B. Gatzhammer WT 2012/13 November 22, 2012 Numerical Programming I (for CSE) Tutorial 6: Interpolation I I 1) The Scheme of Aitken and Neville Let p : R → R be a polynomial interpolant with support points Pi = (xi , yi ), i = 0, . . . , n. Compute the value p(2) of the cubic polynomial with support points P0 = (−2, −7), P1 = (−1, 0), P2 = (0, 1), P3 = (1, 2). Use the scheme of Aitken and Neville! I 2) Newton’s Interpolation Formula Let p : R → R be a polynomial interpolant with support points Pi = (xi , yi ), i = 0, . . . , n. Given the support points P0 = (−1, −3), P1 = (1, 1), P2 = (3, −3), find a closed representation of p that is based on (i) Lagrange polynomials, (ii) divided differences (Newton’s interpolation formula). Now, another support point P3 = (0, 0) is added. Find again a closed representation of the polynomial interpolant. Is it possible to use the previous results? I 3) Estimation of the Interpolation Error Let p be a polynomial that interpolates the function f : [0, 1] → R, x 7→ cos(πx) and xk = k/5, k = 0, . . . , 5 the equidistant support abscissas. Estimate the interpolation error at the points x̃1 = 0.1, x̃2 = 0.5, and x̃3 = 0.6. You can use your program of exercise 4 to verify your results. P 4) Implementation of Newton’s Interpolation Formula Develop a program for polynomial interpolation based on Newton’s interpolation formula. (i) Write a function c = interp newton(x,y) that returns the coefficients c = (c0 , c1 , . . . , cn ) of the polynomial interpolant with support abscissas x = (x0 , . . . , xn ) and support ordinates y = (y0 , . . . , yn ). (ii) Write a function yp = eval newton(c,x,xp) that evaluates Newton’s interpolation formula for given coefficients c = (c0 , c1 , . . . , cn ) and support abscissas x = (x0 , . . . , xn ) at a point xp and returns the result yp = p(xp). Think about how to implement the evaluation of p efficiently with only O(n) additions and multiplications. (iii) Test your program with the Runge function f1 : [a, b] → R, x 7→ 1 1 + x2 and n + 1 support points x0 , . . . , xn that are (1) uniformly distributed on [a, b], (2) equal to the Chebyshev points transformed on [a, b]. Run your program for a = −5, b = 5, and n = 20 and interpolate at the nodes xp=[a:1e-3:b]. Plot the results and the interpolation error for both distributions (1) and (2) of the support points. Remark: The Chebyshev points on [−1, 1] are defined by 2k + 1 xk = cos π , k = 0, . . . , n 2(n + 1) and lead to an almost optimal approximation. Use a linear transformation to get them for an arbitrary interval [a, b]. 5) Hermite Interpolation Hermite interpolation is a method of piecewise interpolation that allows us to consider given derivatives y00 , . . . , yn0 at the support points (x0 , y0 ), . . . , (xn , yn ) as well as the support points themselves. In every subinterval [xi , xi+1 ], the function f is approximated by a cubic polynomial p such that p(xi ) = yi , 0 p (xi ) = p(xi+1 ) = yi+1 , yi0 , 0 p (xi+1 ) = (1) 0 yi+1 . (2) Thus, p(x) is continuously differentiable at all points (p ∈ C 1 ). a) Find the Hermite interpolant p(x) in the interval [xi , xi+1 ]. Hint: Use the ansatz p(x) = pi (x), x ∈ [xi , xi+1 ] with pi (x) = ai0 + ai1 x − xi + ai2 hi x − xi hi 2 + ai3 x − xi hi 3 , hi = xi+1 − xi and determine the coefficients ai0 , . . . , ai3 using the interpolation conditions (1), (2). 0 i b) By sorting the result of a) by yi , yi+1 , yi0 , yi+1 and with substitution t = x−x hi , we get another representation of the interpolant p: 0 pi (t) = yi · H0 (t) + yi+1 · H1 (t) + yi0 · hi H2 (t) + yi+1 · hi H3 (t) (3) Find the Hermite functions H0 (t), . . . , H3 (t). P c) Write a function yp = interp hermite(xi,yi,yprime,xp) that computes the value yp = p(xp) of the Hermite interpolant p(x) = pi (x), x ∈ [xi , xi+1 ], given the support abscissas xi = (x0 , . . . , xn ), the support ordinates yi = (y0 , . . . , yn ), and the derivatives yprime = (y00 , . . . , yn0 ). Use equation (3) with Hermite functions H0 (t) = 1 − 3t2 + 2t3 , H2 (t) = t − 2t2 + t3 , H1 (t) = 3t2 − 2t3 , H3 (t) = −t2 + t3 . Test your program with the interpolation problem of exercise 4.
© Copyright 2026 Paperzz