Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyleft  2005 by MediaLab 1 1-1 Chapter 8 Interpolation (1)

Similar presentations


Presentation on theme: "Copyleft  2005 by MediaLab 1 1-1 Chapter 8 Interpolation (1)"— Presentation transcript:

1 Copyleft  2005 by MediaLab 1 1-1 Chapter 8 Interpolation (1)

2 Copyleft  2005 by MediaLab 2 1-2 Table of Contents  8.1 Polynomial Interpolation  8.1.1 Lagrange Interpolation  8.1.2 Newton Interpolation  8.1.3 Difficulties with Polynomial Interpolation  8.2 Hermite Interpolation  8.3 Rational-Function Interpolation

3 Copyleft  2005 by MediaLab 3 1-3 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.

4 Copyleft  2005 by MediaLab 4 1-4 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   http://math.fullerton.edu/mathews/n2003/lagrangepoly/LagrangePolyProof.pdf

5 Copyleft  2005 by MediaLab 5 1-5 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) 

6 Copyleft  2005 by MediaLab 6 1-6 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 

7 Copyleft  2005 by MediaLab 7 1-7 Higher Order Interpolation Polynomials  Higher order interpolation polynomials x = [ -2 -1 0 1 2 3 4], y = [ -15 0 3 0 -3 0 15]

8 Copyleft  2005 by MediaLab 8 1-8 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.

9 Copyleft  2005 by MediaLab 9 1-9  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

10 Copyleft  2005 by MediaLab 10 1-10  Substituting (x 1, y 1 ) into  Substituting (x 2, y 2 ) into  Substituting (x 3, y 3 ) into Newton Interpolation Polynomials (cont’d)

11 Copyleft  2005 by MediaLab 11 1-11 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

12 Copyleft  2005 by MediaLab 12 1-12 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).

13 Copyleft  2005 by MediaLab 13 1-13 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

14 Copyleft  2005 by MediaLab 14 1-14  Consider again the data from Example 8.4 with Lagrange form. x = [ -2 -1 0 1 2 3 4 ], y = [ -15 0 3 0 -3 0 15] Higher Order Interpolation Polynomials  Do it again with Newton form. That the polynomial is cubic is clear.

15 Copyleft  2005 by MediaLab 15 1-15 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:

16 Copyleft  2005 by MediaLab 16 1-16 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 = [-2 -1 0 1 2 3 4]; >> y = [-15 0 3 0 -3 0 15]; >> Newton_Coef(x,y); d = 15 -6 1 0 0 0 3 -3 1 0 0 0 -3 0 1 0 0 0 -3 3 1 0 0 0 3 6 0 0 0 0 15 0 0 0 0 0 >>

17 Copyleft  2005 by MediaLab 17 1-17 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 = [-15 15 -6 1 0 0 0]; >> x = [-2 -1 0 1 2 3 4]; >> t = [0 1 2]; >> Newton_Eval(t, x, a); t = 0 1 2 p = 3 0 -3

18 Copyleft  2005 by MediaLab 18 1-18  The data  x = [ -2 -1.5 -1 -0.5 0 – 0.5 1 1.5 2]  y = [ 0 0 0 0.87 1 0.87 0 0 0] illustrate the difficulty with using higher order polynomials to interpolate a moderately large number of points. Humped and Flat Data

19 Copyleft  2005 by MediaLab 19 1-19  The data  x = [ 0.00 0.20 0.80 1.00 1.20 1.90 2.00 2.10 2.95 3.00]  y = [ 0.01 0.22 0.76 1.03 1.18 1.94 2.01 2.08 2.90 2.95]  Not well suited with noisy straight line. Noisy Straight Line

20 Copyleft  2005 by MediaLab 20 1-20 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 = [ -1 -0.5 0.0 0.5 1.0 ]  y = [0.0385 0.1379 1.0000 0.1379 0.0385]

21 Copyleft  2005 by MediaLab 21 1-21  Example 2.  x = [-1.000 -0.750 -0.500 -0.250 0.000 0.250 0.500 0.750 1.000 ]  y = [0.0385 0.0664 0.138 0.3902 1.000 0.3902 0.138 0.0664 0.0385]  The interpolation polynomial overshoots the true polynomial much more severely than the polynomial formed by using only five points. Runge Function (cont’d)

22 Copyleft  2005 by MediaLab 22 1-22 8.2 Hermite Interpolation

23 Copyleft  2005 by MediaLab 23 1-23 Hermite Interpolation  Hermite interpolation allows us to find a ploynomial that matched both function value and some of the derivative values

24 Copyleft  2005 by MediaLab 24 1-24 More data for Product concentration

25 Copyleft  2005 by MediaLab 25 1-25 MATLAB Code for Hermite interpolation

26 Copyleft  2005 by MediaLab 26 1-26 Difficult Data  As with lower order polynomial interpolation, trying to interpolate in humped and flat regions cause overshoots.

27 Copyleft  2005 by MediaLab 27 1-27 8.3 Rational-Function Interpolation

28 Copyleft  2005 by MediaLab 28 1-28 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.

29 Copyleft  2005 by MediaLab 29 1-29 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'

30 Copyleft  2005 by MediaLab 30 1-30 Bulirsch-Stoer algorithm(cont’d) Bulirsch-Stoer method for three data points

31 Copyleft  2005 by MediaLab 31 1-31 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

32 Copyleft  2005 by MediaLab 32 1-32 Bulirsch-Stoer algorithm(cont’d) Fifth stage Forth stage

33 Copyleft  2005 by MediaLab 33 1-33 Bulirsch-Stoer Rational-Function(cont’d)

34 Copyleft  2005 by MediaLab 34 1-34 Example 8.13 rational-function interpolation data points: x = [-1-0.5 0.00.51.0] y = [0.03850.1379 1.00000.13790.0385]

35 Copyleft  2005 by MediaLab 35 1-35 Example 8.13 rational-function interpolation(cont’d)


Download ppt "Copyleft  2005 by MediaLab 1 1-1 Chapter 8 Interpolation (1)"

Similar presentations


Ads by Google