Interpolation and Polynomial Approximation: Professor Henry Arguello
Interpolation and Polynomial Approximation: Professor Henry Arguello
Interpolation and Polynomial Approximation: Professor Henry Arguello
3 Introduction to Interpolation
4 Lagrange Approximation
5 Newton Polynomials
6 Lagrange Approximation
7 Newton Polynomials
y = ex y = ex
2.0 2.0
y = pH x L y = qH xL
1.5 1.5
1.0 1.0
0.5 0.5
x x
- 1.0 - 0.5 0.0 0.5 1.0 - 1.0 - 0.5 0.0 0.5 1.0
n 1 + 1 + ··· + 1
Sn = 1 + 1! 2! n!
0 1.0
Example: Compute the number e 1 2.0
using the Taylor series in Table 4.1 2 2.5
with x = 1, 3 2.666666666666...
4 2.708333333333...
5 2.716666666666...
2 3 4 k
1 1 1 1 1 1 6 2.718055555555...
e = 1+ + + + +···+ +···
1! 2! 3! 4! k! 7 2.718253968254...
8 2.718278769841...
The sum of an infinite series 9 2.718281525573...
requires that the partial sums SN 10 2.718281801146...
Example: Show why 15 terms are all that are needed to obtain the
13-digit approximation e = 2.718281828459 in Table 4.2.
Example: Show why 15 terms are all that are needed to obtain the
13-digit approximation e = 2.718281828459 in Table 4.2.
Expand f (x) = ex in a Taylor polynomial of degree 15 using the fixed
value x0 = 0 and involving the powers (x − 0)k = xk . The derivatives
required are f 0 (x) = f 00 (x) = ... = f (16) = ex . The first 15 derivatives are
used to calculate the coefficients ak = e0 /k! and are used to write the
polynomial
x2 x3 x15
P15 (x) = 1 + x + + + ··· + (4)
2! 3! 15!
f (16) (c)x16
E15 (x) = (5)
16!
f (16) (c)x16
E15 (x) = (5)
16!
Since we chose x0 = 0 and x = 1, the value c lies between them, which
implies that ec < e1 . Notice that the partial sums in Table 4.2 are
bounded above by 3. Combining these two inequalities yields ec < 3,
which is used in the following calculation
|f (16) (c)| ec 3
|E15 (1)| = ≤ < < 1.433844x10−13
16! 16! 16!
f (16) (c)x16
E15 (x) = (5)
16!
Since we chose x0 = 0 and x = 1, the value c lies between them, which
implies that ec < e1 . Notice that the partial sums in Table 4.2 are
bounded above by 3. Combining these two inequalities yields ec < 3,
which is used in the following calculation
|f (16) (c)| ec 3
|E15 (1)| = ≤ < < 1.433844x10−13
16! 16! 16!
Therefore, all the digits in the approximation e ≈ 2.718281828459 are
correct, because the actual error must be less than 2 in the thirteenth
decimal place.
Corollary
If PN (x) is the Taylor polynomial of degree N given in Theorem 9, then
(k)
PN (x0 ) = f (k) (x0 ) for k = 0, 1, ..., N. (6)
Proof. Set x = x0 in equations (2) and (3), and the result is
PN (x0 ) = f (x0 ). thus statement (6) is true for k = 0. Now differentiate
the right-hand side of (2) and get
N N−1
X f (k) (x0 ) X f (k+1) (x0 )
P0N (x) = (x − x0 ) k−1
= (x − x0 )k . (7)
(k − 1)! k!
k=1 k=0
Set x = x0 in (7) to obtain P0N (x0 ) = f 0 (x0 ). Thus statement (6) is true for
k = 1. Successive differentiations of (7) will establish the other
identities in (6). The details are left as an exercise.
Table 4.3 Values for the Error Bound |error| < eR RN + 1/(N + 1)!
y
10
8
y = ex
y = P4 H x L
y = P3H xL
y = P2 H x L
6
x
-2 -1 0 1 2
e1.0 (1.0)9
|error| = |E8 (x)| ≤ ≈ 0.00000749.
9!
If |x| ≤ 0.5, then letting R = 0.5 and |f (9) (c)| = |ec | ≤ e0.5 = M in (8)
implies that
e0.5 (0.5)9
|error| = |E8 (x)| ≤ ≈ 0.00000001.
9!
Proof. This follows directly form the definition of convergence of series. The
limit condition is often stated by saying that the error term must go to zero as
N goes to infinity. Therefore, a necessary and sufficient condition for (18) to
hold is that
f (N+1) (c)(x − x0 )N+1
lim EN (x) = lim = 0. (14)
N→∞ N→∞ (N + 1)!
aN xN+1 aN−1 xN a2 x 3 a1 x 2
I(x) = + + ··· + + + a0 x + C (3)
N+1 N 3 2
Where C is the constant of integration. Algorithm 4.1 shows how to
adapt Horner’s method to P0 (x) and I(x).
2.0
(5.5,P(5.5))
(a) (4,P(4))
1.5
b3 = a3 = −0.02
y = P(x)
b2 = a2 + b3 x = 0.2 + (−0.02)(4) = 0.12
1.0
b1 = a1 + b2 x = −0.4 + (0.12)(4) = 0.08
b0 = a0 + b1 x = 1.28 + (0.08)(4) = 1.60
0.5
1.0
The numerical derivative is
P0 (4) = 0.24 0.5
x
0 1 2 3 4 5 6
(c) y
2.0
i4 = a43 = −0.005
a2
i3 = 3 + i4 x = 0.06666667 + (−0.005)(4) = 1.5
0.04666667 y=P(x)
2.0
(5.5,P(5.5))
(d) Use Algorithm 4.1(i) with x = 5.5 (4,P(4))
1.5
b3 = a3 = −0.02
y = P(x)
b2 = a2 + b3 x = 0.2 + (−0.02)(5.5) = 0.09
1.0
b1 = a1 + b2 x = −0.4 + (0.09)(5.5) = 0.095
b0 = a0 + b1 x = 1.28 + (0.095)(5.5) = 1.8025
0.5
(e) Assume that P(x) = A + Bx + Cx2 + Dx3 ; then at each value x = 1, 2, 3, and
5 we get a linear equation involving A, B, C and D.
Atx = 1 : A + 1B + 1C + 1D = 1.06
Atx = 2 : A + 2B + 4C + 8D = 1.12 (4)
Atx = 3 : A + 3B + 9C + 27D = 1.34
Atx = 5 : A + 5B + 25C + 125D = 1.78
The solution to (4) is A = 1.28, B = −0.4, C = 0.2 and D = −0.2.
sion.
INPUT N Degree of P(x)
INPUT A(0), A(1), ..., A(N) Coefficients of P(x)
INPUT C Constant of integration
INPUT X Independent variable
Each term on the right side of (3) involves a linear factor; hence the
sum is a polynomial of degree ≤ 1. The quotients in (3) are denoted by
x − x1 x − x0
L1,0 (0) = and L1,1 (x) = . (8)
x0 − x1 x1 − x0
Computation reveals that L1,0 (x0 ) = 1, L1,0 (x1 ) = 0, L1,1 (x0 ) = 0, and
L1,1 (x1 ) = 1 so that the polynomial P1 (x) in (3) also passes through the
two given points:
The terms L1,0 (x) and L1,1 (x) in (4) are called Lagrange coefficient
polynomials based on the nodes x0 and x1 . Using this notation, (3)
can be written in summation form
1
X
P1 (x) = yk L1,k (x). (10)
k=0
(a) Using (3) with the abscissas x0 = 0.0 and x1 = 1.2 and the ordinates
y0 = cos(0.0) = 1.000000 and y1 = cos(1.2) = 0.362358 produces
x − 1.2 x − 0.0
P1 (x) = 1.000000 + 0.362358
0.0 − 1.2 1.2 − 0.0
= −0.833333(x − 1.2) + 0.301965(x − 0.0).
(a) Using (3) with the abscissas x0 = 0.0 and x1 = 1.2 and the ordinates
y0 = cos(0.0) = 1.000000 and y1 = cos(1.2) = 0.362358 produces
x − 1.2 x − 0.0
P1 (x) = 1.000000 + 0.362358
0.0 − 1.2 1.2 − 0.0
= −0.833333(x − 1.2) + 0.301965(x − 0.0).
(b) When the nodes x0 = 0.2 and x1 = 1.0 with y0 = cos(0.2) = 0.980067
and y1 = cos(1.0) = 0.540302 are used, the result is
x − 1.0 x − 0.2
Q1 (x) = 0.980067 + 0.540302
0.2 − 1.0 1.0 − 0.2
= −1.225083(x − 1.0) + 0.675378(x − 0.2).
Table 4.6 Comparison of f (x) = cos(x) and the Linear Approximations P1 (x) and Q1 (x)
1.0 1.0
y = f(x)
y = f(x)
0.8 0.8
y = P1 HxL y = Q1 HxL
0.6 0.6
0.4 0.4
0.2 0.2
x x
0.0 0.2 0.4 0.6 0.8 1.0 1.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2
The linear approximation y = P1 (x) where The linear approximation y = Q1 (x) where
the nodes x0 = 0.0 and x1 = 1.2 are the the nodes x0 = 0.2 and x1 = 1.0 lie inside
endpoints of the interval [a, b]. the interval [a, b].
For each fixed k, the Lagrange coefficient polynomial LN,k (x) has the
property
Then direct substitution of these values into (7) is used to show that
the polynomial curve y = PN (x) goes through (xj , yj ):
Suppose that PN (x) is not unique and that there exist another
polynomial QN (x) of degree ≤ N that also passes through the N + 1
points.
Form the difference polynomial T(x) = PN (x) − QN (x).
Observe that the polynomial T(x) has degree ≤ N and that
T(xj ) = PN (xj ) − QN (xj ) = yj − yj = 0, for j = 0, 1, ..., N. Therefore,
T(x) ≡ 0 and it follows that QN (x) = PN (x).
y y
1.0 1.0
0.5 0.5
y = f (x)
y = f(x)
x x
0.6 1.2 1.8 0.4 0.8 1.2 1.6 2
y = P2 H x L
- 0.5 - 0.5 y = P3H xL
for some value c = c(x) that lies in the interval [a, b].
Example 4.8: Consider y = f (x) = cos(x) over [0.0, 1.2]. Use formula
(18) through (20) and determine the error bounds for the Lagrange
polynomials P1 (x), P2 (x), and P3 (x) that were constructed in Examples
4.6 and 4.7.
Example 4.8: Consider y = f (x) = cos(x) over [0.0, 1.2]. Use formula
(18) through (20) and determine the error bounds for the Lagrange
polynomials P1 (x), P2 (x), and P3 (x) that were constructed in Examples
4.6 and 4.7. First, determine the bounds M2 , M3 , and M4 for the
derivatives |f (2) (x)|, |f (3) (x)| and |f (4) (x)|, respectively, taken over the
interval [0.0, 1.2]:
For P1 (x) the spacing of the nodes is h = 1.2, and its error bound is
h2 M2 (1.2)2 (1.000000)
|E1 (x)| ≤ ≤ = 0.180000 (25)
8 8
For P2 (x) the spacing of the nodes is h = 0.6, and its error bound is
h 3 M3 (0.6)3 (0.932039)
|E2 (x)| ≤ √ ≤ √ = 0.012915 (26)
9 3 9 3
For P3 (x) the spacing of the nodes is h = 0.4, and its error bound is
h 4 M4 (0.4)4 (1.000000)
|E3 (x)| ≤ ≤ = 0.001067 (27)
24 24
From Example 4.6 we saw that
|E1 (0.6)| = |cos(0.6) − P1 (0.6)| = 0.144157, so the bound 0.180000 in
(21) is reasonable.
y y
y = E3H xL
0.008 0.0008
y = E2 H x L
0.004 0.0004
x x
0.2 0.4 0.6 0.8 1.0 1.2 0.2 0.4 0.6 0.8 1.0 1.2
- 0.004 - 0.0004
- 0.008 - 0.0008
The error function E2 (x) = cos(x) − P2 (x). The error function E3 (x) = cos(x) − P3 (x).
Computation reveals that L1,0 (x0 ) = 1, L1,0 (x1 ) = 0, L1,1 (x0 ) = 0, and
L1,1 (x1 ) = 1 so that the polynomial P1 (x) in (3) also passes through the
two given points:
The terms L1,0 (x) and L1,1 (x) in (4) are called Lagrange coefficient
polynomials based on the nodes x0 and x1 . Using this notation, (3)
can be written in summation form
1
X
P1 (x) = yk L1,k (x). (33)
k=0
(a) Using (3) with the abscissas x0 = 0.0 and x1 = 1.2 and the ordinates
y0 = cos(0.0) = 1.000000 and y1 = cos(1.2) = 0.362358 produces
x − 1.2 x − 0.0
P1 (x) = 1.000000 + 0.362358
0.0 − 1.2 1.2 − 0.0
= −0.833333(x − 1.2) + 0.301965(x − 0.0).
(a) Using (3) with the abscissas x0 = 0.0 and x1 = 1.2 and the ordinates
y0 = cos(0.0) = 1.000000 and y1 = cos(1.2) = 0.362358 produces
x − 1.2 x − 0.0
P1 (x) = 1.000000 + 0.362358
0.0 − 1.2 1.2 − 0.0
= −0.833333(x − 1.2) + 0.301965(x − 0.0).
(b) When the nodes x0 = 0.2 and x1 = 1.0 with y0 = cos(0.2) = 0.980067
and y1 = cos(1.0) = 0.540302 are used, the result is
x − 1.0 x − 0.2
Q1 (x) = 0.980067 + 0.540302
0.2 − 1.0 1.0 − 0.2
= −1.225083(x − 1.0) + 0.675378(x − 0.2).
Table 4.6 Comparison of f (x) = cos(x) and the Linear Approximations P1 (x) and Q1 (x)
1.0 1.0
y = f(x)
y = f(x)
0.8 0.8
y = P1 HxL y = Q1 HxL
0.6 0.6
0.4 0.4
0.2 0.2
x x
0.0 0.2 0.4 0.6 0.8 1.0 1.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2
The linear approximation y = P1 (x) where The linear approximation y = Q1 (x) where
the nodes x0 = 0.0 and x1 = 1.2 are the the nodes x0 = 0.2 and x1 = 1.0 lie inside
endpoints of the interval [a, b]. the interval [a, b].
y y
1.0 1.0
0.5 0.5
y = f (x)
y = f(x)
x x
0.6 1.2 1.8 0.4 0.8 1.2 1.6 2
y = P2 H x L
- 0.5 - 0.5 y = P3H xL
for some value c = c(x) that lies in the interval [a, b].
Example 4.8: Consider y = f (x) = cos(x) over [0.0, 1.2]. Use formula
(18) through (20) and determine the error bounds for the Lagrange
polynomials P1 (x), P2 (x), and P3 (x) that were constructed in Examples
4.6 and 4.7.
Example 4.8: Consider y = f (x) = cos(x) over [0.0, 1.2]. Use formula
(18) through (20) and determine the error bounds for the Lagrange
polynomials P1 (x), P2 (x), and P3 (x) that were constructed in Examples
4.6 and 4.7. First, determine the bounds M2 , M3 , and M4 for the
derivatives |f (2) (x)|, |f (3) (x)| and |f (4) (x)|, respectively, taken over the
interval [0.0, 1.2]:
For P1 (x) the spacing of the nodes is h = 1.2, and its error bound is
h2 M2 (1.2)2 (1.000000)
|E1 (x)| ≤ ≤ = 0.180000 (48)
8 8
For P2 (x) the spacing of the nodes is h = 0.6, and its error bound is
h 3 M3 (0.6)3 (0.932039)
|E2 (x)| ≤ √ ≤ √ = 0.012915 (49)
9 3 9 3
For P3 (x) the spacing of the nodes is h = 0.4, and its error bound is
h 4 M4 (0.4)4 (1.000000)
|E3 (x)| ≤ ≤ = 0.001067 (50)
24 24
From Example 4.6 we saw that
|E1 (0.6)| = |cos(0.6) − P1 (0.6)| = 0.144157, so the bound 0.180000 in
(21) is reasonable.
y y
y = E3H xL
0.008 0.0008
y = E2 H x L
0.004 0.0004
x x
0.2 0.4 0.6 0.8 1.0 1.2 0.2 0.4 0.6 0.8 1.0 1.2
- 0.004 - 0.0004
- 0.008 - 0.0008
The error function E2 (x) = cos(x) − P2 (x). The error function E3 (x) = cos(x) − P3 (x).
Here the polynomial PN (x) is obtained from PN−1 (x) using the recursive
relationship
PN (x) = PN−1 (x) + aN (x − x0 )(x − x1 )(x − x2 ) · · · (x − xN−1 ). (5)
P1 (2.5) = 5 − 2(1.5) = 2,
P2 (2.5) = P1 (2.5) + 0.5(1.5)(−0.5) = 1.625,
P3 (2.5) = P2 (2.5) − 0.1(1.5)(−0.5)(−1.5) = 1.5125,
P4 (2.5) = P3 (2.5) + 0.003(1.5)(−0.5)(−1.5)(−2.0) = 1.50575.
Nested Multiplication
If N is fixed and the polynomial PN (x) is evaluated many times, then
nested multiplication should be used. The process is similar to nested
multiplication for ordinary polynomials, except that the centers xk must
be subtracted from the independent variable x. The nested
multiplication form for P3 (x) is
P3 (x) = ((a3 (x − x2 ) + a2 )(x − x1 ) + a1 )(x − x0 ) + a0 . (6)
To evaluate P3 (x) for a given value of x, start with innermost grouping
and form successively the quantities
S3 = a3 ,
S2 = S3 (x − x2 ) + a2 ,
S1 = S2 (x − x1 ) + a1 , (7)
S0 = S1 (x − x0 ) + a0 .
The quantity S0 is now P3 (x).
Professor Henry Arguello Numerical methods March 12, 2018 64 / 77
Newton Polynomials
S3 = −0.1,
S2 = −0.1(2.5 − 4) + 0.5 = 0.65,
S1 = 0.65(2.5 − 3) − 2 = −2.325,
S0 = −2.325(2.5 − 1) + 5 = 1.5125.
The values for a0 and a1 in (9) and (10) can be used in (11) to obtain
f (x2 ) − a0 − a1 (x2 − x0 )
a2 =
(x2 − x0 )(x2 − x1 )
f (x2 ) − f (x0 ) f (x1 ) − f (x0 )
= − /(x2 − x1 ).
x2 − x0 x1 − x0
f [xk ] = f (xk ),
f [xk ] − f [xk−1 ]
f [xk−1 , xk ] = ,
xk − xk−1
f [xk−1 , xk ] − f [xk−2 , xk−1 ]
f [xk−2 , xk−1 , xk ] = , (13)
xk − xk−2
f [xk−2 , xk−1 , xk ] − f [xk−3 , xk−2 , xk−1 ]
f [xk−3 , xk−2 , xk−1 , xk ] = .
xk − xk−3
(14)
xk f [xk ] f[ , ] f[ , , ] f[ , , , ] f[ , , , , ]
x0 f [x0 ]
x1 f [x1 ] f [x0 , x1 ]
x2 f [x2 ] f [x1 , x2 ] f [x0 , x1 , x2 ]
x3 f [x3 ] f [x2 , x3 ] f [x1 , x2 , x3 ] f [x0 , x1 , x2 , x3 ]
x4 f [x4 ] f [x3 , x4 ] f [x2 , x3 , x4 ] f [x1 , x2 , x3 , x4 ] f [x0 , x1 , x2 , x3 , x4 ]
If f ∈ CN+1 [a, b], then for each x ∈ [a, b] there corresponds a number
c = c(x) in (a, b), so that the error term has the form
Remark. The error term EN (x) is the same as the one for Lagrange interpolation,
which was introduced in equation (16) of Section 4.3.
Table 4.9 Divided-Difference Table Used for Constructing the Newton Polynomial P3 (x)
First Second Third Fourth Fifth
divided divided divided divided divided
xk f [xk ] difference difference difference difference difference
x0 = 1 −3
x1 = 2 0 3
x2 = 3 15 15 6
x3 = 4 48 33 9 1
x4 = 5 105 57 12 1 0
x5 = 6 192 87 15 1 0 0
Table 4.10 Divided-Difference Table Used for Constructing the Newton Polynomials Pk (x)
xk f [xk ] f[ , ] f[ , , ] f[ , , , ] f[ , , , , ]
x0 = 0.0 1.0000000
y = P1 H x L
0.5 0.5
x x
1 2 3 1 2 3
- 0.5 - 0.5
y = cos(x)
y = P2 H x L
y = cos(x)
-1.0 -1.0
y
1.0
0.5
x
1 2 3
y = P3H xL
- 0.5
y = cos(x)
- 1.0