Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

CHAPTER 5 (8 LECTURES)

POLYNOMIAL INTERPOLATION AND APPROXIMATIONS

1. Introduction
Polynomials are used as the basic means of approximation in nearly all areas of numerical analysis.
They are used in the solution of equations and in the approximation of functions, of integrals and
derivatives, of solutions of integral and differential equations, etc. Polynomials have simple structure,
which makes it easy to construct effective approximations and then make use of them. For this reason,
the representation and evaluation of polynomials is a basic topic in numerical analysis. We discuss this
topic in the present chapter in the context of polynomial interpolation, the simplest and certainly the
most widely used technique for obtaining polynomial approximations.
Definition 1.1 (Polynomial). A polynomial Pn (x) of degree ≤ n is, by definition, a function of the
form
Pn (x) = a0 + a1 x + a2 x2 + · · · + an xn (1.1)
with certain coefficients a0 , a1 , · · · , an . This polynomial has (exact) degree n in case its leading coeffi-
cient an is nonzero.
The power form (1.1) is the standard way to specify a polynomial in mathematical discussions. It is
a very convenient form for differentiating or integrating a polynomial. But, in various specific contexts,
other forms are more convenient. For example, the following shifted power form may be helpful.
P (x) = a0 + a1 (x − c) + a2 (x − c)2 + · · · + an (x − c)n . (1.2)
It is good practice to employ the shifted power form with the center c chosen somewhere in the interval
[a, b] when interested in a polynomial on that interval.
Definition 1.2 (Newton form). A further generalization of the shifted power form is the following
Newton form
P (x) = a0 + a1 x − c1 ) + a2 (x − c1 )(x − c2 ) + · · · + an (x − c1 )(x − c2 ) · · · (x − cn ).
This form plays a major role in the construction of an interpolating polynomial. It reduces to the
shifted power form if the centers c1 , · · · , cn , all equal c, and to the power form if the centers c1 , · · · , cn ,
all equal zero.

2. Lagrange Interpolation
In this chapter, we consider the interpolation problem. Suppose we do not know the function f , but
a few information (data) about f . Now we try to compute a function g that approximates f .

2.1. Polynomial Interpolation. The polynomial interpolation problem, also called Lagrange inter-
polation, can be described as follows: Given (n+1) data points (xi , yi ), i = 0, 1, · · · , n find a polynomial
P of lowest possible degree such
yi = P (xi ), i = 0, 1, · · · , n.
Such a polynomial is said to interpolate the data. Here yi may be the value of some unknown function
f at xi , i.e. yi = f (xi ).
One reason for considering the class of polynomials in approximation of functions is that they uniformly
approximate continuous function.
Theorem 2.1 (Weierstrass Approximation Theorem). Suppose that f is defined and continuous on
[a, b]. For any ε > 0, there exists a polynomial P (x) defined on [a, b] with the property that
|f (x) − P (x)| < ε, ∀x ∈ [a, b].
1
2 INTERPOLATION AND APPROXIMATIONS

Another reason for considering the class of polynomials in approximation of functions is that the
derivatives and indefinite integrals of a polynomial are easy to compute.

Theorem 2.2 (Existence and Uniqueness). Given a real-valued function f (x) and n + 1 distinct points
x0 , x1 , · · · , xn , there exists a unique polynomial Pn (x) of degree ≤ n which interpolates the unknown
f (x) at points x0 , x1 , · · · , xn .

Proof. Existence: Let x0 , x1 , · · · , xn be the given n + 1 discrete data points. We will prove the result
by the mathematical induction.
The Theorem clearly holds for n = 0, only one data point is given and we can take constant polynomial
P0 (x) = f (x0 ), ∀x.
Assume that the Theorem holds for n ≤ k, i.e. there is a polynomial Pk with degree ≤ k such that
Pk (xi ) = f (xi ), for 0 ≤ i ≤ k.
Now we try to construct a polynomial of degree at most k + 1 to interpolate (xi , f (xi )), 0 ≤ i ≤ k + 1.
Let
Pk+1 (x) = Pk (x) + c(x − x0 )(x − x1 ) · · · (x − xk ).
For x = xk+1 ,

Pk+1 (xk+1 ) = f (xk+1 ) = Pk (xk+1 ) + c(xk+1 − x0 )(xk+1 − x1 ) · · · (xk+1 − xk )

f (xk+1 ) − Pk (xk+1 )
=⇒ c = .
(xk+1 − x0 )(xk+1 − x1 ) · · · (xk+1 − xk )
Since xi are distinct, the polynomial Pk+1 (x) is well-defined and degree of Pk+1 ≤ k + 1. Now

Pk+1 (xi ) = Pk (xi ) + 0 = Pk (xi ) = f (xi ), 0 ≤ i ≤ k

and
Pk+1 (xk+1 ) = f (xk+1 )
Above two equations implies
Pk+1 (xi ) = f (xi ), 0 ≤ i ≤ k + 1.
Therefore Pk+1 (x) interpolate f (x) at all k + 2 nodal points. By mathematical induction result is true
for all polynomials.
Uniqueness: Let there are two such polynomials Pn and Qn such that

Pn (xi ) = f (xi )

Qn (xi ) = f (xi ), 0 ≤ i ≤ n.
Define
Sn (x) = Pn (x) − Qn (x)
Since for both Pn and Qn , degree ≤ n, which implies the degree of Sn is also ≤ n.
Also
Sn (xi ) = Pn (xi ) − Qn (xi ) = f (xi ) − f (xi ) = 0, 0 ≤ i ≤ n.
This implies Sn has at least n + 1 zeros which is not possible as degree of Sn is at most n.
This implies
Sn (x) = 0, ∀x

=⇒ Pn (x) = Qn (x), ∀x.


Therefore interpolating polynomial is unique.
INTERPOLATION AND APPROXIMATIONS 3

2.2. Linear Interpolation. We determine a polynomial


P (x) = ax + b (2.1)
where a and b are arbitrary constants satisfying the interpolating conditions f (x0 ) = P (x0 ) and
f (x1 ) = P (x1 ). We have
f (x0 ) = P (x0 ) = ax0 + b
f (x1 ) = P (x1 ) = ax1 + b.
Lagrange interpolation: Solving for a and b, we obtain
f (x0 ) − f (x1 )
a =
x0 − x1
f (x0 )x1 − f (x1 )x0
b =
x1 − x0
Substituting these values in equation (2.1), we obtain
f (x0 ) − f (x1 ) f (x0 )x1 − f (x1 )x0
P (x) = x+
x0 − x1 x1 − x0
x − x1 x − x0
=⇒ P (x) = f (x0 ) + f (x1 )
x0 − x1 x1 − x0
=⇒ P (x) = l0 (x)f (x0 ) + l1 (x)f (x1 )
x − x1 x − x0
where l0 (x) = and l1 (x) = .
x0 − x1 x1 − x0
These functions l0 (x) and l1 (x) are called the Lagrange Fundamental Polynomials and they satisfy the
following conditions.
l0 (x) + l1 (x) = 1.
l0 (x0 ) = 1, l0 (x1 ) = 0
l1 (x0 ) = 0, l1 (x1 ) = 1

