Copyleft 2005 by MediaLab Chapter 8 Interpolation (1)
Copyleft 2005 by MediaLab Table of Contents 8.1 Polynomial Interpolation Lagrange Interpolation Newton Interpolation Difficulties with Polynomial Interpolation 8.2 Hermite Interpolation 8.3 Rational-Function Interpolation
Copyleft 2005 by MediaLab Lagrange Interpolation Polynomials Basic concept The Lagrange interpolating polynomial is the polynomial of degree n-1 that passes through the n points. Using given several point, we can find Lagrange interpolation polynomial.
Copyleft 2005 by MediaLab General Form of Lagrange The general form of the polynomial is p(x) = L 1 y 1 + L 2 y 2 + … + L n y n where the given points are (x 1,y 1 ), ….., (x n,y n ). The equation of the line passing through two points (x 1,y 1 ) and (x 2,y 2 ) is The equation of the parabola passing through three points (x 1,y 1 ), (x 2,y 2 ), and (x 3,y 3 ) is
Copyleft 2005 by MediaLab Example of Lagrange Interpolation Example Given points (x 1,y 1 )=(-2,4), (x 2,y 2 )=(0,2), (x 3,y 3 )=(2,8)
Copyleft 2005 by MediaLab MATLAB Function for Lagrange Interpolation We can represent the Lagrange polynomial with coefficient c k. p(x)=c 1 N 1 +c 2 N 2 + … +c n N n
Copyleft 2005 by MediaLab Higher Order Interpolation Polynomials Higher order interpolation polynomials x = [ ], y = [ ]
Copyleft 2005 by MediaLab Review and Discussion In Lagrange interpolation polynomial, it always go through given points. Think with equation below The Lagrange form of polynomial is convenient when the same abscissas may occur in different applications. It is less convenient than the Newton form when additional data points may be added to the problem.
Copyleft 2005 by MediaLab Newton form of the equation of a straight line passing through two points (x 1, y 1 ) and (x 2, y 2 ) is Newton form of the equation of a parabola passing through three points (x 1, y 1 ), (x 2, y 2 ), and (x 3, y 3 ) is the general form of the polynomial passing through n points (x 1, y 1 ), …,(x n, y n ) is Newton Interpolation Polynomials
Copyleft 2005 by MediaLab Substituting (x 1, y 1 ) into Substituting (x 2, y 2 ) into Substituting (x 3, y 3 ) into Newton Interpolation Polynomials (cont’d)
Copyleft 2005 by MediaLab Newton Interpolation Parabola Passing through the points (x 1, y 1 )=(-2, 4), (x 2, y 2 )=(0, 2), and (x 3, y 3 )=(2, 8). The equations is Where the coefficients are thus
Copyleft 2005 by MediaLab Newton Interpolation Parabola (cont’d) Passing through the points (x 1, y 1 )=(-2, 4), (x 2, y 2 )=(0, 2), and (x 3, y 3 )=(2, 8).
Copyleft 2005 by MediaLab Additional Data Points We extend the previous example, adding the points (x 4, y 4 ) = (-1, -1) and (x 5, y 5 ) = (1, 1) Divided-difference table becomes (with new entries shown in bold) Newton interpolation polynomial is
Copyleft 2005 by MediaLab Consider again the data from Example 8.4 with Lagrange form. x = [ ], y = [ ] Higher Order Interpolation Polynomials Do it again with Newton form. That the polynomial is cubic is clear.
Copyleft 2005 by MediaLab Higher Order Interpolation Polynomials (cont’d) If the y values are modified slightly, the divided-difference table shows the small contribution from the higher degree terms:
Copyleft 2005 by MediaLab MATLAB functions – Finding the coefficients function a = Newton_Coef(x, y) n = length(x); %Calculate coeffiecients of Newton interpolating polynomial a(1) = y(1); for k=1 : n-1 d(k,1) = (y(k+1) - y(k))/(x(k+1) - x(k)); %1st divided diff end for j=2 : n-1 for k=1 : n-j d(k,j) = (d(k+1,j-1) - d(k,j-1))/(x(k+j) - x(k)); %jth divided diff end d for j=2:n a(j) = d(1, j-1); end >> x = [ ]; >> y = [ ]; >> Newton_Coef(x,y); d = >>
Copyleft 2005 by MediaLab MATLAB functions – Evaluate the polynomials function p = Newton_Eval(t,x,a) % t : input value of the polynomial (x) % x : x values of interpolating points % a : answer of previous MATLAB function, i.e, the coefficients of Newton polynomial. n = length(x); hold on; for i =1 : length(t) ddd(1) = 1; %Compute first term c(1) = a(1); for j=2 : n ddd(j) = (t(i) - x(j-1)).*ddd(j-1); % Compute jth term c(j) = a(j).*ddd(j); end; p(i) = sum(c); %plot(t(i),p(i)); grid on; end t p >> a = [ ]; >> x = [ ]; >> t = [0 1 2]; >> Newton_Eval(t, x, a); t = p =
Copyleft 2005 by MediaLab The data x = [ – ] y = [ ] illustrate the difficulty with using higher order polynomials to interpolate a moderately large number of points. Humped and Flat Data
Copyleft 2005 by MediaLab The data x = [ ] y = [ ] Not well suited with noisy straight line. Noisy Straight Line
Copyleft 2005 by MediaLab Runge Function The function is a famous example of the fact that polynomial interpolation does not produce a good approximation for some functions and that using more function values (at evenly spaced x values) does not necessarily improve the situation. Example 1. x = [ ] y = [ ]
Copyleft 2005 by MediaLab Example 2. x = [ ] y = [ ] The interpolation polynomial overshoots the true polynomial much more severely than the polynomial formed by using only five points. Runge Function (cont’d)
Copyleft 2005 by MediaLab Hermite Interpolation
Copyleft 2005 by MediaLab Hermite Interpolation Hermite interpolation allows us to find a ploynomial that matched both function value and some of the derivative values
Copyleft 2005 by MediaLab More data for Product concentration
Copyleft 2005 by MediaLab MATLAB Code for Hermite interpolation
Copyleft 2005 by MediaLab Difficult Data As with lower order polynomial interpolation, trying to interpolate in humped and flat regions cause overshoots.
Copyleft 2005 by MediaLab Rational-Function Interpolation
Copyleft 2005 by MediaLab Rational-Function Interpolation Why use rational-function interpolation? Some functions are not well approximated by polynomials.(runge-function) but are well approximated by rational functions, that is quotients of polynomials.
Copyleft 2005 by MediaLab Bulirsch-Stoer algorithm Bulirsch-Stoer algorithm The approach is recursive, based on tabulated data(in a manner similar to that for the Newton form of polynomial interpolation). Given a set of m+1 data points (x 1,y 1 ), …, (x m+1, y m+1 ), we seek an interpolation function of the form The proof is in J.Stoer and R.Bulirsch, 'Introduction to Numerical Analysis'
Copyleft 2005 by MediaLab Bulirsch-Stoer algorithm(cont’d) Bulirsch-Stoer method for three data points
Copyleft 2005 by MediaLab Bulirsch-Stoer algorithm(cont’d) Bulirsch-Stoer method for five data points Third stage R 5 =y 5 x 5 y 5 R 4 =y 4 x 4 y 4 R 3 =y 3 x 3 y 3 R 2 = y 2 x 2 y 2 R 1 = y 1 x 1 y 1 Second stage First stagedata
Copyleft 2005 by MediaLab Bulirsch-Stoer algorithm(cont’d) Fifth stage Forth stage
Copyleft 2005 by MediaLab Bulirsch-Stoer Rational-Function(cont’d)
Copyleft 2005 by MediaLab Example 8.13 rational-function interpolation data points: x = [ ] y = [ ]
Copyleft 2005 by MediaLab Example 8.13 rational-function interpolation(cont’d)