Lecture 3—Polynomial Interpolation Outline 1 Methods for generating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 1 / 16
What is a polynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x y Order 0 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
What is a polynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x y Order 1 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
What is a polynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x y Order 2 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
What is a polynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x4, f4 x y Order 3 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
What is a polynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x4, f4x5, f5 x y Order 4 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. p(5) is the coefficient of x0 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials Matlab has a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. p(5) is the coefficient of x0 If there are missing terms in a polynomial expression, a 0 must be used in the Matlab representation: x3 + x − 1 » p = [1 0 1 -1]; x5 » p = [1 0 0 0 0]; Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
Matlab and polynomials The function polyval can be used to evaluate a polynomial at any number of x-values: 4x4 + 2x3 − 3x2 − 3x + 1 >> x = [ - 1 0 1 ]; >> p = [4 2 -3 -3 1]; >> polyval(p,x) ans = 5 3 1 1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 4 / 16
Matlab and polynomials The function polyval can be used to evaluate a polynomial at any number of x-values: 4x4 + 2x3 − 3x2 − 3x + 1 >> x = [ - 1 0 1 ]; >> p = [4 2 -3 -3 1]; >> polyval(p,x) ans = 5 3 1 1 The roots function will return all n roots of an nth -order polynomial. (Some roots may contain imaginary numbers) >> r = roots(p) r = -0.84202 + 0.5319i -0.84202 - 0.5319i 5 0.90577 0.27826 >> length(r) ans = 4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 4 / 16
Matlab and polynomials The function polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 0 10 20 30 0 100 200 300 P, atm V,m3 mol Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
Matlab and polynomials The function polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 >> logP = [1,10,20,30]; >> V = [310660,31060,15520,10350]; >> order = 2; >> p = polyfit(logP,V,order); >> fplot(@(x)polyval(p,x),[0 30],’r’); 0 10 20 30 0 100 200 300 P, atm V,m3 mol If order < length(logP)-1 then linear regression is used. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
Matlab and polynomials The function polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 >> logP = [1,10,20,30]; >> V = [310660,31060,15520,10350]; >> order = 3; >> p = polyfit(logP,V,order); >> fplot(@(x)polyval(p,x),[0 30],’g’); 0 10 20 30 0 200 400 P, atm V,m3 mol If order < length(logP)-1 then linear regression is used. If order == length(logP)-1 then the interpolating polynomial is calculated. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
Uses of interpolating polynomials Estimating the value of a function in between tabulated data points (e.g., getting physical property data from the steam tables) Estimating the derivatives of a function when the data are not uniformly spaced. Simply find the interpolating polynomial, and then calculate its derivatives. Estimating the integral of a function. Most numerical integration algorithms are based on interpolating polynomials. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 6 / 16
Outline 1 Methods for generating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 7 / 16
Calculating the interpolating polynomial We want to find the polynomial with n coefficients to interpolate n data points. Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
Calculating the interpolating polynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3 Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
Calculating the interpolating polynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3 a0 + a1(1) + a2(1)2 + a3(1)3 = 310660 a0 + a1(10) + a2(10)2 + a3(10)3 = 31060 a0 + a1(20) + a2(20)2 + a3(20)3 = 15520 a0 + a1(30) + a2(30)2 + a3(30)3 = 10350 Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
Calculating the interpolating polynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3     1 1 1 1 1 10 100 1000 1 20 400 8000 1 30 900 27000         a0 a1 a2 a3     =     310660 31060 15520 10350     Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
Calculating the interpolating polynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3     1 1 1 1 1 10 100 1000 1 20 400 8000 1 30 900 27000         a0 a1 a2 a3     =     310660 31060 15520 10350     Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 The problem is that the corresponding matrix is nearly singular, and numerical errors become a significant problem. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
Newton’s Interpolating Polynomial We start with the 0 order polynomial P0(x), with 1 data point. 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P0(x) = f(x1) = f1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
Newton’s Interpolating Polynomial The first polynomial is related to the first by adding the term: (x − x1) (f1 − f2) x1 − x2 1,1 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P1(x) = f1 + (x − x1) (f1 − f2) x1 − x2 1,1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
Newton’s Interpolating Polynomial The quadratic interpolating polynomial is related to the linear by adding the term: (x − x1)(x − x2) ( 1,1 − 2,1) x1 − x3 1,2 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P2(x) = f1 + (x − x1) (f1 − f2) x1 − x2 1,1 +(x − x1)(x − x2) 1,1 (f1 − f2) x1 − x2 − 2,1 (f2 − f3) x2 − x3 x3 − x1 1,2 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
Newton’s Interpolating Polynomial The equation for the nth order newton polynomial is: Pn(x) = f1 + n−1 i=1 1,i i j=1 (x − xj) 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P3(x) = f1 + (x − x1) 1,1 + (x − x1)(x − x2) 1,2 + (x − x1)(x − x2)(x − x3) 1,3 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
Newton’s Interpolating Polynomial The equation for the nth order newton polynomial is: Pn(x) = f1 + n−1 i=1 i1 i j=1 (x − xj) The are called finite difference operators i,j = i+1,j−1− i,j−1 xi+j −xi These formula can be used to develop a Matlab code to find Newton’s Interpolating Polynomial. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 10 / 16
Newton Interpolating Polynomials — The algorithm The first step is to copy all of the fi values into the first column of a table The 2nd column entries are the first order finite differences i,1 = fi+1 − fi xi+1 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 f2 − f1 x2 − x1 x2 f2 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The 3rd column entries require the 2nd column. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 x2 f2 f3 − f2 x3 − x2 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The 3rd column entries are the second order finite differences i,2 = i+1,1 − i,1 xi+2 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 2,1 − 1,1 x3 − x1 x2 f2 2,1 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The 4th column entry (the cubic coefficient) requires 1 more round of finite differences. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 x2 f2 2,1 x3 f3 f4 − f3 x4 − x3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The 4th column entry (the cubic coefficient) requires 1 more round of finite differences. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 x2 f2 2,1 3,1 − 2,1 x4 − x2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The 4th column entries are the 3rd order finite differences i,3 = i+1,2 − i,2 xi+3 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 2,2 − 1,2 x4 − x1 x2 f2 2,1 2,2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Newton Interpolating Polynomials — The algorithm The first row in the table contains the necessary coefficients: Pn(x) = f1 + n i=1 1,i i j=1 (x − xj) xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 1,3 x2 f2 2,1 2,2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
Outline 1 Methods for generating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 12 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Ln i (x) is designed such that: Ln i (x) = 0 x = xj, j = i 1 x = xi Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials The LaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Ln i (x) is designed such that: Ln i (x) = 0 x = xj, j = i 1 x = xi The form of Ln i (x) is: Ln i (x) = j=i(x − xj) j=i(xi − xj) Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
The LaGrange Polynomials Example Suppose x = 1 2 : Then L1 1(x) = x−x2 x1−x2 = x−2 1−2 L1 2(x) = x−x1 x2−x1 = x−1 2−1 It is easy to check that L1 1(x1) = 1 and L1 1(x2) = 0: L1 1(x1) = x1 − x2 x1 − x2 = 1 L1 1(x2) = x2 − x2 x1 − x2 = 0 1 1.5 2 0 0.5 1 (x1, 1) (x2, 1) (x1, 0) (x2, 0) L 1 1 (x) L1 2(x) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 14 / 16
The LaGrange Polynomials Example Suppose x = 1 2 3 : Then L2 1(x) = (x−x2)(x−x3) (x1−x2)(x1−x3) L2 2(x) = (x−x1)(x−x3) (x2−x1)(x2−x3) L2 3(x) = (x−x1)(x−x2) (x3−x1)(x3−x2) It is easy to check that L2 1(x1) = (x1 − x2)(x1 − x3) (x1 − x2)(x1 − x3) = 1 L2 2(x2) = (x2 − x2)(x2 − x3) (x1 − x2)(x1 − x3) = 0 L2 3(x3) = (x3 − x2)(x3 − x3) (x1 − x2)(x1 − x3) = 0 1 2 3 0 0.5 1 x1, 1 x2, 1 x3, 1 x1, 0 x2, 0 x3, 0 xy Che 310 — Chapra 17 3 — Interpolation September 7, 2017 15 / 16
The LaGrange Interpolating Polynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16
The LaGrange Interpolating Polynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) + (2) (x − 1)(x − 3) (2 − 1)(2 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16
The LaGrange Interpolating Polynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) + (2) (x − 1)(x − 3) (2 − 1)(2 − 3) +(1) (x − 1)(x − 3) (2 − 1)(2 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16

Lecture 3 - Introduction to Interpolation

  • 1.
    Lecture 3—Polynomial Interpolation Outline 1Methods for generating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 1 / 16
  • 2.
    What is apolynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x y Order 0 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
  • 3.
    What is apolynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x y Order 1 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
  • 4.
    What is apolynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x y Order 2 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
  • 5.
    What is apolynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x4, f4 x y Order 3 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
  • 6.
    What is apolynomial? A polynomial is a special type of function composed of sums an independent variable raised to an integer power. p(x) = anxn + an−1xn−1 + · · · a1x + a0 The number n is called the order of the polynomial. There are n + 1 degrees of freedom in a polynomial of order n. Each coefficient ai controls the properties of the polynomial. −1 0 1 −2 −1 0 1 2 x1, f1 x2, f2 x3, f3 x4, f4x5, f5 x y Order 4 Interpolating Polynomial An interpolating polynomial is a special polynomial of order n designed to precisely agree with the values of n − 1 data points. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 2 / 16
  • 7.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 8.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 9.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 10.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 11.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. p(5) is the coefficient of x0 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 12.
    Matlab and polynomials Matlabhas a few built-in functions for dealing with polynomials that are worth knowing. An nth order polynomial in Matlab is represented by an array of its n + 1 coefficients: 4x4 + 7x3 + x2 − 2x + 1 » p = [4 7 1 -2 1]; The order of the polynomial is 4, so length(p) is 5. p(1) is the coefficient of x4. p(5) is the coefficient of x0 If there are missing terms in a polynomial expression, a 0 must be used in the Matlab representation: x3 + x − 1 » p = [1 0 1 -1]; x5 » p = [1 0 0 0 0]; Che 310 — Chapra 17 3 — Interpolation September 7, 2017 3 / 16
  • 13.
    Matlab and polynomials Thefunction polyval can be used to evaluate a polynomial at any number of x-values: 4x4 + 2x3 − 3x2 − 3x + 1 >> x = [ - 1 0 1 ]; >> p = [4 2 -3 -3 1]; >> polyval(p,x) ans = 5 3 1 1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 4 / 16
  • 14.
    Matlab and polynomials Thefunction polyval can be used to evaluate a polynomial at any number of x-values: 4x4 + 2x3 − 3x2 − 3x + 1 >> x = [ - 1 0 1 ]; >> p = [4 2 -3 -3 1]; >> polyval(p,x) ans = 5 3 1 1 The roots function will return all n roots of an nth -order polynomial. (Some roots may contain imaginary numbers) >> r = roots(p) r = -0.84202 + 0.5319i -0.84202 - 0.5319i 5 0.90577 0.27826 >> length(r) ans = 4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 4 / 16
  • 15.
    Matlab and polynomials Thefunction polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 0 10 20 30 0 100 200 300 P, atm V,m3 mol Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
  • 16.
    Matlab and polynomials Thefunction polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 >> logP = [1,10,20,30]; >> V = [310660,31060,15520,10350]; >> order = 2; >> p = polyfit(logP,V,order); >> fplot(@(x)polyval(p,x),[0 30],’r’); 0 10 20 30 0 100 200 300 P, atm V,m3 mol If order < length(logP)-1 then linear regression is used. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
  • 17.
    Matlab and polynomials Thefunction polyfit will use linear regression to determine the best fit of a polynomial to a data set: Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 >> logP = [1,10,20,30]; >> V = [310660,31060,15520,10350]; >> order = 3; >> p = polyfit(logP,V,order); >> fplot(@(x)polyval(p,x),[0 30],’g’); 0 10 20 30 0 200 400 P, atm V,m3 mol If order < length(logP)-1 then linear regression is used. If order == length(logP)-1 then the interpolating polynomial is calculated. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 5 / 16
  • 18.
    Uses of interpolatingpolynomials Estimating the value of a function in between tabulated data points (e.g., getting physical property data from the steam tables) Estimating the derivatives of a function when the data are not uniformly spaced. Simply find the interpolating polynomial, and then calculate its derivatives. Estimating the integral of a function. Most numerical integration algorithms are based on interpolating polynomials. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 6 / 16
  • 19.
    Outline 1 Methods forgenerating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 7 / 16
  • 20.
    Calculating the interpolatingpolynomial We want to find the polynomial with n coefficients to interpolate n data points. Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
  • 21.
    Calculating the interpolatingpolynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3 Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
  • 22.
    Calculating the interpolatingpolynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3 a0 + a1(1) + a2(1)2 + a3(1)3 = 310660 a0 + a1(10) + a2(10)2 + a3(10)3 = 31060 a0 + a1(20) + a2(20)2 + a3(20)3 = 15520 a0 + a1(30) + a2(30)2 + a3(30)3 = 10350 Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
  • 23.
    Calculating the interpolatingpolynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3     1 1 1 1 1 10 100 1000 1 20 400 8000 1 30 900 27000         a0 a1 a2 a3     =     310660 31060 15520 10350     Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
  • 24.
    Calculating the interpolatingpolynomial We want to find the polynomial with n coefficients to interpolate n data points. We could just set up a linear algebra problem to do this. For example, with 4 data points, we want a cubic interpolating polynomial: V(P) = a0 + a1P + a2P2 + a3P3     1 1 1 1 1 10 100 1000 1 20 400 8000 1 30 900 27000         a0 a1 a2 a3     =     310660 31060 15520 10350     Properties of steam at 550 ◦ C: P, atm V, cm3 mol 1 310660 10 31060 20 15520 30 10350 The problem is that the corresponding matrix is nearly singular, and numerical errors become a significant problem. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 8 / 16
  • 25.
    Newton’s Interpolating Polynomial Westart with the 0 order polynomial P0(x), with 1 data point. 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P0(x) = f(x1) = f1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
  • 26.
    Newton’s Interpolating Polynomial Thefirst polynomial is related to the first by adding the term: (x − x1) (f1 − f2) x1 − x2 1,1 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P1(x) = f1 + (x − x1) (f1 − f2) x1 − x2 1,1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
  • 27.
    Newton’s Interpolating Polynomial Thequadratic interpolating polynomial is related to the linear by adding the term: (x − x1)(x − x2) ( 1,1 − 2,1) x1 − x3 1,2 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P2(x) = f1 + (x − x1) (f1 − f2) x1 − x2 1,1 +(x − x1)(x − x2) 1,1 (f1 − f2) x1 − x2 − 2,1 (f2 − f3) x2 − x3 x3 − x1 1,2 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
  • 28.
    Newton’s Interpolating Polynomial Theequation for the nth order newton polynomial is: Pn(x) = f1 + n−1 i=1 1,i i j=1 (x − xj) 5 10 15 20 25 30 0 100 200 300 x1, f1 x2, f2 x3, f3 x4, f4 P3(x) = f1 + (x − x1) 1,1 + (x − x1)(x − x2) 1,2 + (x − x1)(x − x2)(x − x3) 1,3 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 9 / 16
  • 29.
    Newton’s Interpolating Polynomial Theequation for the nth order newton polynomial is: Pn(x) = f1 + n−1 i=1 i1 i j=1 (x − xj) The are called finite difference operators i,j = i+1,j−1− i,j−1 xi+j −xi These formula can be used to develop a Matlab code to find Newton’s Interpolating Polynomial. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 10 / 16
  • 30.
    Newton Interpolating Polynomials— The algorithm The first step is to copy all of the fi values into the first column of a table The 2nd column entries are the first order finite differences i,1 = fi+1 − fi xi+1 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 f2 − f1 x2 − x1 x2 f2 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 31.
    Newton Interpolating Polynomials— The algorithm The 3rd column entries require the 2nd column. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 x2 f2 f3 − f2 x3 − x2 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 32.
    Newton Interpolating Polynomials— The algorithm The 3rd column entries are the second order finite differences i,2 = i+1,1 − i,1 xi+2 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 2,1 − 1,1 x3 − x1 x2 f2 2,1 x3 f3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 33.
    Newton Interpolating Polynomials— The algorithm The 4th column entry (the cubic coefficient) requires 1 more round of finite differences. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 x2 f2 2,1 x3 f3 f4 − f3 x4 − x3 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 34.
    Newton Interpolating Polynomials— The algorithm The 4th column entry (the cubic coefficient) requires 1 more round of finite differences. xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 x2 f2 2,1 3,1 − 2,1 x4 − x2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 35.
    Newton Interpolating Polynomials— The algorithm The 4th column entries are the 3rd order finite differences i,3 = i+1,2 − i,2 xi+3 − xi xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 2,2 − 1,2 x4 − x1 x2 f2 2,1 2,2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 36.
    Newton Interpolating Polynomials— The algorithm The first row in the table contains the necessary coefficients: Pn(x) = f1 + n i=1 1,i i j=1 (x − xj) xi i,0 = fi i,1 = fi+1−fi xi+1−xi i,2 = i+1,1− i,1 xi+2−xi i,3 = i+1,2− i,2 xi+3−xi x1 f1 1,1 1,2 1,3 x2 f2 2,1 2,2 x3 f3 3,1 x4 f4 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 11 / 16
  • 37.
    Outline 1 Methods forgenerating interpolating polynomials Matlab built-in functions for dealing with polynomials Newton Interpolating Polynomials LaGrange Interpolating Polynomials Che 310 — Chapra 17 3 — Interpolation September 7, 2017 12 / 16
  • 38.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 39.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 40.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 41.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 42.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Ln i (x) is designed such that: Ln i (x) = 0 x = xj, j = i 1 x = xi Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 43.
    The LaGrange Polynomials TheLaGrange polynomials are a family of polynomials defined by n + 1 x-values: x = x1 x2 x3 . . . xn+1 Each member of the family is designated Ln i (x): Each of the n + 1 polynomials is order n. E.g. if we have 3 points then L2 1(x), L2 2(x), and L2 3(x) are quadratics. Ln i (x) is the nth order polynomial that ‘‘belongs’’ to xi Ln i (x) is designed such that: Ln i (x) = 0 x = xj, j = i 1 x = xi The form of Ln i (x) is: Ln i (x) = j=i(x − xj) j=i(xi − xj) Che 310 — Chapra 17 3 — Interpolation September 7, 2017 13 / 16
  • 44.
    The LaGrange Polynomials Example Supposex = 1 2 : Then L1 1(x) = x−x2 x1−x2 = x−2 1−2 L1 2(x) = x−x1 x2−x1 = x−1 2−1 It is easy to check that L1 1(x1) = 1 and L1 1(x2) = 0: L1 1(x1) = x1 − x2 x1 − x2 = 1 L1 1(x2) = x2 − x2 x1 − x2 = 0 1 1.5 2 0 0.5 1 (x1, 1) (x2, 1) (x1, 0) (x2, 0) L 1 1 (x) L1 2(x) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 14 / 16
  • 45.
    The LaGrange Polynomials Example Supposex = 1 2 3 : Then L2 1(x) = (x−x2)(x−x3) (x1−x2)(x1−x3) L2 2(x) = (x−x1)(x−x3) (x2−x1)(x2−x3) L2 3(x) = (x−x1)(x−x2) (x3−x1)(x3−x2) It is easy to check that L2 1(x1) = (x1 − x2)(x1 − x3) (x1 − x2)(x1 − x3) = 1 L2 2(x2) = (x2 − x2)(x2 − x3) (x1 − x2)(x1 − x3) = 0 L2 3(x3) = (x3 − x2)(x3 − x3) (x1 − x2)(x1 − x3) = 0 1 2 3 0 0.5 1 x1, 1 x2, 1 x3, 1 x1, 0 x2, 0 x3, 0 xy Che 310 — Chapra 17 3 — Interpolation September 7, 2017 15 / 16
  • 46.
    The LaGrange InterpolatingPolynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16
  • 47.
    The LaGrange InterpolatingPolynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) + (2) (x − 1)(x − 3) (2 − 1)(2 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16
  • 48.
    The LaGrange InterpolatingPolynomials Through a weighted sum, the family of Ln i (x) becomes a single interpolating polynomial: Ln (x) = n+1 i=1 fiLn i (x) Example Suppose x = (1 2 3) and f(x) = (−1 2 1) Then L2 1(x) = (x−2)(x−3) (1−2)(1−3) L2 2(x) = (x−1)(x−3) (2−1)(2−3) L2 3(x) = (x−1)(x−2) (3−1)(3−2) The interpolating polynomial: L 2 (x) = (−1) (x − 2)(x − 3) (1 − 2)(1 − 3) + (2) (x − 1)(x − 3) (2 − 1)(2 − 3) +(1) (x − 1)(x − 3) (2 − 1)(2 − 3) 1 2 3 0 2 (x1, f1) (x2, f2) (x3, f3) x y Che 310 — Chapra 17 3 — Interpolation September 7, 2017 16 / 16