Numerica Analysis 1
Numerica Analysis 1
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 78
3.1 Interpolation and the Lagrange Polynomial
Interpolation
One of the most useful and
well-known classes of functions mapping the set of real numbers
into itself is the algebraic(x
polynomials, the set of functions of the form
Given data points i , yi ) : i = 1, . . . , n , can we find a function
to “fit” the data? Pn (x) = an x n + an−1 x n−1 + · · · + a1 x + a0 ,
where n is a nonnegative integer and a0 , . . . , an are real constants. One reason for their
importance is that they uniformly approximate continuous functions. By this we mean that
Theorem (Weierstrass
given any function, defined andapproximation
continuous on a closedtheorem)
and bounded interval, there exists
a polynomial
Suppose f ∈that is asb],
C [a, “close”
thento ∀
thegiven
> 0,function as desired. ThisP(x)
∃ a polynomial result issuch
expressed
that
precisely in the Weierstrass Approximation Theorem. (See Figure 3.1.)
|f (x) − P(x)| < , ∀ x ∈ [a, b].
Figure 3.1
y
y ! f(x) " ε
y ! P(x)
y ! f(x)
y ! f(x) # ε
a b x
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 79
Polynomial interpolation
0 1 (n)
f (x) ≈ Pn (x) := f (x0 ) + f (x0 )(x − x0 ) + · · · + f (x0 )(x − x0 )n
n!
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 80
Polynomial interpolation
1 n
Solution. Taylor’s polynomial Pn (x) = 1 + x + · · · + n! x .
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 81
functions, had P4 (x) = 1 + x + + + , and P5 (x) = 1 + x + + + + .
2 6 24 2 6 24 120
fluence on an entire
Issue withTheTaylor’s
f students. polynomial
graphs of the polynomials are shownapproximation
in Figure 3.2. (Notice that even for the
higher-degree polynomials, the error becomes progressively worse as we move away from
zero.)
Figure 3.2
y
20
y " P5(x)
y " ex
y " P4(x)
15
y " P3(x)
10
y " P2(x)
5
y " P1(x)
y " P0(x)
!1 1 2 3 x
(−1)n n!
Solution. We know f (n) (x) = x n+1
. Then Taylor’s polynomial is
n
X
Pn (x) = (−1)n (x−1)n = 1−(x−1)+(x−1)2 +· · ·+(−1)n (x−1)n
i=0
Suppose we use Pn (x) to approximate f at x = 3, we get
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 83
Lagrange interpolating polynomial
Suppose we have two points (x0 , y0 ) and (x1 , y1 ), then best use a
straight line to interpolate. Define two linear polynomials:
x − x1 x − x0
L0 (x) = and L1 (x) =
x0 − x1 x1 − x0
So L0 and L1 are polynomials of degree 1, and
Now set P(x) = f (x0 )L0 (x) + f (x1 )L1 (x), then P(x) coincides
f (x) at x0 and x1 .
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 84
Example
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 85
Lagrange interpolating polynomial
Given n + 1 points (xi , f (xi )) : 0 ≤ i ≤ n . For each i, define:
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 86
Lagrange interpolating polynomial
The interpolating polynomial is easily described once the form of Ln,k is known. This
polynomial, called the nth Lagrange interpolating polynomial, is defined in the following
theorem.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 87
Lagrange interpolating polynomial
Properties:
I P(x) is a polynomial of degree n
I P(xk ) = f (xk ) for all k = 0, . . . , n.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 88
Example
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 89
9 105 49 29
f (3) ≈ P(3) = − + = ≈ 0.32955.
Example 22 88 44 88
Recall that in the opening section of this chapter (see Table 3.1) we found that no Taylor
polynomial expanded about x0 = 1 could be used to reasonably approximate f (x) = 1/x
at x Example
= 3. (Lagrange interpolating polynomial)
Let f (x) = x1 , x0 = 2, x1 = 2.75, x2 = 4. Find the 2nd Lagrange
interpolating polynomial P(x) of f (x) and compute P(3).
e 3.6
y
2 y ! f (x)
1
y ! P(x)
1 2 3 4 5 x
f (n+1) (ξ(x))
f (x) = P(x) + (x − x0 ) . . . (x − xn )
(n + 1)!
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 91
Error of Lagrange interpolating polynomial
Proof.
For any given x ∈ [a, b] different from x0 , . . . , xn , define g (t) as
(t − x0 ) . . . (t − xn )
g (t) = f (t) − P(t) − (f (x) − P(x))
(x − x0 ) . . . (x − xn )
| {z }
polynomial of t, degree n + 1
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 93
Example
Solution. Let P(x) be the Lagrange interpolating polynomial, then
f (3) (ξ(x))
f (x) − P(x) = (x − 2)(x − 2.75)(x − 4)
3!
We know f 0 (x) = − x12 , f 00 (x) = x23 , f 000 (x) = − x3!4 , so
f (3) (ξ(x)) 1 1
= − 4 ≤ 4 (∵ ξ(x) ∈ [2, 4])
3! (ξ(x)) 2
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 94
Example
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 95
Example
1 (2)
f (ξ(x))(x − xj )(x − xj+1 )
2
f (2) (ξ(x)) e ξ(x) e
So | 2 | = | 2 | ≤ 2 (∵ ξ(x) ∈ [0, 1]).
h2
Again take h(x) = (x − xj )(x − xj+1 ) which has max Then 2.
f (2) (ξ(x)) e h2
(x − xj )(x − xj+1 ) ≤ ≤ 10−6
2 2 4
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 96
Recursive constructions of interpolating polynomials
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 97
Example
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 98
Neville’s method
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 99
Example
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 100
Recursive construction of interpolating polynomials
(x − xj )P0,...,j,...,k
ˆ (x) − (x − xi )P0,...,i,...,k
ˆ (x)
P0,1,...,k (x) =
xi − xj
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 101
Recursive construction of interpolating polynomials
Proof.
Denote the RHS by P(x).
Both P0,...,j,...,k
ˆ (x) and P0,...,i,...,k
ˆ (x) are polynomials of degree
k − 1, we know P(x) is a polynomial of degree ≤ k.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 102
Neville’s method
x0 P0
(x−x0 )P1 −(x−x1 )P0
x1 P1 P0,1 = x1 −x0
(x−x1 )P2 −(x−x2 )P1 (x−x0 )P1,2 −(x−x2 )P0,1
x2 P2 P1,2 = x2 −x1 P0,1,2 = x2 −x0
(x−x2 )P3 −(x−x3 )P2 (x−x1 )P2,3 −(x−x3 )P1,2 ..
x3 P3 P2,3 = x3 −x2 P1,2,3 = x3 −x1
.
(x−x3 )P4 −(x−x4 )P3 (x−x2 )P3,4 −(x−x4 )P2,3
x4 P4 P3,4 = x4 −x3 P2,3,4 = x4 −x2 ...
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 103
Neville’s method
x0 Q0,0
x1 Q1,0 Q1,1
x2 Q2,0 Q2,1 Q2,2
x3 Q3,0 Q3,1 Q3,2 Q3,3
x4 Q4,0 Q4,1 Q4,2 Q4,3 Q4,4
For example Q3,3 = P0,1,2,3 , Q4,3 = P1,2,3,4 , etc.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 104
Example (Neville’s method)
Consider the interpolation of the function f with 5 points:
k xk f (xk )
0 1.0 0.7651977
1 1.3 0.6200860
2 1.6 0.4554022
3 1.9 0.2818186
4 2.2 0.1103623
2
The data in this table were retrieved from a Bessel function with true value
f (1.5) = 0.5118277.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 105
Neville’s iterated interpolation
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 106
Divided difference
We can also get the polynomials, not just the interpolating values.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 107
Divided difference
We define the following notations of divided difference:
f [xi ] = f (xi )
f [xi+1 ] − f [xi ]
f [xi , xi+1 ] =
xi+1 − xi
f [xi+1 , xi+2 ] − f [xi , xi+1 ]
f [xi , xi+1 , xi+2 ] =
xi+2 − xi
..
.
Once the (k − 1)th divided differences are determined, we can get
the kth divided difference as
f [x1 , . . . , xk ] − f [x0 , . . . , xk−1 ]
f [x0 , . . . , xk ] =
xk − x0
until we get f [x0 , . . . , xn ]. Then set ak = f [x0 , . . . , xk ] for all k:
n
X
Pn (x) = f [x0 ] + f [x0 , . . . , xk ](x − x0 ) . . . (x − xk )
k=1
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 108
Divided difference
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 ]
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 109
Divided difference
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 110
Newton’s divided difference formula
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 111
Special case
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 112
Special case
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 113
Backward difference
We can also use the backward differences:
Pn (x) = f [xn ]+f [xn , xn−1 ](x−xn )+· · ·+f [xn , . . . , x0 ](x−xn ) . . . (x−x1 ).
3
For example, ∇2 pn = (pn − pn−1 ) − (pn−1 − pn−2 ) = pn − 2pn−1 + pn−2 .
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 114
Hermite interpolation
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 115
Hermite polynomial
We’re mostly interested in the case with mi = 1, ∀ i. That is, we
have f (xi ) and f 0 (xi ) at each xi .
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 116
Hermite polynomial
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 117
Hermite polynomial
Proof.
It’s clear the degree ≤ n + 1. Also,
(
0, if i 6= j
Hn,j (xi ) = and Ĥn,j (xi ) = 0, ∀i
1, if i = j
Therefore
(
0 0 0, if i 6= j
Hn,j (xi ) = 0 ∀ i, and Ĥn,j (x) =
1, if i = j
0
Hence H2n+1 (x) = f 0 (xi ), ∀ i.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 118
Hermite polynomials
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 119
Hermite polynomial
z 0 = x0 f [z0 ] = f (x0 )
z 1 = x0 f [z1 ] = f (x0 ) f [z0 , z1 ] = f 0 (x0 )
f [z2 ]−f [z1 ]
z 2 = x1 f [z2 ] = f (x1 ) f [z1 , z2 ] = z2 −z1
f [z0 , z1 , z2 ]
0
z 3 = x1 f [z3 ] = f (x1 ) f [z2 , z3 ] = f (x1 ) f [z1 , z2 , z3 ] f [z0 , z1 , z2 , z3 ]
f [z4 ]−f [z3 ]
z 4 = x2 f [z4 ] = f (x2 ) f [z3 , z4 ] = z4 −z3
f [z2 , z3 , z4 ] f [z1 , z2 , z3 , z4 ] f [z0 , z1 , z2 , z3 , z4 ]
0
z 5 = x3 f [z5 ] = f (x3 ) f [z4 , z5 ] = f (x2 ) f [z3 , z4 , z5 ] f [z2 , z3 , z4 , z5 ] f [z1 , z2 , z3 , z4 , z5 ]
.
.
.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 120
Hermite interpolation
Qi,j−1 − Qi−1,j−1
Qi,j =
zi − zi−j
I Output. Hermite polynomial coeff. Q0,0 , . . . , Q2n+1,2n+1 , s.t.
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 121