1, i = j
=⇒ li (xj ) = δij =
0, i 6= j.
Higher-order Lagrange interpolation: In this section we take a different approach and assume
that the interpolation polynomial is given as a linear combination of n + 1 polynomials of degree n.
This time, we set the coefficients as the interpolated values, {f (xi )}ni=0 , while the unknowns are the
polynomials. We thus let
X n
Pn (x) = f (xi )li (x),
i=0
where li (x) are n + 1 polynomials of degree n. Note that in this particular case, the polynomials li (x)
are precisely of degree n (and not ≤ n). However, Pn (x), given by the above equation may have a
lower degree. In either case, the degree of Pn (x) is n at the most. We now require that Pn (x) satisfies
the interpolation conditions
Pn (xj ) = f (xj ), 0 ≤ j ≤ n.
By substituting xj for x we have
n
X
Pn (xj ) = f (xi )li (xj ), 0 ≤ j ≤ n.
i=0
Therefore we may conclude that li (x) must satisfy
li (xj ) = δij , i, j = 0, 1, · · · , n
where δij is the Kronecker delta, defined as

1, i = j
δij =
6 j.
0, i =
Each polynomial li (x) has n + 1 unknown coefficients. The conditions given above through delta
provide exactly n + 1 equations that the polynomials li (x) must satisfy and these equations can be
4 INTERPOLATION AND APPROXIMATIONS

solved in order to determine all li (x)’s. Fortunately there is a shortcut. An obvious way of constructing
polynomials li (x) of degree n that satisfy the condition is the following:
(x − x0 )(x − x1 ) · · · (x − xi−1 )(x − xi+1 ) · · · (x − xn )
li (x) = .
(xi − x0 )(xi − x1 ) · · · (xi − xi−1 )(xi − xi+1 ) · · · (xi − xn )
The uniqueness of the interpolating polynomial of degree ≤ n given n + 1 distinct interpolation points
implies that the polynomials li (x) given by above relation are the only polynomials of degree n.
Note that the denominator does not vanish since we assume that all interpolation points are distinct.
We can write the formula for li (x) in a compact form using the product notation.
(x − x0 )(x − x1 ) · · · (x − xi−1 )(x − xi+1 ) · · · (x − xn )
li (x) =
(xi − x0 )(xi − x1 ) · · · (xi − xi−1 )(xi − xi+1 ) · · · (xi − xn )
W (x)
= , i = 0, 1, · · · , n
(x − xi )W 0 (xi )
where
W (x) = (x − x0 ) · · · (x − xi−1 )(x − xi )(x − xi+1 ) · · · (x − xn )
∴ W 0 (xi ) = (xi − x0 ) · · · (xi − xi−1 )(xi − xi+1 ) · · · (xi − xn ).
The Lagrange interpolating polynomial can be written as
n n
X Y (x − xj )
Pn (x) = f (xi ) .
(xi − xj )
i=0 j=0
j6=i

Example 1. Given the following four data point. Find a polynomial in Lagrange form to interpolate

xi 0 1 3 5
yi 1 2 6 7

the data.
Sol. The Lagrange functions are given by
(x − 1)(x − 3)(x − 5) 1
l0 (x) = = − (x − 1)(x − 3)(x − 5).
(0 − 1)(0 − 3)(0 − 5) 15
(x − 0)(x − 3)(x − 5) 1
l1 (x) = = (x − 0)(x − 3)(x − 5).
(1 − 0)(1 − 3)(1 − 5) 8
(x − 0)(x − 1)(x − 5) 1
l2 (x) = = − (x)(x − 1)(x − 5).
(3 − 0)(3 − 1)(3 − 5) 12
(x − 0)(x − 1)(x − 3) 1
l3 (x) = = (x)(x − 1)(x − 3).
(5 − 0)(5 − 1)(5 − 3) 40
The interpolating polynomial in the Lagrange form is
P3 (x) = l0 (x) + 2l1 (x) + 6l2 (x) + 7l3 (x).

Example 2. Let f (x) = x − x2 and P2 (x) be the interpolation polynomial on x0 = 0, x1 and x2 = 1.
Find the largest value of x1 in (0, 1) for which f (0.5) − P2 (0.5) = −0.25.
√ p
Sol. If f (x) = x − x2 then our nodes are [x0 , x1 , x2 ] = [0, x1 , 1] and f (x0 ) = 0, f (x1 ) = x1 − x21
and f (x2 ) = 0. Therefore
(x − x1 )(x − x2 ) (x − x1 )(x − 1)
l0 (x) = = ,
(x0 − x1 )(x0 − x2 ) x1
(x − x0 )(x − x2 ) x(x − 1)
l1 (x) = = ,
(x1 − x0 )(x1 − x2 ) x1 (x1 − 1)
(x − x0 )(x − x1 ) x(x − 1)
l2 (x) = = .
(x2 − x0 )(x2 − x1 ) (1 − x1 )
INTERPOLATION AND APPROXIMATIONS 5

∴ P2 (x) = l0 (x)f (x0 ) + l1 (x)f (x1 ) + l2 (x)f (x2 )


(x − x1 )(x − 1) x(x − 1) x(x − 1)
q
= .0 + . x1 − x21 + .0
x1 x1 (x1 − 1) (1 − x1 )
x(x − 1)
= −p .
x1 (1 − x1 )
If we now consider f (x) − P2 (x), then
p x(x − 1)
f (x) − P2 (x) = x − x2 + p .
x1 (1 − x1 )
Hence f (0.5) − P2 (0.5) = −0.25 implies
p 0.5(0.5 − 1)
0.5 − 0.52 + p = −0.25
x1 (1 − x1 )
Solving for x1 gives
x21 − x1 = −1/9
or
(x1 − 1/2)2 = 5/36
q q
which gives x1 = 12 − 36 5
or x1 = 1
2
5
+ 36 .
The largest of these is therefore
r
1 5
x1 = + ≈ 0.8727.
2 36
2.3. Error Analysis for Polynomial Interpolation. We are given nodes x0 , x1 , · · · , xn , and the
corresponding function values f (x0 ), f (x1 ), · · · , f (xn ), but the we don’t know the expression for the
function. Let Pn (x) be the polynomial of order ≤ n that passes through the n + 1 points (x0 , f (x0 )),
(x1 , f (x1 )),· · · , (xn , f (xn )).
Question: What is the error between f (x) and Pn (x) even we don’t know f (x) in advance?
Definition 2.3 (Truncation error). The polynomial P (x) coincides with f (x) at all nodal points and
may deviates at other points in the interval. This deviation is called the truncation error and we write
En (f ; x) = f (x) − P (x).
Theorem 2.4. Suppose that x0 , x1 , · · · , xn are distinct numbers in [a, b] and f ∈ C n+1 [a, b]. Let P (x)
be the unique polynomial of degree ≤ n that passes through n + 1 nodal points then prove that
∀x ∈ [a, b], ∃ξ = ξ(x) ∈ (a, b)
such that
(x − x0 ) · · · (x − xn ) (n+1)
En (f ; x) = f (x) − P (x) = f (ξ).
(n + 1)!
Proof. Let x0 , x1 , · · · , xn are distinct numbers in [a, b] and f ∈ C n+1 [a, b].
Let P (x) be the unique polynomial of degree ≤ n that passes through n + 1 discrete points.
Since f (xi ) = P (xi ), which implies f (x) − P (x) = 0.
Now for any t in the domain, define a function g(t),t ∈ [a, b],
(t − x0 ) · · · (t − xn )
g(t) = f (t) − P (t) − [f (x) − P (x)] (2.2)
(x − x0 ) · · · (x − xn )
Now g(t) ∈ C n+1 [a, b] as f ∈ C n+1 [a, b] and P (x) ∈ C n+1 [a, b].
Now g(t) = 0 at t = x, x0 , x1 , ....., xn . Therefore g(t) satisfy the conditions of Rolle’s Theorem which
states that between n + 2 zeros of a function, there is at least one zero of (n + 1)th derivative of the
function. Hence there exists a point ξ such that
g (n+1) (ξ) = 0
6 INTERPOLATION AND APPROXIMATIONS

