Interpolation Gerald Recktenwald Portland State University Mechanical Engineering Department gerry@me.pdx.edu These slides are a supplement to the book Numerical Methods with Matlab : Implementations and Applications , by Gerald W. Recktenwald, c c � 2002, Prentice-Hall, Upper Saddle River, NJ. These slides are � 2002 Gerald W. Recktenwald. The PDF version of these slides may be downloaded or stored or printed only for noncommercial, educational use. The repackaging or sale of these slides in any form, without written consent of the author, is prohibited. The latest version of this PDF file, along with other supplemental material for the book, can be found at www.prenhall.com/recktenwald . Version 0.01 March 9, 2002
Primary Topics • Interpolating polynomials of arbitrary degree ⊲ Monomial basis ⊲ Lagrange basis ⊲ Newton basis • Piecewise polynomial interpolation ⊲ Linear ⊲ Hermite polynomials ⊲ Cubic splines • Matlab ’s built-in interpolation routines NMM: Interpolation page 1
Figure 10.2 12 11 1 10 2 9 3 8 0 0 1 0 6 0 1 0 2 4 4 8 0 1 0 kmh 4 2 7 5 0 6 NMM: Interpolation page 2
Figure 10.3 12 10 Viscosity (N ⋅ s)/m 2 8 6 4 2 0 0 10 20 30 40 50 Temperature (C) NMM: Interpolation page 3
Figure 10.4 known data y curve fit interpolation x NMM: Interpolation page 4
Figure 10.5 y 3 y 2 y 2 y 1 y 1 x 1 x 2 x 1 x 2 x 3 NMM: Interpolation page 5
Figure 10.6 30 historic data linear quadratic cubic 25 spline 20 Millions of passengers ? 15 10 5 0 1980 1985 1990 1995 2000 2005 2010 NMM: Interpolation page 6
Figure 10.7 145 140 gasoline price, (cents) 135 130 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 year NMM: Interpolation page 7
Figure 10.8 145 140 gasoline price, (cents) 135 130 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 year NMM: Interpolation page 8
Figure 10.9 y 2 1 L 1 ( x ) L 2 ( x ) y 1 0 0 x 1 x 2 x 1 x 2 NMM: Interpolation page 9
Figure 10.10 degree 1 degree 2 1.5 1.5 1 1 0.5 0.5 0 0 -0.5 -0.5 1 2 3 4 5 1 2 3 4 5 degree 3 degree 4 1.5 1.5 1 1 0.5 0.5 0 0 -0.5 -0.5 1 2 3 4 5 1 2 3 4 5 NMM: Interpolation page 10
Table 10.1 x i f [ ] f [,] f [,,] f [,,,] x 1 f [ x 1 ] x 2 f [ x 2 ] f [ x 1 , x 2 ] x 3 f [ x 3 ] f [ x 2 , x 3 ] f [ x 1 , x 2 , x 3 ] x 4 f [ x 4 ] f [ x 3 , x 4 ] f [ x 2 , x 3 , x 4 ] f [ x 1 , x 2 , x 3 , x 4 ] NMM: Interpolation page 11
Diagonals of Divided-Difference Table x i f [ ] f [,] f [,,] f [,,,] x 1 c 1 x 2 c 2 c 2 x 3 c 3 c 3 c 3 x 4 c 4 c 4 c 4 c 4 NMM: Interpolation page 12
Figure 10.11 6 10 monomial Lagrange Newton 5 10 4 10 Flops 3 10 2 10 1 10 0 1 2 3 10 10 10 10 Number of points to interpolate NMM: Interpolation page 13
Figure 10.12 5 5 0 0 -5 -5 0 2 4 6 8 10 0 2 4 6 8 10 5 5 0 0 -5 -5 0 2 4 6 8 10 0 2 4 6 8 10 5 5 0 0 -5 -5 0 2 4 6 8 10 0 2 4 6 8 10 5 5 0 0 -5 -5 0 2 4 6 8 10 0 5 10 NMM: Interpolation page 14
Figure 10.13 2 1.5 1 0.5 0 0 1 2 3 4 5 6 2 1.5 1 0.5 0 0 1 2 3 4 5 6 2 1 0 0 1 2 3 4 5 6 NMM: Interpolation page 15
Figure 10.14 ' f i +2 , f i +2 ' f i +1 , f i +1 P i +1 ( x ) P i ( x ) f i , f i ' x i x i +1 x i +2 NMM: Interpolation page 16
Figure 10.15 P P 4 ( x ) 5 ( x ) P 3 ( x ) P 2 ( x ) P 1 ( x ) x 1 x 2 x 3 x 4 x 5 x 6 ˆ x NMM: Interpolation page 17
Figure 10.16 0.5 0.5 Given Given x*exp(-x) x*exp(-x) 0.4 0.4 Hermite Hermite 0.3 0.3 0.2 0.2 4 knots 6 knots 0.1 0.1 0 0 0 2 4 6 8 0 2 4 6 8 0.5 0.5 Given Given x*exp(-x) x*exp(-x) 0.4 0.4 Hermite Hermite 0.3 0.3 0.2 8 knots 0.2 12 knots 0.1 0.1 0 0 0 2 4 6 8 0 2 4 6 8 NMM: Interpolation page 18
Figure 10.17 segments coupled ´´ ´´ by P i –1 ( x i ) = P i ( x i ) P n –2 ( x ) P P 2 ( x ) n –1 ( x ) P i –1 ( x ) P P 1 ( x ) i ( x ) x 1 x 2 x 3 x i –1 x i x i +1 x n– 2 x n– 1 x n NMM: Interpolation page 19
Figure 10.18 no curvature no curvature NMM: Interpolation page 20
Figure 10.19 Natural end conditions Zero slope end conditions 0.5 0.5 knots knots spline spline 0.4 0.4 x*exp(-x) x*exp(-x) 0.3 0.3 0.2 0.2 0.1 0.1 0 0 0 2 4 6 0 2 4 6 Not a knot end conditions Exact slope end conditions 0.5 0.5 knots knots spline spline 0.4 0.4 x*exp(-x) x*exp(-x) 0.3 0.3 0.2 0.2 0.1 0.1 0 0 0 2 4 6 0 2 4 6 NMM: Interpolation page 21
Figure 10.20 100 100 Nearest neighbor Piecewise linear 50 50 0 0 0 0.5 1 1.5 0 0.5 1 1.5 100 100 Piecewise cubic Cubic spline 50 50 0 0 0 0.5 1 1.5 0 0.5 1 1.5 NMM: Interpolation page 22
Exercise 10.20 6 5 4 y 3 2 1 0 -1 0 1 2 3 4 x NMM: Interpolation page 23
Exercise 10.37 6 t = 5 5 4 t = 4 y t = 2 3 t = 3 2 1 t = 1 0 -1 0 1 2 3 4 x NMM: Interpolation page 24
Recommend
More recommend