0% found this document useful (0 votes)
11 views

Weak 2

The document discusses interpolation and polynomial approximation. It introduces Lagrange polynomials and the Weierstrass approximation theorem, which states that polynomials can uniformly approximate continuous functions on closed intervals. It also provides an example of using Lagrange polynomials to interpolate data points and calculate the interpolation error.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Weak 2

The document discusses interpolation and polynomial approximation. It introduces Lagrange polynomials and the Weierstrass approximation theorem, which states that polynomials can uniformly approximate continuous functions on closed intervals. It also provides an example of using Lagrange polynomials to interpolate data points and calculate the interpolation error.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Interpolation and Polynomial Approximation

Mg. Dennis Quispe Sánchez

March 19, 2024

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 1 / 28
Outline

1 Introduction

2 Weierstrass Approximation Theorem

3 Lagrange Polynomial

4 Newton Polynomial
Divided Dierences

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 2 / 28
Introduction

One of the most useful and well-known classes of functions mapping the
set of real numbers into itself is the algebraic polynomials, the set of
functions of the form
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 given any function, dened and
continuous on a closed and bounded interval, there exists a polynomial that
is as "close" to the given function as desired. This result is expressed
precisely in the Weierstrass Approximation Theorem.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 3 / 28
Introduction

Figure: Approximation Theorem.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 4 / 28
Theorem 1
Suppose f is dened and continuous on [a, b]. For each ε > 0, there exists
a polynomial P(x) with the property that
|f (x) − P(x)| < ε,

for all x in [a, b]. The proof of this theorem can be found in most
elementary texts on real analysis.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 5 / 28
Consider the construction of a polynomial of degree at most n that passes
through the n + 1 points
(x0 , f (x0 )), (x1 , f (x1 )), . . . , (xn , f (xn )).

In this case, we rst construct, for each k = 0, 1, . . . , n, a function Lnk (x)


with the property that Lnk (xi ) = 0 when i ̸= k and Lnk (xk ) = 1. To satisfy
Lnk (xi ) = 0 for each i ̸= k requires that the numerator of Lnk (x) contain the
term
(x − x0 )(x − x1 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn ).
To satisfy Lnk (xk ) = 1, the denominator of Lnk (x) must be this same term
but evaluated at x = xk . Thus,
(x − x0 )(x − x1 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn )
Lnk (x) = .
(xk − x0 )(xk − xk−1 )(xk − xk+1 ) · · · (xk − xn )

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 6 / 28
Figure: Graph of a typical Lnk (x) (when n is even).

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 7 / 28
The interpolating polynomial is easily described once the form of Lnk is
known. This polynomial, called the n-th Lagrange interpolating polynomial,
is dened in the following theorem:
Theorem 2 (1795)
If x0 , x1 , . . . , xn are n + 1 distinct numbers and f is a function whose values
are given at these numbers, then a unique polynomial P(x) of degree at
most n exists with f (xk ) = P(xk ), for each k = 0, 1, . . . , n. This
polynomial is given by
n
X
P(x) = f (x0 )Ln,0 (x) + · · · + f (xn )Ln,n (x) = f (xk )Ln,k (x),
k=0

where, for each k = 0, 1, . . . , n,


(x − x0 )(x − x1 ) · · · (x − xk−1 )(x − xk+1 ) · · · (x − xn )
Ln,k (x) = .
(xk − x0 )(xk − x1 )(xk − xk−1 )(xk − xk+1 ) · · · (xk − xn )

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 8 / 28
Example 1
(a) Use the numbers (called nodes) x0 = 2, x1 = 2.75, and x2 = 4 to nd
the second Lagrange interpolating polynomial for f (x) = x1 .
(b) Use this polynomial to approximate f (3) = 13 .

Solution
(a) We rst determine the coecient polynomials L0 (x), L1 (x), and L2 (x).
In nested form, they are
(x − 2.75)(x − 4) 2
L0 (x) = = (x − 2.75)(x − 4),
(2 − 2.75)(2 − 4) 3
(x − 2)(x − 4) 16
L1 (x) = = − (x − 2)(x − 4),
(2.75 − 2)(2.75 − 4) 15
and
(x − 2)(x − 2.75) 2
L2 (x) = = (x − 2)(x − 2.75).
(4 − 2)(4 − 2.75) 5
Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 9 / 28
Solution
También, dado que f (x0 ) = 12 , f (x1 ) = 4
11 , y f (x2 ) = 14 , podemos calcular
el polinomio interpolante P(x) como:
2
X
P(x) = f (xk )Lk (x) = f (x0 )L0 (x) + f (x1 )L1 (x) + f (x2 )L2 (x),
k=0

Sustituyendo los valores dados de f (x0 ), f (x1 ), y f (x2 ) junto con sus
respectivos polinomios Lk (x) en la ecuación, obtenemos:

1 64 1
P(x) = (x − 2.75)(x − 4) − (x − 2)(x − 4) + (x − 2)(x − 2.75).
3 165 10
Simplicando esta expresión, obtenemos:
1 2 35 49
P(x) = x − x+ .
22 88 44
Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 10 / 28
1
(b) An approximation to f (3) = 3 (see Figure 3.6) is
9 105 49
f (3) ≈ P(3) = − + = 0.32955.
22 88 44

Figure: Example 1

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 11 / 28
Lagrange interpolating polynomial

1 def calculate_Lk ( nodes , k , x ) :


2 numerator = 1
3 denominator = 1
4 for i in range ( len ( nodes ) ) :
5 if i != k :
6 numerator *= ( x - nodes [ i ])
7 denominator *= ( nodes [ k ] - nodes [ i ])
8 return numerator / denominator
9

10 def calculate_polynomial ( nodes , values , x ) :


11 polynomial = 0
12 for k in range ( len ( nodes ) ) :
13 Lk = calculate_Lk ( nodes , k , x )
14 polynomial += values [ k ] * Lk
15 return polynomial

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 12 / 28
Simulation

Figure: Results.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 13 / 28
Theorem 3
Suppose x0 , x1 , . . . , xn are distinct numbers in the interval [a, b] and
f ∈ C n+1 [a, b]. Then, for each x in [a, b], a number ξ(x) (generally
unknown) between min{x0 , x1 , . . . , xn } and max{x0 , x1 , . . . , xn } and hence
in (a, b), exists with
f (n+1) (ξ(x))
f (x) = P(x) + (x − x0 )(x − x1 ) · · · (x − xn ),
(n + 1)!

where P(x) is the interpolating polynomial given in Theorem 2.


The error formula in Theorem 3 is an important theoretical result because
Lagrange polynomials are used extensively for deriving numerical
dierentiation and integration methods. Error bounds for these techniques
are obtained from the Lagrange error formula.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 14 / 28
Example 2

In Example 1, we found the second Lagrange polynomial for f (x) = x1 on


[2, 4] using the nodes x0 = 2, x1 = 2.75, and x2 = 4. Determine the error
formula for this polynomial and the maximum error when the polynomial is
used to approximate f (x) for x ∈ [2, 4].

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 15 / 28
Solution: Because f (x) = x −1 , we have f ′ (x) = −x −2 , f ′′ (x) = 2x −3 , and
f ′′′ (x) = −6x −4 . As a consequence, the second Lagrange polynomial has
the error form:
f ′′′ (ξ(x)) (ξ(x))−4
(x −x0 )(x −x1 )(x −x2 ) = − (x − 2)(x − 2.75)(x − 4), for
3! 16
(ξ(x))−4 1
ξ(x) ∈ (2, 4) The maximum value of on the interval is 16
16 . We now
need to determine the maximum value on this interval of the absolute value
of the polynomial:
35 2 7
g (x) = (x − 2)(x − 2.75)(x − 4) = x 3 − x + x − 22.
4 4

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 16 / 28
Because
35 2 49 35 49 1
 
Dx x − x + x − 22 = 3x 2 − x +
3
= (3x − 7)(2x − 7),
4 2 2 2 2
the critical points occur at x = 73 with g (7/3) = 25/108 and x = 7
2 with
g (7/2) = −9/16. Hence, the maximum error is

f ′′′ (ξ(x)) 1 −9 9
|(x − x0 )(x − x1 )(x − x2 )| ≤ = ≤ 0.03515625.
3! 16 16 256

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 17 / 28
Divided Dierences

Suppose that Pn (x) is the n-th interpolating polynomial that agrees with
the function f at the distinct numbers x0 , x1 , . . . , xn . Although this
polynomial is unique, there are alternate algebraic representations that are
useful in certain situations. The divided dierences of f with respect to
x0 , x1 , . . . , xn are used to express Pn (x) in the form:

Pn (x) = a0 +a1 (x−x0 )+a2 (x−x0 )(x−x1 )+. . .+an (x−x0 )(x−x1 ) · · · (x−xn−1 ),

for appropriate constants a0 , a1 , . . . , an . To determine the rst of these


constants, a0 , note that if evaluating Pn (x) at x0 leaves only the constant
term a0 ; that is,
a0 = Pn (x0 ) = f (x0 ).

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 18 / 28
Similarly, when P(x) is evaluated at x1 , the only nonzero terms in the
evaluation of Pn (x1 ) are the constant and linear terms,
f (x0 ) + a1 (x1 − x0 ) = Pn (x1 ) = f (x1 ),

so
f (x1 ) − f (x0 )
a1 = .
x1 − x0
The zeroth divided dierence of the function f with respect to xi , denoted
f [xi ], is simply the value of f at xi , denoted as f (xi ), given by:

f [xi ] = f (xi ).