where ξ ∈ (a, b) and depends on x.


Now differentiate function g(t) (n + 1) times to obtain
(n + 1)!
g (n+1) (t) = f (n+1) (t) − P (n+1) (t) − [f (x) − P (x)]
(x − x0 ) · · · (x − xn )
(n + 1)!
= f (n+1) (t) − [f (x) − P (x)]
(x − x0 ) · · · (x − xn )
Here P (n+1) (t) = 0 as P (x) is a n-th degree polynomial.
Now g (n+1) (ξ) = 0 and then solving for f (x) − P (x), we obtain
(x − x0 ) · · · (x − xn ) (n+1)
f (x) − P (x) = f (ξ)
(n + 1)!

Corollary 2.5. If |f (n+1) (ξ)| ≤ M then we can obtain a bound of the error
M
|f (x) − P (x)| ≤ max |(x − x0 ) · · · (x − xn )|.
(n + 1)! x∈[a,b]
The next example illustrates how the error formula can be used to prepare a table of data that will
ensure a specified interpolation error within a specified bound.
Example 3. Suppose a table is to be prepared for the function f (x) = ex , for x in [0, 1]. Assume
the number of decimal places to be given per entry is d ≥ 8 and that the difference between adjacent
x−values, the step size, is h. What step size h will ensure that linear interpolation gives an absolute
error of at most 10−6 for all x in [0, 1]?
Sol. Let x0 , x1 , . . . be the numbers at which f is evaluated, x be in [0, 1], and suppose i satisfies
xi ≤ x ≤ xi+1 .
The error in linear interpolation is
|f 2 (ξ)|

