More examples of Lagrange interpolation

Appendix E
More examples of Lagrange
interpolation
E.1
Lagrange polynomials
We wish to nd the polynomial interpolating the points
x
f (x)
1
1.3
1.6
1.9
2.2
0.1411 −0.6878 −0.9962 −0.5507 0.3115
where f (x) = sin(3x), and estimate f (1.5).
First, we nd Lagrange polynomials Lk (x), k = 1 . . . 5,
(x − 1)(x − 1.6)(x − 1.9)(x − 2.2)
(x − 1.3)(x − 1.6)(x − 1.9)(x − 2.2)
, L2 (x) =
(1 − 1.3)(1 − 1.6)(1 − 1.9)(1 − 2.2)
(1.3 − 1)(1.3 − 1.6)(1.3 − 1.9)(1.3 − 2.2)
(x − 1)(x − 1.3)(x − 1.9)(x − 2.2)
(x − 1)(x − 1.3)(x − 1.6)(x − 2.2)
L3 (x) =
, L4 (x) =
(1.6 − 1)(1.6 − 1.3)(1.6 − 1.9)(1.6 − 2.2)
(1.9 − 1)(1.9 − 1.3)(1.9 − 1.6)(1.9 − 2.2)
(x − 1)(x − 1.3)(x − 1.6)(x − 1.9)
L5 (x) =
(2.2 − 1)(2.2 − 1.3)(2.2 − 1.6)(2.2 − 1.9))
L1 (x) =
with the following graphs,
1.0
1.5
0.8
1.0
L2(x)
L1(x)
0.6
0.4
0.5
0.2
0.0
1.0
−0.2
0.0
1.0
1.2
1.4
1.6
1.8
2.0
2.2
−0.5
71
1.2
1.4
1.6
1.8
2.0
2.2
72
1.0
1.5
0.5
1.0
0.0
1.0
1.2
1.4
1.6
1.8
2.0
L4(x)
L3(x)
E.2 Convergence of Lagrange interpolation
2.2
0.5
−0.5
0.0
1.0
−1.0
1.2
1.4
1.6
1.8
2.0
2.2
−0.5
1.0
0.8
L5(x)
0.6
0.4
0.2
0.0
1.0
−0.2
1.2
1.4
1.6
1.8
2.0
2.2
Clearly, Lk (xi ) = δik . Next, the polynomial approximation can be assembled,
P (x) = 0.1411 × L1 (x) − 0.6878 × L2 (x) − 0.9962 × L3 (x) − 0.5507 × L4 (x) + 0.3115 × L5 (x).
1.0
sin(3x)
P(x)
0.5
0.0
0
1
2
3
−0.5
−1.0
The interpolating polynomial approximates accurately the function f (x) = sin(3x) in the
interval [1, 2.2], with ve points only.
So, P (1.5) ≈ −0.9773 is an approximate to f (1.5) = sin(4.5) ≈ −0.9775 accurate within
E ≈ 2 × 10−4 .
E.2
Convergence of Lagrange interpolation
First, consider, P (x), the polynomial interpolating f (x) = cos(x) through a set of equidistant
points in the interval [−5, 5].
73
Chapter E More examples of Lagrange interpolation
1.0
n=6
−4
1.0
cos(x)
n=11
0.5
−2
P(x)
0.0
0
2
4
−4
0.5
−2
0.0
0
−0.5
−0.5
−1.0
−1.0
−1.5
−1.5
2
4
Clearly, increasing the number of equidistant points from n = 6 (left panel) to n = 11 (right
panel) signicantly improves the approximation of f (x) by the polynomial P . In the right
panel, the 10th order interpolating polynomial (solid line) matches perfectly with the function
cos(x).
However, Lagrange interpolation is not always accurate. For instance, consider the polynomial
interpolating the Lorentz function, f (x) = 1/(1 + x2 ), through a set of equidistant points in
the interval [−5, 5].
1.0
n=6
2.0
1/(1+x2)
n=11
0.8
1.5
0.6
1.0
0.4
P(x)
0.5
0.2
−4
−2
0.0
0
−0.2
2
−4
4
−2
0.0
0
2
4
−0.5
Increasing the number of equidistant points from n = 6 (left panel) to n = 11 (right panel)
improves the polynomial interpolation in the central part of f (x), but large oscillations are
present in the at region.
20
−4
−2
0
0
2
4
−20
n=21
−40
−60
If the number of equidistant interpolation points is increased further, these oscillations get
even larger. The interpolating polynomial of degree n − 1, P (x), does not converge to the
function 1/(1 + x2 ) as n → ∞.