The remaining divided dierences are dened recursively; the rst divided
dierence of f with respect to xi and xi+1 is denoted f [xi , xi+1 ] and
dened as:
f [xi+1 ] − f [xi ]
f [xi , xi+1 ] = , xi+1 ̸= xi .
xi+1 − xi

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 19 / 28
The second divided dierence, f [xi , xi+1 , xi+2 ], is dened as:
f [xi+1 , xi+2 ] − f [xi , xi+1 ]
f [xi , xi+1 , xi+2 ] = .
xi+2 − xi

Similarly, after the (k − 1)-st divided dierences,


f [xi , xi+1 , xi+2 , . . . , xi+k−1 ] and f [xi+1 , xi+2 , . . . , xi+k ], have been
determined, the k -th divided dierence relative to xi , xi+1 , xi+2 , . . . , xi+k is:
f [xi+1 , xi+2 , . . . , xi+k ] − f [xi , xi+1 , xi+2 , . . . , xi+k−
f [xi , xi+1 , xi+2 , . . . , xi+k ] =
xi+k − xi

The process ends with the single n-th divided dierence:


f [x1 , x2 , . . . , xn ] − f [x0 , x1 , . . . , xn−1 ]
f [x0 , x1 , . . . , xn ] = .
xn − x0

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 20 / 28
We can write a1 = f [x0 , x1 ], just as a0 can be expressed as f [x0 ] = f [x0 ].
Hence, the interpolating polynomial is:
Pn (x) = f [x0 ] + f [x0 , x1 ](x − x0 ) + · · · + an (x − x0 )(x − x1 ) · · · (x − xn−1 ).

As might be expected from the evaluation of a0 and a1 , the required


constants are:
ak = f [x0 , x1 , x2 , . . . , xk ],
for each k = 0, 1, . . . , n. So, Pn (x) can be rewritten in a form called
Newton's Divided-Dierence:
n
X
Pn (x) = f [x0 ] + f [x0 , x1 , . . . , xk ](x − x0 )(x − x1 ) · · · (x − xk−1 ).
k=1

The value of f [x0 , x1 , . . . , xk ] is independent of the order of the numbers


x0 , x1 , . . . , xk .

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 21 / 28
Divided Dierences

Figure: Table: Divided Dierences.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 22 / 28
Newton Divided Dierences Formula

To obtain the divided-dierence coecients of the interpolatory polynomial


P on the (n + 1) distinct numbers x0 , x1 , . . . , xn for the function f :
INPUT: numbers x0 , x1 , . . . , xn ; values f (x0 ), f (x1 ), . . . , f (xn ) as
F0,0 , F1,0 , . . . , Fn,0 .
OUTPUT: the numbers F0,0 , F1,1 , . . . , Fn,n where
n
X i−1
Y
Pn (x) = F0,0 + Fi,i (x − xj )
i=1 j=0

Step 1: For i = 1, 2, . . . , n
For j = 1, 2, . . . , i
Set Fi,j = Fi,j−1 −Fi−1,j−1
xi −xi−j (where Fi,j = [xi , xi−1 , . . . , xi−j ]).
Step 2: OUTPUT (F0,0 , F1,1 , . . . , Fn,n ); STOP.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 23 / 28
Example2

Complete the divided dierence table for the data in the Table, and
construct the interpolating polynomial that uses all these data.

Figure: Table 1: Data.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 24 / 28
Solution: The rst divided dierence involving x0 and x1 is
f [x1 ] − f [x0 ] 0.6200860 − 0.7651977
f [x0 , x1 ] = = = −0.4837057.
x1 − x0 1.3 − 1.0
The remaining rst divided dierences are found in a similar manner and
are shown in the fourth column in Table 2

Figure: Table 2: Divided Dierences.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 25 / 28
The second divided dierence involving x0 , x1 , and x2 is
f [x1 , x2 ] − f [x0 , x1 ] −0.5489460 − (−0.4837057)
f [x0 , x1 , x2 ] = = =
x2 − x0 1.6 − 1.0
−0.1087339. The remaining second divided dierences are shown in the
5th column of Table 2.
The third divided dierence involving x0 , x1 , x2 , and x3 and the fourth
divided dierence involving all the data points are, respectively,
f [x1 , x2 , x3 ] − f [x0 , x1 , x2 ] −0.0494433 − (−0.1087339)
f [x0 , x1 , x2 , x3 ] = =
x3 − x0 1.9 − 1.0
= 0.0658784 and
f [x1 , x2 , x3 , x4 ] − f [x0 , x1 , x2 , x3 ] 0.0680685 − 0.06587
f [x0 , x1 , x2 , x3 , x4 ] = =
x4 − x0 2.2 − 1.0
= 0.0018251

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 26 / 28
Figure: Code in Pyhton.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 27 / 28
Figure: Results.

Mg. Dennis Quispe Sánchez Interpolation and Polynomial Approximation March 19, 2024 28 / 28

You might also like