1 2
|f (x) − P (x)| = f (ξ)(x − xi )(x − xi+1 ) =
|(x − xi )||(x − xi+1 )|.
2 2
The step size is h, so xi = ih, xi+1 = (i + 1)h, and
1
|f (x) − p(x)| ≤ |f 2 (ξ)| |(x − ih)(x − (i + 1)h|.
2
Hence
1
|f (x) − p(x)| ≤ max eξ max |(x − ih)(x − (i + 1)h|
2 ξ∈[0,1] xi ≤x≤xi+1
e
≤ max |(x − ih)(x − (i + 1)h|.
2 xi ≤x≤xi+1
Consider the function g(x) = (x − ih)(x − (i + 1)h), for ih ≤ x ≤ (i + 1)h. Because
h
g 0 (x) = (x − (i + 1)h) + (x − ih) = 2 x − ih − ),
2
the only critical point for g is at x = ih + h/2, with g(ih + h/2) = (h/2) = h2 /4. Since g(ih) = 0 and
2

g((i + 1)h) = 0, the maximum value of |g 0 (x)| in [ih, (i + 1)h] must occur at the critical point which
implies that
e e h2 eh2
|f (x) − p(x)| ≤ max |g(x)| ≤ · = .
2 xi ≤x≤xi+1 2 4 8
Consequently, to ensure that the the error in linear interpolation is bounded by 10−6 , it is sufficient
for h to be chosen so that
eh2
≤ 10−6 .
8
This implies that h < 1.72 × 10−3 .
Because n = (1 − 0)/h must be an integer, a reasonable choice for the step size is h = 0.001.
Example 4. Determine the step size h that can be used in the tabulation of a function f (x), a ≤ x ≤ b,
at equally spaced nodal points so that the truncation error of the quadratic interpolation is less than ε.
INTERPOLATION AND APPROXIMATIONS 7

Sol. Let xi−1 , xi , xi+1 are three eqispaced points with spacing h. The truncation error of the quadratic
interpolation is given by
M
|f (x) − P( x)| ≤ max |(x − xi−1 , )(x − xi )(x − xi+1 )|
3! a≤x≤b
where M = max |f (3) (x)|.
a≤x≤b
To simplify the calculation, let
x − xi = th
∴ x − xi−1 = x − (xi − h) = (t + 1)h
and x − xi+1 = x − (xi + h) = (t − 1)h.
∴ |(x − xi−1 , )(x − xi )(x − xi+1 )| = h3 |t(t + 1)(t − 1)| = g(t)(say)
Now g(t) attains its extreme values if
dg
=0
dt
which gives t = ± √13 . At end points of the interval g becomes zero.
For both values of t = ± √13 , we obtain max 2
|g(t)| = h3 3√ 3
.
xi−1 ≤x≤xi+1
Truncation error
|f (x) − P2 (x)| < ε
h3
=⇒ √ M < ε
9 3
" √ #1/3
9 3ε
=⇒ h < .
M

3. Neville’s Method
Neville’s method can be applied in the situation that we want to interpolate f (x) at a given point
x = p with increasingly higher order Lagrange interpolation polynomials.
For concreteness, consider three distinct points x0 , x1 , and x2 at which we can evaluate f (x) ex-
actly f (x0 ), f (x1 ), f (x2 ). From each of these three points we can construct an order zero (constant)
”polynomial” to approximate f (p)
f (p) ≈ P0 (p) = f (x0 ) (3.1)
f (p) ≈ P1 (p) = f (x1 ) (3.2)
f (p) ≈ P2 (p) = f (x2 ) (3.3)
Of course this isn’t a very good approximation so we turn to first order Lagrange polynomials
p − x1 p − x0
f (p) ≈ P0,1 (p) = f (x0 ) + f (x1 )
x0 − x1 x1 − x0
p − x2 p − x1
f (p) ≈ P1,2 (p) = f (x1 ) + f (x2 ).
x1 − x2 x2 − x1
There is also P0,2 , but we won’t concern ourselves with that one.
If we note that f (xi ) = Pi (x), we find
p − x1 p − x0
P0,1 (p) = P0 (p) + P1 (p)
x0 − x1 x1 − x0
(p − x1 )P0 (p) − (p − x0 )P1 (p)
=
x0 − x1
and similarly
(p − x2 )P1 (p) − (p − x1 )P2 (p)
P1,2 (p) =
x1 − x2
In general we want to multiply Pi (x) by (x−xj ) where j 6= i (i.e., xj is a point that is NOT interpolated
by Pi (x)). We take the difference of two such products and divide by the difference between the added
8 INTERPOLATION AND APPROXIMATIONS

points.
The result is a polynomial Pi,i−1 of one degree higher than either of the two used to construct it
and that interpolates all the points of the two constructing polynomials combined. This idea can be
extended to construct the third order polynomial P0,1,2
(p − x2 )P0,1 (p) − (p − x0 )P1,2 (p)
P0,1,2 (p) = .
x0 − x2
A little algebra will convince that
(p − x1 )(p − x2 ) (p − x0 )(p − x2 ) (p − x0 )(p − x1 )
P0,1,2 (p) = f (x0 ) + f (x1 ) + f (x2 )
(x0 − x1 )(x0 − x2 ) (x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )
which is just the third order Lagrange polynomial interpolating the points x0 , x1 , x2 . This shouldn’t
surprise you since this is the unique third order polynomial interpolating these three points.
Example: We are given the function
1
f (x) =
x
We want to approximate the value f (3). First we evaluate the function at the three points
xi f (xi )
2 0.5
2.5 0.4
4 0.25
We can first make three separate zero-order approximations
f (3) ≈ P0 (3) = f (x0 ) = 0.5

f (3) ≈ P1 (3) = f (x1 ) = 0.4


f (3) ≈ P2 (3) = f (x2 ) = 0.25
From these we proceed to construct P0,1 and P1,2 by using the Neville formula
(3 − x1 )P0 (3) − (3 − x0 )P1 (3)
f (3) ≈ P0,1 (3) = = 0.3
x0 − x1
(3 − x2 )P1 (3) − (3 − x1 )P2 (3)
f (3) ≈ P1,2 (3) = = 0.35
x1 − x2
So we can add these numbers to our table
xi f (xi ) Pi,i+1
2 0.5
2.5 0.2 0.3
4 0.25 0.35
Finally we can compute P0,1,2 using P0,1 and P1,2 .
(3 − x2 )P0,1 (3) − (3 − x0 )P1,2 (3)
f (3) ≈ P0,1,2 (3) = = 0.325
x0 − x2
xi f (xi ) Pi,i+1 Pi,i+1,i+2
2 0.5
2.5 0.2 0.3
4 0.25 0.35 0.325
Example 5. Neville’s method is used to approximate f (0.4) as follows. Complete the table.
xi Pi (0.4) Pi,i+1 (0.4) Pi,i+1,i+2 Pi,i+1,i+2,i+3
0 1
0.25 2 P0,1 (0.4)=2.6
0.5 P2 P1,2 (0.4) P0,1,2 (0.4)
0.75 8 P2,3 (0.4) = 2.4 P1,2,3 (0.4) = 2.96 P0,1,2,3 (0.4) = 3.016
INTERPOLATION AND APPROXIMATIONS 9

Sol.
(0.4 − 0.75)P2 − (0.4 − 0.5)P3
P2,3 (0.4) = = 2.4
0.5 − 0.75
=⇒ P2 = 4
(0.4 − 0.5)P1 − (0.4 − 0.25)P2 (−0.1)(2) − (0.15)(4)
P1,2 (0.4) = = = 3.2
0.25 − 0.5 −0.25
(0.4 − 0.5)P0,1 − (0.4 − 0)P1,2 (0.4) (−0.1)(2.6) − (0.4)(3.2)
P0,1,2 (0.4) == = = 3.08.
0 − 0.5 −0.5
Example 6. In Neville’s method, suppose xi = i, for i = 0, 1, 2, 3 and it is known that P0,1 (x) =
x + 1, P1,2 (x) = 3x − 1, and P1,2,3 (1.5) = 4. Find P2,3 (1.5) and P0,1,2,3 (1.5).
Sol. Here x0 = 0, x1 = 1, x2 = 2, x3 = 3.
(x − x2 )P0,1 (x) − (x − x0 )P1,2 (x) (x − 2)(x + 1) − x(3x + 1)
P0,1,2 (x) = = = x2 + 1.
x0 − x2 −2

(1.5 − x1 )P2,3 (1.5) − (1.5 − x3 )P1,2 (1.5)


P1,2,3 (1.5) = =4
x3 − x1
=⇒ P2,3 (1.5) = 5.5
Now
P0,1,2 (1.5) = 3.25
(1.5 − 3)P0,1,2 (1.5) − (1.5 − 0)P1,2,3 (1.5)
P0,1,2,3 (1.5) =
0−3
= 3.625.

4. Newton’s divided difference interpolation


Suppose that Pn (x) is the n-th order Lagrange 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 differences 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 − xn−1 ), (4.1)
for appropriate constants a0 , a1 , · · · , an .
Now we determine the first of these constants a0 . For this we substitute x = x0 in Pn (x) and we obtain
a0 = Pn (x0 ) = f (x0 ).
Similarly, when Pn (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 = = f [x0 , x1 ]
x1 − x0
f (x1 ) − f (x0 )
The ratio f [x0 , x1 ] = , is called first divided difference of f (x) and in general
x1 − x0
f (xi+1 ) − f (xi )
f [xi , xi+1 ] = .
xi+1 − xi
The remaining divided differences are defined recursively.
The second divided difference of three points, xi , xi+1 , xi+2 , is defined as
f [xi+1 , xi+2 ] − f [xi , xi+1 ]
f [xi , xi+1 , xi+2 ] = .
xi+2 − xi
10 INTERPOLATION AND APPROXIMATIONS

Now if we substitute x = x2 and the values of a0 and a1 in Eqs. (4.1), we obtain


f (x1 ) − f (x0 )
P (x2 ) = f (x2 ) = f (x0 ) + (x2 − x0 ) + a2 (x2 − x0 )(x2 − x1 )
x1 − x0
f (x0 ) f (x1 ) f (x2 )
=⇒ a2 = + +
(x0 − x1 )(x0 − x2 ) (x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )
f [x1 , x2 ] − f [x0 , x1 ]
= = f [x0 , x1 , x2 ].
x2 − x0
The process ends with the single n-th divided difference,
f [x1 , x2 , · · · , xn ] − f [x0 , x1 , · · · , xn−1 ]
an = f [x0 , x1 , · · · , xn ] =
xn − x0
n
X f (xi )
= n
Q
i=0 (xi − xj )
j=0
j6=i

We can write the Newton divided difference formula in the following fashion (and we will prove in next
Theorem).
Pn (x) = f (x0 ) + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) +
· · · + f [x0 , x1 , · · · , xn ](x − x0 )(x − x1 ) · · · (x − xn−1 )
n
X i−1
Y
= f (x0 ) + f [x0 , x1 , · · · , xi ] (x − xj ).
i=1 j=0
We can also construct the Newton interpolating polynomial as given in the next result.
Theorem 4.1. The unique polynomial of degree ≤ n that passes through (x0 , y0 ), (x1 , y1 ), · · · , (xn , yn )
is given by
Pn (x) = f [x0 ] + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) + · · · +
f [x0 , · · · , xn ](x − x0 )(x − x1 ) · · · (x − xn−1 )
Proof. We prove it by induction. The unique polynomial of degree 0 that passes through (x0 , y0 ) is
obviously
P0 (x) = y0 = f [x0 ].
Suppose that the polynomial Pk (x) of order ≤ k that passes through (x0 , y0 ), (x1 , y1 ), · · · , (xk , yk ) is
Pk (x) = f [x0 ] + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) + · · · +
f [x0 , · · · , xk ](x − x0 )(x − x1 ) · · · (x − xk−1 )
Write Pk+1 (x), the unique polynomial of order (degree) ≤ k that passes through (x0 , y0 ), (x1 , y1 ), · · · ,
(xk , yk )(xk+1 , yk+1 ) by
Pk+1 (x) = f [x0 ] + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) + · · · +
f [x0 , · · · , xk ](x − x0 )(x − x1 ) · · · (x − xk−1 ) + C(x − x0 )(x − x1 ) · · · (x − xk−1 )(x − xk )
We only need to show that
C = f [x0 , x1 , · · · , xk , xk+1 ].
For this, let Qk (x) be the unique polynomial of degree ≤ k that passes through (x1 , y1 ), · · · , (xk , yk )
(xk+1 , yk+1 ). Define
x − x0
R(x) = Pk (x) + [Qk (x) − Pk (x)]
xk+1 − x0
Then,
• R(x) is a polynomial of degree k + 1.
• R(x0 ) = Pk (x0 ) = y0 ,
xi − x0
R(xi ) = Pk (xi ) + (Qk (xi ) − Pk (xi )) = Pk (xi ) = yi , i = 1, · · · , k,
xk+1 − x0
R(xk+1 ) = Qk (xk+1 ) = yk+1 .
INTERPOLATION AND APPROXIMATIONS 11

