More Examples of Lagrange Interpolation: Appendix E

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Appendix E

More examples of Lagrange


interpolation
E.1 Lagrange polynomials

We wish to nd the polynomial interpolating the points

x 1 1.3 1.6 1.9 2.2


f (x) 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.3)(x − 1.6)(x − 1.9)(x − 2.2) (x − 1)(x − 1.6)(x − 1.9)(x − 2.2)


L1 (x) = , 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))

with the following graphs,


1.0 1.5

0.8
1.0
0.6
L1(x)

L2(x)

0.4 0.5

0.2
0.0
0.0 1.0 1.2 1.4 1.6 1.8 2.0 2.2
1.0 1.2 1.4 1.6 1.8 2.0 2.2
−0.2 −0.5

71
72 E.2 Convergence of Lagrange interpolation

1.0 1.5

0.5 1.0
L3(x)

L4(x)
0.0 0.5
1.0 1.2 1.4 1.6 1.8 2.0 2.2

−0.5 0.0
1.0 1.2 1.4 1.6 1.8 2.0 2.2

−1.0 −0.5

1.0

0.8

0.6
L5(x)

0.4

0.2

0.0
1.0 1.2 1.4 1.6 1.8 2.0 2.2
−0.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)

0.5
P(x)

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].
Chapter E  More examples of Lagrange interpolation 73

1.0 cos(x) 1.0

n=6 0.5 n=11 0.5

0.0 0.0
−4 −2 0 2 4 −4 −2 0 2 4

−0.5 −0.5

−1.0 −1.0

P(x)
−1.5 −1.5

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 2.0
1/(1+x2)
n=11
n=6 0.8
1.5

0.6
1.0
0.4 P(x)
0.5
0.2

0.0
0.0 −4 −2 0 2 4
−4 −2 0 2 4
−0.2 −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

0
−4 −2 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 → ∞.

You might also like