# Chapter 3, Interpolation and Extrapolation. Interpolation & Extrapolation (x i,y i ) Find an analytic function f(x) that passes through given N points.

## Presentation on theme: "Chapter 3, Interpolation and Extrapolation. Interpolation & Extrapolation (x i,y i ) Find an analytic function f(x) that passes through given N points."— Presentation transcript:

Chapter 3, Interpolation and Extrapolation

Interpolation & Extrapolation (x i,y i ) Find an analytic function f(x) that passes through given N points exactly.

Polynomial Interpolation Use polynomial of degree N-1 to fit exactly with N data points (x i,y i ), i =1, 2, …, N. The coefficient c i is determined by a system of linear equations

Vandermonde Matrix Equation But it is not advisable to solve this system numerically because of ill-conditioning.

Condition Number cond(A) = ||A|| · ||A -1 || For singular matrix, cond(A) = ∞ A linear system is ill-conditioned if cond(A) is very large. Norm ||. ||: a function that satisfies (1) f(A) ≥ 0, (2) f(A+B) ≤ f(A) + f(B), (3) f(  A) = |  | f(A).

Norms Vector p-norm Matrix norm sup: supremum

Commonly Used Norms Vector norm Matrix norm Where μ is the maximum eigenvalue of matrix A T A.

Lagrange’s Formula It can be verified that the solution to the Vandermonde equation is given by the formula below: l i (x) has the property l i (x i )=1; l i (x k )=0, k≠i.

Joseph-Louis Lagrange (1736-1813) Italian-French mathematician associated with many classic mathematics and physics – Lagrange multipliers in minimization of a function, Lagrange’s interpolation formula, Lagrange’s theorem in group theory and number theory, and the Lagrangian (L=T-V) in mechanics and Euler-Lagrange equations.

Neville’s Algorithm Evaluate Lagrange’s interpolation formula f(x) at x, given the data points (x i,y i ). Interpolation tableau P x 1 : y 1 = P 1 P 12 x 2 : y 2 = P 2 P 123 P 23 P 1234 x 3 : y 3 = P 3 P 234 P 34 x 4 : y 4 = P 4 P i,i+1,i+2,…,i+n is a polynomial of degree n in x that passes through the points (x i,y i ), (x i+1,y i+1 ), …, (x i+n,y i+n ) exactly.

Determine P 12 from P 1 & P 2 Given the value P 1 and P 2 at x=x 1 and x 2, we find linear interpolation P 12 (x) = λ(x) P 1 +[1-λ(x)] P 2 Since P 12 (x 1 ) = P 1 and P 12 (x 2 ) = P 2, we must have λ(x 1 ) = 1, λ(x 2 ) = 0 so λ(x) = λ 12 = (x-x 2 )/(x 1 -x 2 )

Determine P 123 from P 12 & P 23 We write P 123 (x) = λ(x) P 12 (x) + [1-λ(x)] P 23 (x) P 123 (x 2 ) = P 2 already for any choice of λ(x). We require that P 123 (x 1 )=P 12 (x 1 ) =P 1 and P 123 (x 3 )=P 23 (x 3 ) =P 3, thus λ(x 1 ) = 1, λ(x 3 ) = 0 Or

Recursion Relation for P Given two m-point interpolated value P constructed from point i,i+1,i+2,…,i+m-1, and i+1,i+2,…,i+m, the next level m+1 point interpolation from i to i+m is a convex combination:

Use Small Difference C & D P1P1 P2P2 P3P3 P4P4 P 12 P 23 P 34 P 123 P 234 P 1234 C 1,1 = P 12 -P 1 D 1,1 C 1,2 C 1,3 D 1,2 D 1,3 C 2,1= P 123 -P 12 C 2,2 D 2,1 C 3,1 =P 1234 -P 123 D 3,1 =P 1234 -P 234 D 2,2 =P 234 -P 34

Deriving the Relation among C & D P =λ P A + (1-λ)P B PAPA PBPB P0P0 C2=P-PAC2=P-PA C1=PB –P0C1=PB –P0 D2=P-PBD2=P-PB D1=PA –P0D1=PA –P0

Evaluate f(3) given 4-points (0,1), (1,2), (2,3),(4,0). P 1234 = 11/4 C 1,1 = 3 D 1,1 = 2 C 1,2 = 2 C 1,3 = -3/2 D 1,2 = 1 D 1,3 = 3/2 C 2,1 = 0 C 2,2 = -5/3 D 2,1 = 0 C 3,1 = - 5/4 D 3,1 = 5/12 D 2,2 =5/6 x 1 =0, y 1 =1 =P 1 x 2 =1, y 2 =2 =P 2 x 3 =2, y 3 =3 =P 3 x 4 =4, y 4 =0 =P 4 C 0,1 =1 D 0,1 =1 C 0,2 =2 D 0,2 =2 C 0,3 =3 D 0,3 =3 D 0,4 =0 C 0,4 =0

polint( ) Program

polint(), continued

Piecewise Linear Interpolation (x 1,y 1 ) (x 2,y 2 ) (x 3,y 3 ) (x 4,y 4 ) (x 5,y 5 ) P 12 (x) P 23 (x) P 34 (x) P 45 (x) x y

Piecewise Polynomial Interpolation (x 1,y 1 ) (x 2,y 2 ) (x 3,y 3 ) (x 4,y 4 ) (x 5,y 5 ) P 1234 (x) P 2345 (x) x y Discontinuous derivatives across segment

Cubic Spline Given N points (x i,y i ), i=1,2,…,N, for each interval between points i to i+1, fit to cubic polynomials such that P i (x i )=y i and P i (x i+1 )=y i+1. Make 1 st and 2 nd derivatives continuous across intervals, i.e., P i (n) (x i+1 ) = P (n) i+1 (x i+1 ), n = 1 and 2. Fix boundary condition to P’’(x 1 or N )=0, or P’(x 1 or N ) = const, to completely specify.

Reading NR, Chapter 3 See also J. Stoer and R. Bulirsch, “Introduction to Numerical Analysis,” Chapter 2. Other chapters are also excellent, but rather mathematical, references for other topics.

Problems for Lecture 3 (Interpolation) 1.Use Neville’s algorithm to find the interpolation value at x = 0, for a cubic polynomial interpolation with 4 points (x,y) = (-1,1.25), (1,2), (2,3), (4,0). Also write out the Lagrange’s formula and compute f(0). 2. Given the same 4 points as above, determine the cubic splines with natural boundary condition (second derivatives equal to 0 at the boundary). Give the cubic polynomials in each of the three intervals. Use the method outlined in NR page 113 to 116, or a direct fit to cubic polynomials with proper conditions.

Download ppt "Chapter 3, Interpolation and Extrapolation. Interpolation & Extrapolation (x i,y i ) Find an analytic function f(x) that passes through given N points."

Similar presentations