By the uniqueness, R(x) = Pk+1 (x).


The leading coefficient of Pk+1 (x) is C.
x − x0
The leading coefficient of R(x) is the leading coefficient of [Qk (x) − Pk (x)] which is
xk+1 − x0
1
(leading coefficient of Qk (x) - leading coefficient of Pk (x)).
xk+1 − x0
On the other hand, the leading coefficient of Qk (x) is f [x1 , · · · , xk+1 ], and the leading coefficient of
Pk (x) is f [x0 , · · · , xk ]. Therefore
f [x1 , · · · , xk+1 ] − f [x0 , · · · , xk ]
C= = f [x0 , x1 , · · · , xk+1 ].
xk+1 − x0

The generation of the divided differences is outlined in following Table.

Example 7. Given the following four data points. Find a polynomial in Newton form to interpolate

xi 0 1 3 5
yi 1 2 6 7

the data (the same exercise was done by Lagrange interpolation).


Sol. To write the Newton form, we draw divided difference table as following

xi yi first d.d. second d.d. third d.d.


0 1 1 1/3 −17/120
1 2 2 −3/8
3 6 1/2
5 7

P3 (x) = f (x0 ) + (x − 0)f [0, 1] + (x − 0)(x − 1)f [0, 1, 3] + (x − 0)(x − 1)(x − 3)f [0, 1, 3, 5]
P3 (x) = 1 + x + 1/3x(x − 1) − 17/120x(x − 1)(x − 3).
Note that xi can be re-ordered but must be distinct. When the order of some xi are changed, one
obtain the same polynomial but in different form.
Theorem 4.2. Let f ∈ C n [a, b] and x0 , · · · , xn are distinct numbers in [a, b]. Then there exists ξ such
that
f (n) (ξ)
f [x0 , x1 , x2 , · · · , xn ] = .
n!
12 INTERPOLATION AND APPROXIMATIONS

Proof. Let
n
X
Pn (x) = f (x0 ) + f [x0 , x1 , · · · , xk ](x − x0 )(x − x1 ) · · · (x − xk−1 )
k=1
be the interpolating polynomial of f in Newton’s form. Define
g(x) = f (x) − Pn (x).
Since Pn (xi ) = f (xi ) for i = 0, 1, · · · , n, the function g has n + 1 distinct zeros in [a, b]. By the
generalized Rolle’s Theorem there exists ξ ∈ (a, b) such that
g (n) (ξ) = f (n) (ξ) − Pn(n) (ξ) = 0.
Here
Pn(n) (x) = n! f [x0 , x1 , · · · , xn ].
Therefore
f (n) (ξ)
f [x0 , x1 , · · · , xn ] = .
n!

Example 8. Let f (x) = xn for some integer n ≥ 0. Let x0 , x1 , · · · , xm be m + 1 distinct numbers.


What is f [x0 , x1 , · · · , xm ] for m = n? For m > n?
Sol. Since we can write
f (m) (ξ)
f [x0 , x1 , · · · , xm ] = ,
m!
n!
∴ f [x0 , x1 , · · · , xn ] = = 1.
n!
If m > n, then f (m) (x) = 0 as f (x) is a monomial of degree n, thus f [x0 , x1 , · · · , xm ] = 0.
4.1. Newton interpolation for equally spaced points. Newton’s divided-difference formula can
be expressed in a simplified form when the nodes are arranged consecutively with equal spacing. Let
n + 1 points x0 , x1 , · · · , xn are arranged consecutively with equal spacing h.
Let
xn − x0
h= = xi+1 − xi , i = 0, 1, · · · , n
n
Then each xi = x0 + ih, i = 0, 1, · · · , n.
For any x ∈ [a, b], we can write x = x0 + sh, s ∈ R.
Then x − xi = (s − i)h.
Now Newton interpolating polynomial is given by
Xn
Pn (x) = f (x0 ) + f [x0 , x1 , · · · , xk ] (x − x0 ) · · · (x − xk−1 )
k=1
n
X
= f (x0 ) + f [x0 , x1 , · · · , xk ] (s − 0)h (s − 1)h · · · (s − k + 1)h
k=1
Xn
= f (x0 ) + f [x0 , x1 , · · · , xk ] s(s − 1) · · · (s − k + 1) hk
k=1
n  
X s k
= f (x0 ) + f [x0 , x1 , · · · , xk ] k! h
k
k=1
where the binomial formula  
s s(s − 1) · · · (s − k + 1)
= .
k k!
Now we introduce the forward difference operator
4f (xi ) = f (xi+1 ) − f (xi ).
4k f (xi ) = 4k−1 4f (xi ) = 4k−1 [f (xi+1 ) − f (xi )], i = 0, 1, · · · , n − 1
INTERPOLATION AND APPROXIMATIONS 13

Using the 4 notation, we can write


f (x1 ) − f (x0 ) 1
f [x0 , x1 ] = = 4f (x0 )
x1 − x0 h
1
f [x1 , x2 ] − f [x0 , x1 ] h 4f (x1 ) − h1 4f (x0 ) 1
f [x0 , x1 , x2 ] = = = 42 f (x0 )
x2 − x0 2h 2!h2
In general
1
4k f (x0 ).
f [x0 , x1 , · · · , xk ] =
k!hk
Therefore
n  
X s
Pn (x) = Pn (x0 + sh) = f (x0 ) + 4k f (x0 ).
k
k=1
This is the Newton’s forward divided difference interpolation.
If the interpolation nodes are arranged recursively as xn , xn−1 , · · · , x0 , a formula for the interpolating
polynomial is similar to previous result. In this case, Newton’s divided difference formula can be
written as
n
X
Pn (x) = f (xn ) + f [xn , xn−1 · · · , xn−k ] (x − xn ) · · · (x − xn−k+1 ).
k=1
If nodes are equally spaced with spacing
xn − x0
h= , xi = xn − (n − i)h, i = n, n − 1, · · · , 0.
n
Let x = xn + sh.
Therefore
Xn
Pn (x) = f (xn ) + f [xn , xn−1 · · · , xn−k ] (x − xn ) · · · (x − xn−k+1 )
k=1
Xn
= f (xn ) + f [xn , xn−1 · · · , xn−k ] (s)h (s + 1)h · · · (s + k − 1)h
k=1
n  
X −s
k
= f (xn ) + f [xn , xn−1 · · · , xn−k ] (−1) hk k!
k
k=1
where the binomial formula is extended to include all real values s,
 
−s −s(−s − 1) · · · (−s − k + 1) s(s + 1) · · · (s + k − 1)
= = (−1)k .
k k! k!
Like-wise the forward difference operator, we introduce the backward-difference operator by symbol ∇
(nabla) and
∇f (xi ) = f (xi ) − f (xi−1 ).
∇k f (xi ) = ∇k−1 ∇f (xi ) = ∇k−1 [f (xi ) − f (xi−1 )]
then
1
∇f (xn )
f [xn , xn−1 ] =
h
1
f [xn , xn−1 ] − f [xn−1 , xn−2 ] ∇f (xn ) − h1 ∇f (xn−1 ) 1
f [xn , xn−1 , xn−2 ] = = h = ∇2 f (xn ).
xn − xn−2 2h 2!h2
In general
1
f [xn , xn−1 , xn−2 · · · , xn−k ] = ∇k f (xn ).
k!hk
Therefore by using the backward-difference operator, the divided-difference formula can be written as
n  
X −s
Pn (x) = f (xn ) + (−1)k ∇k f (xn ).
k
k=1
This is the Newton’s backward difference interpolation formula.
14 INTERPOLATION AND APPROXIMATIONS

Example 9. Using the following table for tan x, approximate its value at 0.71 using Newton interpo-
lation.

xi 0.70 72 0.74 0.76 0.78


tan xi 0.84229 0.87707 0.91309 0.95045 0.98926

Sol. As the point x = 0.71 lies in the beginning, we will use Newton’s forward interpolation. The
forward difference table is:

xi f (xi ) ∆f (xi ) ∆2 f (xi ) ∆3 f (xi ) ∆4 f (xi )


0.70 0.84229 0.03478 0.00124 0.0001 0.00001
0.72 0.87707 0.03602 0.00134 0.00011
0.74 0.91309 0.03736 0.00145
0.76 0.95045 0.03881
0.78 0.98926

Here x0 = 0.70, h = 0.02, x = 0.71 = x0 + sh gives s = 0.5. The Newton forward difference polynomial
is given by
s(s − 1) 2 s(s − 1)(s − 2) 3 s(s − 1)(s − 2)(s − 3) 4
P3 (x) = f (x0 )+s∆f (x0 )+ ∆ f (x0 )+ ∆ f (x0 )+ ∆ f (x0 ).
2! 3! 4!
Substituting the values from table (first entries of each column starting from second), we obtain
P3 (0.71) = tan(0.71) = 0.8596.
Example 10. Show that the cubic polynomials
P (x) = 3 − 2(x + 1) + 0(x + 1)(x) + (x + 1)(x)(x − 1)
and
Q(x) = −1 + 4(x + 2) − 3(x + 2)(x + 1) + (x + 2)(x + 1)(x)
both interpolate the given data. Why does this not violate the uniqueness property of interpolating

x -2 -1 0 1 2
f (x) -1 3 1 -1 3

polynomials?
Sol. The forward difference table is:

x f (x) first d.d. second d.d. third d.d. fourth d.d.


-2 -1 4 -3 1 0
-1 3 -2 0 1
0 1 -2 3
1 -1 4
2 3

In the formulation of P (x), second node is taken as x0 while in the formulation of Q(x) first point
is taken as initial point.
Also (alternatively without drawing the table) P (−2) = Q(−2) = −1, P (−1) = Q(−1) = 3, P (0) =
Q(0) = 1, P (1) = Q(1) = −1, P (2) = Q(2) = 3.
Therefore both the cubic polynomials interpolate the given data. Further the interpolating polyno-
mials are unique but format of a polynomial is not unique.
If P (x) and Q(x) are expanded, they are identical.
INTERPOLATION AND APPROXIMATIONS 15

5. Curve Fitting : Principles of Least Squares


Least-squares, also called “regression analysis”, is one of the most commonly used methods in
numerical computation. Essentially it is a technique for solving a set of equations where there are more
equations than unknowns, i.e. an overdetermined set of equations. Least squares is a computational
procedure for fitting an equation to a set of experimental data points. The criterion of the “best” fit is
that the sum of the squares of the differences between the observed data points, (xi , yi ), and the value
calculated by the fitting equation, is minimum. The goal is to find the parameter values for the model
which best fits the data. The least squares method finds its optimum when the sum E, of squared
residuals
Xn
E= ei 2
i=1
is a minimum. A residual is defined as the difference between the actual value of the dependent variable
and the value predicted by the model. Thus
ei = yi − f (xi ).
Least square fit of a straight line: Suppose that we are given a data set (x1 , y1 ), (x2 , y2 ), · · · , (xn , yn )
of observations from an experiment. We are interested in fitting a straight line of the form f (x) = a+bx,
to the given data. Now residuals is given by
ei = yi − (a + bxi ).
Note that ei is a function of parameters a and b. We need to find a and b such that
Xn
E= e2i
i=1
is minimum. The necessary condition for the minimum is given by
∂E ∂E
= 0, = 0.
∂a ∂b
The conditions yield
n
∂E X
= [yi − (a + bxi )](−2) = 0
∂a
i=1
n
X n
X
=⇒ yi = na + b xi (5.1)
i=1 i=1
n
∂E X
= [yi − (a + bxi )](−2xi ) = 0
∂b
i=1
n
X n
X n
X
=⇒ x i yi = a xi + b x2i . (5.2)
i=1 i=1 i=1
These equations (5.1-5.2) are called normal equations, which are to be solved to get desired values for
a and b.
Example 11. Obtain the least square straight line fit to the following data

x 0.2 0.4 0.6 0.8 1


f (x) 0.447 0.632 0.775 0.894 1

Sol. The normal equations for fitting a straight line y = a + bx are


5
X 5
X
f (xi ) = 5a + b xi
i=1 i=1
5
X 5
X 5
X
xi f (xi ) = a xi + b x2i
i=1 i=1 i=1
16 INTERPOLATION AND APPROXIMATIONS

5 5 5 5
x2i = 2.2,
P P P P
From the data, we have xi = 3, f (xi ) = 3.748, and xi f (xi ) = 2.5224.
i=1 i=1 i=1 i=1
Therefore
5a + 3b = 3.748, 3a + 2.2b = 2.5224.
The solution of this system is a = 0.3392 and b = 0.684. The required approximation is y = 0.3392 +
0.684x.
5
[f (xi ) − (0.3392 + 0.684xi )2 ] = 0.00245.
P
Least square error=
i=1

Example 12. Find the least square approximation of second degree for the discrete data

x −2 −1 0 1 2
f (x) 15 1 1 3 19

Sol. We fit a second degree polynomial y = a + bx + cx2 .


By principle of least squares, we minimize the function
5
X
E= [yi − (a + bxi + cx2i )]2 .
i=1

The necessary condition for the minimum is given by


∂E ∂E ∂E
= 0, = 0, = 0.
∂a ∂b ∂c
The normal equations for fitting a second degree polynomial are

5
X 5
X 5
X
f (xi ) = 5a + b xi + c x2i
i=1 i=1 i=1
5
X 5
X 5
X 5
X
xi f (xi ) = a xi + b x2i + c x3i
i=1 i=1 i=1 i=1
5
X 5
X 5
X 5
X
x2i f (xi ) = a x2i + b x3i + c x4i .
i=1 i=1 i=1 i=1
5 5 4 5 5 5 5
x2i = 10, x3i = 0, x4i = 34, x2i f (xi ) =
P P P P P P P
We have xi = 0, f (xi ) = 39, xi f (xi ) = 10,
i=1 i=1 i=1 i=1 i=1 i=1 i=1
140.
From given data
5a + 10c = 39
10b = 10
10a + 34c = 140.
−37 31
The solution of this system is a = , b = 1, and c = .
35 7
1
The required approximation is y = (−37 + 35x + 155x2 ).
35

Example 13. Use the method of least square to fit the curve f (x) = c0 x + c1 / x. Also find the least

x 0.2 0.3 0.5 1 2


f (x) 16 14 11 6 3

square error.
INTERPOLATION AND APPROXIMATIONS 17

Sol. By principle of least squares, we minimize the error


5
X c1
E(c0 , c1 ) = [f (xi ) − c0 xi − √ ]2
xi
i=1
We obtain the normal equations
5 5 5
X X √ X
c0 x2i + c1 xi = xi f (xi )
i=1 i=1 i=1
5 5 5
X √ X 1 X f (xi )
c0 xi + c1 = √ .
xi xi
i=1 i=1 i=1
We have
5 5 5
X √ X 1 X
xi = 4.1163, = 11.8333, x2i = 5.38
xi
i=1 i=1 i=1
5 5
X X f (xi )
xi f (xi ) = 24.9, √ = 85.0151.
xi
i=1 i=1
The normal equations are given by
5.3c0 + 4.1163c1 = 24.9
4.1163c0 + 11.8333c1 = 85.0151.
Whose solution is c0 = −1.1836, c1 = 7.5961.
Therefore, the least square fit is given as
7.5961
f (x) = √ − 1.1836x.
x
The least square error is given by
5
X 7.5961
E= [f (xi ) − √ + 1.1836xi ]2 = 1.6887
xi
i=1

Example 14. Obtain the least square fit of the form y = abx to the following data

x 1 2 3 4 5 6 7 8
f (x) 1.0 1.2 1.8 2.5 3.6 4.7 6.6 9.1

Sol. The curve y = abx takes the form Y = A + Bx after taking log, where Y = log y, A = log a and
B = log b.
Hence the normal equations are given by
8
X 8
X
Yi = 8A + B xi
i=1 i=1
8
X x
X 8
X
xi Yi = A xi + B x2i
i=1 i=1 i=1
From the data, we form the following table.
Putting the values, we obtain
8A + 36B = 3.7393, 36A + 204B = 22.7385
=⇒ A = 0.1656, B = 0.1407
=⇒ a = 0.68, b = 1.38
The required curve is y = (0.68)(1.38)x .
18 INTERPOLATION AND APPROXIMATIONS

x y Y = log y xY x2
1 1.0 0.0 0.0 1
2 1.2 0.0792 0.1584 4
3 1.8 0.2553 0.7659 9
4 2.5 0.3979 1.5916 16
5 3.6 0.5563 2.7815 25
6 4.7 0.6721 4.0326 36
7 6.6 0.8195 5.7365 49
8 9.1 0.9590 7.6720 64
Σ 36 30.5 3.7393 22.7385 204

Remark 5.1. If data is quite large then we can make it small by changing the origin and appropriating
scaling.
Example 15. Show that the line of fit to the following data is given by y = 0.7x + 11.28.
x 0 5 10 15 20 25
y 12 15 17 22 24 30
Sol. Here n = 6. We fit a line of the form y = A + Bx.
x − 15
Let u = , v = y − 20 and line of the form v = a + bu.
5
x y u v uv u2
0 12 −3 −8 24 9
5 15 −2 −5 10 4
10 17 −1 −3 3 1
15 22 0 2 0 0
20 24 1 4 4 1
25 30 2 10 20 4
Σ −3 0 61 19
The normal equations are,
0 = 6a − 3b
61 = −3a + 19b.
By solving a = 1.7428 and b = 3.4857.
Therefore equation of the line is v = 1.7428 + 3.4857u.
Changing in to original variable, we obtain
 
x − 15
y − 20 = 1.7428 + 3.4857
5
=⇒ y = 11.2857 + 0.6971x.

Exercises
(1) Find the unique polynomial P (x) of degree 2 or less such that
P (1) = 1, P (3) = 27, P (4) = 64
using Lagrange interpolation. Evaluate P (1.05).
(2) For the given functions f (x), let x0 = 1, x1 = 1.25, and x2 = 1.6. Construct Lagrange
interpolation polynomials of degree at most one and at most two to approximate f (1.4), and
find the absolute error. √
a. f (x) = sin πx b. f (x) = 3 x − 1 c. f (x) = log10 (3x − 1) d. f (x) = e2x − x.
(3) Let P3 (x) be the Lagrange interpolating polynomial for the data (0, 0), (0.5, y), (1, 3) and (2, 2).
Find y if the coefficient of x3 in P3 (x) is 6.
(4) Let f (x) = ln(1 + x), x0 = 1, x1 = 1.1. Use Lagrange linear interpolation to find the
approximate value of f (1.04) and obtain a bound on the truncation error.
INTERPOLATION AND APPROXIMATIONS 19

(5) Construct the Lagrange interpolating polynomials for the following functions, and find a bound
for the absolute error on the interval [x0 , xn ].
a. f (x) = e2x cos 3x, x0 = 0, x1 = 0.3, x2 = 0.6, n = 2.
b. f (x) = sin(ln x), x0 = 2.0, x1 = 2.4, x2 = 2.6, n = 2.
c. f (x) = cos x + sin x, x0 = 0, x1 = 0.25, x2 = 0.5, x3 = 1.0, n = 3.
(6) Use the following values and four-digit rounding arithmetic to construct a third degree Lagrange
polynomial approximation to f (1.09). The function being approximated is f (x) = log10 (tan x).
Use this knowledge to find a bound for the error in the approximation.
f (1.00) = 0.1924, f (1.05) = 0.2414, f (1.10) = 0.2933, f (1.15) = 0.3492.
(7) Use the Lagrange interpolating polynomial of degree three or less and four-digit chopping
arithmetic to approximate cos 0.750 using the following values. Find an error bound for the
approximation.
cos 0.698 = 0.7661, cos 0.733 = 0.7432, cos 0.768 = 0.7193, cos 0.803 = 0.6946.
The actual value of cos 0.750 is 0.7317 (to four decimal places). Explain the discrepancy between
the actual error and the error bound. √
(8) Determine the spacing h in a table of equally spaced values of the function f (x) = x between
1 and 2, so that interpolation with a quadratic polynomial will yield an accuracy of 5 × 10−8 .
(9) It is suspected that the high amounts of tannin in mature oak leaves inhibit the growth of the
winter moth larvae that extensively damage these trees in certain years. The following table
lists the average weight of two samples of larvae at times in the first 28 days after birth. The
first sample was reared on young oak leaves, whereas the second sample was reared on mature
leaves from the same tree.
a. Use Lagrange interpolation to approximate the average weight curve for each sample.
b. Find an approximate maximum average weight for each sample by determining the maximum
of the interpolating polynomial.
Day 0 6 10 13 17 20 8
Sample 1 average weight (mg) 6.67 17.33 42.67 37.33 30.10 29.31 28.74
Sample 2 average weight (mg) 6.67 16.11 18.89 15.00 10.56 9.44 8.89
(10) Use Neville’s method to obtain the approximations for Lagrange interpolating polynomials of
degrees one, two, and three to approximate each of the following:
a. f (8.4) if f (8.1) = 16.94410, f (8.3) = 17.56492, f (8.6) = 18.50515, f (8.7) = 18.82091
b. f (−1/3) if f (−0.75) = −0.07181250, f (−0.5) = −0.02475000, f (−0.25) = 0.33493750, f (0) =
1.10100000. √
(11) Use Neville’s method to approximate 3 with the following functions and values.
a. f (x) = 3√x and the values x0 = −2, x1 = −1, x2 = 0, x3 = 1, and x4 = 2.
b. f (x) = x and the values x0 = 0, x1 = 1, x2 = 2, x3 = 4, and x4 = 5.
c. Compare the accuracy of the approximation in parts (a) and (b).
(12) Let P3 (x) be the interpolating polynomial for the data (0, 0), (0.5, y), (1, 3), and (2, 2). Use
Neville’s method to find y if P3 (1.5) = 0.
(13) Neville’s Algorithm is used to approximate f (0) using f (−2), f (−1), f (1), and f (2). Suppose
f (−1) was understated by 2 and f (1) was overstated by 3. Determine the error in the original
calculation of the value of the interpolating polynomial to approximate f (0).
(14) If linear interpolation is used to interpolate the error function
Z x
2 2
f (x) = √ e−x dt,
π 0
show that the √ error of linear interpolation using data (x0 , f0 ) and (x1 , f1 ) cannot exceed
(x1 − x0 )2 /2 2πe.
(15) Using Newton divided difference interpolation, construct interpolating polynomials of degree
one, two, and three for the following data. Approximate the specified value using each of the
polynomials.
f (0.43) if f (0) = 1, f (0.25) = 1.64872, f (0.5) = 2.71828, f (0.75) = 4.4816.
20 INTERPOLATION AND APPROXIMATIONS

(16) Show that the polynomial interpolating (in Newton form) the following data has degree 3.

x −2 −1 0 1 2 3
f (x) 1 4 11 16 13 −4
(17) Let f (x) = ex , show that f [x0 , x1 , . . . , xm ] > 0 for all values of m and all distinct equally spaced
nodes {x0 < x1 < · · · < xm }.
(18) Show that the interpolating polynomial for f (x) = xn+1 at n + 1 nodal points x0 , x1 , · · · , xn is
given by
xn+1 − (x − x0 )(x − x1 ) · · · (x − xn ).
(19) The following data are given for a polynomial P (x) of unknown degree
x 0 1 2 3
f (x) 4 9 15 18
Determine the coefficient of x3 in P (x) if all fourth-order forward differences are 1.
(20) Let i0 , i1 , · · · , in be a rearrangement of the integers 0, 1, · · · , n. Show that f [xi0 , xi1 , · · · , xin ] =
f [x0 , x1 , · · · , xn ].
(21) Let f (x) = 1/(1 + x) and let x0 = 0, x1 = 1, x2 = 2. Calculate the divided differences f [x0 , x1 ]
and f [x0 , x1 , x2 ]. Using these divided differences, give the quadratic polynomial P2 (x) that
interpolates f (x) at the given node points {x0 , x1 , x2 }. Graph the error f (x) − P2 (x) on the
interval [0, 2].
(22) Construct the interpolating polynomial that fits the following data using Newton forward and
backward
x 0 0.1 0.2 0.3 0.4 0.5
f (x) −1.5 −1.27 −0.98 −0.63 −0.22 0.25
difference interpolation. Hence find the values of f (x) at x = 0.15 and 0.45.
(23) For a function f , the forward-divided differences are given by
x0 = 0.0 f [x0 ]
50
x1 = 0.4 f [x1 ] f [x0 , x1 ] f [x0 , x1 , x2 ] =
7
x1 = 0.4 f [x2 ] = 6 f [x1 , x2 ] = 10
Determine the missing entries in the table.
(24) A fourth-degree polynomial P (x) satisfies ∆4 P (0) = 24, ∆3 P (0) = 6, and ∆2 P (0) = 0, where
∆P (x) = P (x + 1) − P (x). Compute ∆2 P (10).
(25) Show that
f (n+1) (ξ(x))
f [x0 , x1 , x2 , · · · , xn , x] = .
(n + 1)!
(26) Use the method of least squares to fit the linear and quadratic polynomial to the following
data.
x −2 −1 0 1 2
f (x) 15 1 1 3 19
(27) By the method of least square fit a curve of the form y = axb to the following data.
x 2 3 4 5
y 27.8 62.1 110 161

(28) Use the method of least squares to fit a curve y = c0 /x + c1 x to the following data.
x 0.1 0.2 0.4 0.5 1 2
y 21 11 7 6 5 6
(29) Experiment with a periodic process provided the following data :
t◦ 0 50 100 150 200
y 0.754 1.762 2.041 1.412 0.303
Estimate the parameter a and b in the model y = a + b sin t, using the least square approxima-
tion.
INTERPOLATION AND APPROXIMATIONS 21

Appendix A. Algorithms
Algorithm (Lagrange Interpolation):


Read the degree n of the polynomial Pn (x).

Read the values of x(i) and y(i) = f (xi ), i = 0, 1, . . . , n.

Read the point of interpolation p.

Calculate the Lagrange’s fundamental polynomials li (x) using the following loop:
for i=1 to n
l(i) = 1.0
for j=1 to n
if j 6= i
p − x(j)
l(i) = ∗ l(i)
x(i) − x(j)
end j
end i
• Calculate the approximate value of the function at x = p using the following loop:
sum=0.0
for i=1 to n
sum = sum + l(i) ∗ y(i)
end i
• Print sum.
Algorithm (Newton Divided-Difference Interpolation):
Given n distinct interpolation points x0 , x1 , · · · , xn , and the values of a function f (x) at these
points, the following algorithm computes the matrix of divided differences:
D = zeros(n, n);
for i = 1 : n
D(i,1) = y(i);
end i
for j = 2 : n,
for k = j : n,
D(k, j) = (D(k, j − 1) − D(k − 1, j − 1))/(x(k) − x(k − j + 1));
end i
end j.

Now compute the value at interpolating point p using nesting:


f p = D(n, n);
for i = n − 1 : −1 : 1
f p = f p ∗ (p − x(i)) + D(i, i);
end i
Print Matrix D and f p.

Bibliography
[Burden] Richard L. Burden, J. Douglas Faires and Annette Burden, “Numerical Analysis,” Cengage
Learning, 10th edition, 2015.
[Atkinson] K. Atkinson and W. Han, “Elementary Numerical Analysis,” John Willey and Sons, 3rd
edition, 2004.

You might also like