


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















It is well-known that a continuous function f (x) on [a, b] can be approximated as close as possible by means of a polynomial. Specifically, for each > 0, there exists a polynomial P (x) such that |f (x) − P (x)| < for all x in [a, b]. This is a classical result, known as Weierstrass Approximation Theorem. Knowing that fk, k = 0, · · · , n are the values of a certain function at xk, the most obvious thing then to do is to construct a polynomial Pn(x) of degree at most n that passes through the (n + 1) points: (x 0 , f 0 ), (x 1 , f 1 ), · · · , (xn, fn). Indeed, if the nodes x 0 , x 1 , ..., xn are assumed to be distinct, then such a poly- nomial always does exist and is unique, as can be seen from the following.
Let Pn(x) = a 0 + a 1 x + a 2 x^2 + · · · + anxn^ be a polynomial of degree at most n. If Pn(x) interpolates at x 0 , x 1 , · · · , xn, we must have, by definition
Pn(x 0 ) = f 0 = a 0 + a 1 x 0 + a 2 x^20 + · · · + anxn 0 Pn(x 1 ) = f 1 = a 0 + a 1 x 1 + a 2 x^21 + · · · + anxn 1 .. . Pn(xn) = fn = a 0 + a 1 xn + a 2 x^2 n + · · · + anxnn
These equations can be written in matrix form:
1 x 0 x^20 · · · xn 0 1 x 1 x^21 · · · xn 1 .. . 1 xn x^2 n · · · xnn
a 0 a 1 a 2 .. . an
f 0 f 1 .. . fn
Because x 0 , x 1 , · · · , xn are distinct, it can be shown [Exercise] that the matrix of the above system is nonsingular. Thus, the linear system for the unknowns a 0 , a 1 , · · · , an has a unique solution, in view of the following well-known result, available in any linear algebra text book.
The n × n algebraic linear system Ax = b has a unique solution for every b if and only if A is nonsingular.
This means that Pn(x) exists and is unique.
Theorem 2.1 (Existence and Uniqueness Theorem for Polynomial Interpola- tion)
Given (n + 1) distinct points x 0 , x 1 , · · · , xn and the associated values f 0 , f 1 , · · · , fn of a function f (x) at these points (that is, f (xi) = fi, i = 0, 1 , · · · , n), there is a unique polynomial Pn(x) of degree at most n such that Pn(xi) = fi, i = 0, 1 , · · · , n. The coefficients of this polynomial can be obtained by solving the (n + 1) × (n + 1) linear system (2.2).
Definition: The polynomial Pn(x) in Theorem 2.1 is called the interpolating polynomial.
Once we know that the interpolating polynomial exists and is unique, the problem then becomes how to construct an interpolating polynomial; that is, how to construct a polynomial Pn(x) of degree at most n, such that
Pn(xi) = fi, i = 0, 1 , · · · , n.
It is natural to obtain the polynomial by solving the linear system (2.1) in the previous section. Unfortunately, the matrix of this linear system, known as the Vandermonde Matrix, is usually highly ill-conditioned, and the solution of such an ill-conditioned system, even by the use of a stable method, may not be accurate. There are, however, several other ways to construct such a polynomial, that do not require solution of a Vandermonde system. We describe one such in the following: Suppose n = 1, that is, suppose that we have only two points (x 0 , f 0 ), (x 1 , f 1 ), then it is easy to see that the linear polynomial
P 1 (x) =
x − x 1 (x 0 − x 1 )
f 0 +
(x − x 0 ) (x 1 − x 0 )
f 1
is an interpolating polynomial, because
P 1 (x 0 ) = f 0 , P 1 (x 1 ) = f 1.
For convenience, we shall write the polynomial P 1 (x) in the form
P 1 (x) = L 0 (x)f 0 + L 1 (x)f 1 ,
where, L 0 (x) =
x − x 1 x 0 − x 1
, and L 1 (x) =
x − x 0 x 1 − x 0
Note that both the polynomials L 0 (x) and L 1 (x) are polynomials of degree 1.
L 0 (x) =
(x − 1)(x − 2)(x − 4) (−1)(−2)(−4)
L 1 (x) =
(x − 0)(x − 2)(x − 4) 1 · (−1)(−3)
L 2 (x) =
(x − 0)(x − 1)(x − 4) 2 · 1 · (−2)
L 3 (x) =
(x − 0)(x − 1)(x − 2) 4 · 3 · 2
From (2.4) with n = 3, we have P 3 (x) = 7L 0 (x) + 13L 1 (x) + 21L 2 (x) + 43L 3 (x)
Now, L 0 (3) =
So, P 3 (3) = 7L 0 (3) + 13L 1 (3) + 21L 2 (3) + 43L 3 (3) = 31.
Verify: Note that f (x) in this case is f (x) = x^2 + 5x + 7, and the exact value of f (x) at x = 3 is 31.
Example 2.2 Given
i xi f (xi)
Interpolate f (x) at x = 3.
L 0 (x) =
(x − x 1 )(x − x 2 ) (x 0 − x 1 )(x 0 − x 2 )
(x − 2 .5)(x − 4) (− 0 .5)(−2)
= (x − 2 .5)(x − 4)
L 1 (x) =
(x − x 0 )(x − x 2 ) (x 1 − x 0 )(x 1 − x 2 )
(x − 2)(x − 4) (0.5)(− 1 .5)
(x − 2)(x − 4)
L 2 (x) =
(x − x 1 )(x − x 0 ) (x 2 − x 1 )(x 2 − x 0 )
(x − 2 .5)(x − 2)
So, P 2 (x) = f (x 0 )L 0 (x) + f (x 1 )L 1 (x) + f (x 2 )L 2 (x) =
L 0 (x) +
L 1 (x) +
L 2 (x)
Thus, P 2 (3) =
Verify: (The value of f (x) at x = 3 is 13 ≈ 0 .3333).
If f (x) is approximated by an interpolating polynomial Pn(x), we would like to obtain an expression for the error of interpolation at a give intermediate point, say, ¯x. That is, we would like to calculate E(¯x) = f (¯x) − Pn(¯x). Note that, since Pn(xi) = f (xi), E(xi) = 0, i = 0, 1 , 2 , · · · , n), that is, there are no errors of interpolating at a tabulated point. Here is a result for the error expression E(¯x).
For proof of Theorem 2.2 we need the following result from Calculus:
Generalized Rolle’s Theorem
Suppose that f (x) is continuous on [a, b] and n times differentiable on (a, b). If f (x) has n distinct zeros in [a, b], then f (n+1)(c) = 0 where a < c < b.
Theorem 2.2 (Interpolation-Error Theorem) Let Pn(x) be the interpolating poly- nomial that interpolates at (n + 1) distinct numbers in [a, b], and let f (x) be (n + 1) times continuously differentiable on [a, b]. Then for every x¯ in [a, b], there exists a number ξ = ξ(¯x) in (a, b) (depending on ¯x) such that
En(¯x) = f (¯x) − Pn(¯x) =
f (n+1)(ξ(¯x)) (n + 1)!
∏^ n
i=
(¯x − xi). (2.5)
So,
g(n+1)(ξ) = f (n+1)(ξ) −
(f (¯x) − Pn(¯x)) (¯x − x 0 ) · · · (¯x − xn)
(n + 1)! (2.10)
Since g(n+1)(ξ) = 0, from (2.10), we have En(¯x) = f (¯x) − Pn(¯x) =
f (n+1)(ξ) (n + 1)!
(¯x − x 0 ) · · · (¯x −
xn).
Remark: To obtain the error of interpolation using the above theorem, we need to know the (n + 1)th derivative of the f (x) or its absolute maximum value on the interval [a, b]. Since in practice this value is hardly known, this error formula is of limited use only.
Example 2.3 Let’s compute the maximum absolute error for Example 2.2. Here n = 2.
E 2 (¯x) = f (¯x) − P 2 (¯x)
f (3)(ξ) 3!
(¯x − x 0 )(¯x − x 1 )(¯x − x 2 )
To know the maximum value of E 2 (¯x), we need to know f (3)(x). Let’s compute this now:
f (x) =
x
, f ′(x) = −
x^2
, f ′′(x)
x^3
, f (3)(x) = −
x^4
So, |f (3)(ξ)| <
for 2 < x ≤ 4.
Since x¯ = 3, x 0 = 2, x 1 = 2. 5 , x 2 = 4, we have
|E 2 (¯x)| ≤ |
Note that in four-digit arithmetic, the difference between the value obtained by interpolation and the exact value is 0. 3333 − 0 .3250 = 0. 0083.
The error formula in Theorem 2.2 can be simplified in case the tabulated points (nodes) are equally spaced; because, in this case it is possible to obtain a nice bound for the expression: (¯x − x 0 )(¯x − x 1 ) · · · (¯x − xn). Suppose the nodes are equally spaced with spacing h; that is xi+1 − xi = h.
PSfrag replacements
a = x 0 x 1 x 2 b = xn
h h h h h
Then it can be shown [Exercise] that
|(¯x − x 0 )(¯x − x 1 ) · · · (¯x − xn)| ≤
hn+ 4
n!
If we also assume that |f (n+1)(x)| ≤ M, then we have
|En(¯x)| = |f (¯x) − Pn(¯x)| ≤
(n + 1)!
hn+ 4
n! =
Mhn+ 4(n + 1)
Example 2.4 Suppose a table of values for f (x) = cos x has to be prepared in [0, 2 π] with nodes of spacing h, using linear interpolation, with an error of interpolation of at most 5 × 10 −^7. How small should h be? Here n = 1. f (x) = cos x, f ′(x) = − sin x, f 2 (x) = f ′′(x) = − cos x max |f (2)(x)| = 1, for 0 ≤ x ≤ 2 π Thus M = 1.
So, by (2.11) above we have
|E 1 (¯x)| = |f (¯x) − P 1 (¯x)| ≤
h^2 8
Since the maximum error has to be 5 × 10 −^7 , we must have: h^2 8
× 10 −^6. That is, h ≤ 6. 3246 × 10 −^4.
Example 2.5 Suppose a table is to be prepared for the function f (x) =
x on [1, 2]. Deter- mine the spacing h in a table such that the interpolation with a polynomial of degree 2 will give accuracy = 5 × 10 −^8.
We first compute the maximum absolute error.
Since f (3)(x) =
x − 25 ,
M =
∣f (3)(x)
for 1 ≤ x ≤ 2.
Thus, taking n = 2 in (2.11) the maximum (absolute) error is
h^3 12
h^3.
Thus, to have an accuracy of = 5× 10 −^8 , we must have
h^3 < 5 × 10 −^8 or h^3 < 160 × 10 −^8.
This means that a spacing h of about h = 3
160 × 10 −^8 = 0.0117 will be needed in the Table to guarantee the accuracy of 5 × 10 −^8.
Notes:
(i) Each divided difference can be obtained from two previous ones of lower orders. For example, f [x 0 , x 1 , x 2 ] can be computed from f [x 0 , x 1 ], and f [x 1 , x 2 ], and so on. Indeed, they can be arranged in form of a table as shown below:
x f (x) 1 st^ Divided 2 nd^ Divided 3 rd^ Divided 4 th^ Divided Difference Difference Difference Difference x 0 f 0 f [x 0 , x 1 ] x 1 f 1 f [x 0 , x 1 , x 2 ] f [x 1 , x 2 ] f [x 0 , x 1 , x 2 , x 3 ] x 2 f 2 f [x 1 , x 2 , x 3 ] f [x 2 , x 3 ] f [x 0 , x 1 , x 2 , x 3 , x 4 ] f [x 1 , x 2 , x 3 , x 4 ] x 3 f 3 f [x 2 , x 3 , x 4 ] f [x 3 , x 4 ] x 4 f 4
(ii) Note that in computing Pn(x) we need only the diagonal entries of the above table; that is, we need only f [x 0 ], f [x 0 , x 1 ], · · · , f [x 0 , x 1 , · · · , xn].
(iii) Since the divided differences are generated recursively, the interpolating polynomials of successively higher degrees can also be generated recursively. Thus the work done previously can be used gainfully. For example, P 1 (x) = f [x 0 ] + f [x 0 , x 1 ](x − x 0 ) P 2 (x) = f [x 0 ] + f [x 0 , x 1 ](x − x 0 ) + f [x 0 , x 1 , x 2 ](x − x 0 )(x − x 1 ) = P 1 (x) + f [x 0 , x 1 , x 2 ](x − x 0 )(x − x 1 ).
Similarly, P 3 (x) = P 2 (x) + f [x 0 , x 1 , x 2 , x 3 ](x − x 0 )(x − x 1 )(x − x 2 ) P 4 (x) = P 3 (x) + f [x 0 , x 1 , x 2 , x 3 , x 4 ](x − x 0 )(x − x 1 )(x − x 2 )(x − x 3 ) and so on.
Thus, in computing P 2 (x), P 1 (x) has been gainfully used; in computing P 3 (x), P 2 (x) has been gainfully used, etc.
Example 2.6 Interpolate at x = 2. 5 using the following Table, with polynomials of degree 3 and 4.
i xi fi 1 st diff. 2 nd diff. 3 rd diff. 4 th diff. 5 th diff.
From (2.14), with n = 3, we have
P 3 (2.5) = 0 + (2. 5 − 1 .0)(0.35222) + (2. 5 − 1 .0)(2. 5 − 1 .5)(− 0 .1023) +(2. 5 − 1 .0)(2. 5 − 1 .5)(2. 5 − 2 .0)(.0265534) =. 52827 − .15345 +. 019915 = 0.
Similarly, with n = 4, we have
P 4 (2.5) = P 3 (2.5) + (2. 5 − 1 .0)(2. 5 − 1 .5)(2. 5 − 2 .0)(2. 5 − 3 .0)(−.006409) = 0.394795 + .002403 = (^) 0..
Note that P 4 (2.5) − P 3 (2.5) = (^) 0..
Verification. The above is a table for log(x). The exact value of log(2.5) (correct up to 5 decimal places) is 0.39794.
(Note that in computing P 4 (2.5), P 3 (2.5) computed previously has been gainfully used). If we use the notation Dij = f [xi,... , xi+j ]. Then
We can then write
Pn(x) = Pn(x 0 + sh) =
∑^ n
k=
s k
hkk!f [x 0 , · · · , xn] (2.16)
The Newton Forward-Difference Formula
Let’s introduce the notations: ∆fi = f (xi+1) − f (xi). Then, ∆f 0 = f (x 1 ) − f (x 0 ) So,
f [x 0 , x 1 ] =
f (x 1 ) − f (x 0 ) x 1 − x 0
∆f 0 h
Also, note that
∆^2 f 0 = ∆(∆f 0 ) = ∆(f (x 1 ) − f (x 0 )) = ∆f (x 1 ) − ∆f (x 0 ) = f (x 2 ) − f (x 1 ) − f (x 1 ) + f (x 0 ) = f (x 2 ) − 2 f (x 1 ) + f (x 0 )
So,
f [x 0 , x 1 , x 2 ] =
f [x 1 , x 2 ] − f [x 0 , x 1 ] (x 2 − x 0 )
f (x 2 )−f (x 1 ) x 2 −x 1 −^
f (x 1 )−f (x 0 ) x 1 −x 0 (x 2 − x 0 )
f (x 2 ) − 2 f (x 1 ) + f (x 0 ) h × 2 h
∆^2 f 0 2 h^2
In general, we have
Theorem 2. f [x 0 , x 1 ,... , xk] =
k!hk^
∆kf 0.
Proof is by induction on k.
For k = 0, the result is trivially true. We have also proved the result for k = 1, and k = 2. Assume now that the result is true k = m. Then we need to show that the result is also true for k = m + 1.
Now, f [x 0 , · · · , xm+1] =
f [x 1 ,... , xm+1] − f [x 0 ,... , xm] xm+1 − x 0
(∆mf 1 m!hm^ −^
∆mf 0 m!hm
(m + 1)h
∆m(f 1 − f 0 ) m!(m + 1)hm+^
∆m+1f 0 (m + 1)!hm+ The numbers ∆kfi are called kth^ order forward differences of f at x = i. We now show how the interpolating polynomial Pn(x) given by (2.16) can be written using forward differences.
Pn(x) = Pn(x 0 + sh) = f [x 0 ] + shf [x 0 , x 1 ] + s(s − 1)h^2 f [x 0 , x 1 , x 2 ]
∑^ n
k=
s(s − 1) · · · (s − k + 1)hkf [x 0 , x 1 , · · · , xk]
∑^ n
k=
s k
k!hkf [x 0 , x 1 , · · · , xn] =
∑^ n
k=
( (^) s k
∆kf 0 using (2.20).
Newton’s Forward-Difference Interpolation Formula
Let x 0 , x 1 , ..., xn be (n + 1) equidistant points with distance h; that is xi+1 − xi = h. Then Newton’s interpolating polynomial Pn(x) of degree at most n, using forward-differences ∆kf 0 , k = 0, 1 , 2 , ..., n is given by
Pn(x) =
∑^ n
k=
s k
∆kf 0 ,
where s =
x − x 0 h
Illustration: The Forward Difference Table with n = 4
∇fn = fn − fn− 1 , n = 1, 2 , 3 ,... ,
and
∇kfn = ∇(∇k−^1 fn), k = 2, 3 ,...
Thus, ∇^2 fn = ∇(∇fn) = ∇(fn − fn− 1 ) = fn − fn− 1 − (fn− 1 − fn− 2 ) = fn − 2 fn− 1 + fn− 2 , and so on. The following a relationship between the backward-differences and the divided differences can be obtained.
f [xn−k, · · · , xn− 1 , xn] =
k!hk^
∇kfn.
Using these backward-differences, we can write the Newton interpolation formula as:
Pn(x) = fn + s∇fn +
s(s + 1) 2!
∇^2 fn + ... +
s(s + 1)...(s + n − 1) n!
∇nfn.
Again, using the notation
(−s k
(−s)(−s − 1) · · · (−s − k + 1) k! we can rewrite the above formula as:
Newton’s Backward-Difference Interpolations Formula
Pn(x) =
∑^ n
k=
(−1)k
−s k
5 k^ fn.
So far we have been considering interpolation by means of a single polynomial in the entire range. Let’s now consider interpolation using different polynomials (but of the same degree) at different intervals. Let the function f (x) be defined at the nodes a = x 0 , x 1 , x 2 , ..., xn = b. The problem now is to construct piecewise polynomials Sj (x) on each interval [xj , xj+1], j = 0, 1 , 2 , ..., n − 1, so that the resulting function S(x) is an interpolant for the function f (x). The simplest such polynomials are of course, linear polynomials (straight lines). The inter- polating polynomial in this case is called linear spline. The two biggest disadvantages of a linear spline are (i) the convergence is rather slow, and (ii) not suitable for applications demanding smooth approximations, since these splines have corner at the knots.
“Just imagine a cross section of an airplane wing in the form of a linear spline and you quickly decide to go by rail. (Stewart (1998), p. 93).” Likewise the quadratic splines have also certain disadvantages. The most common and widely used splines are cubic splines. Assume that the cubic polynomial Sj (x), has the following form:
Sj (x) = aj + bj (x − xj ) + cj (x − xj )^2 + dj (x − xj )^3 , j = 0, 1 ,... , n − 1.
Since Sj (x) contains four unknowns, to construct n cubic polynomials S 0 (x), S 1 (x), ..., Sn− 1 (x), we need 4n conditions. To have these 4n conditions, a cubic spline S(x) for the function f (x) can be conveniently defined as follows:
Cubic Spline Interpolant
A function S(x), denoted by Sj (x), over the interval [xj , xj+1], j = 0, 1 , ..., n − 1 is called a cubic spline interpolant if the following conditions hold:
(i) Sj (xj ) = fj , j = 0, 1 , 2 , ..., n.
(ii) Sj+1(xj+1) = Sj (xj+1), j = 0, 1 , 2 , ..., n − 2.
(iii) S′ j+1(xj+1) = S′ j (xj+1), j = 0, 1 , 2 , ..., n − 2.
(iv) S′′ j+1(xj+1) = S′′ j (xj+1), j = 0, 1 , 2 , ..., n − 2.
Then, since for j there are four unkowns: aj , bj , cj , and dj and there are n such polynomials to be determined, all together there are 4n unknowns. However, conditions (i)-(iv) above give only (4n−2) equations: (i) gives n+1, and each of (ii)-(iv) gives n−1. So, to completely determine the cubic spline, we must need two more equations. To obtain these two additional equations, we can invoke boundary conditions.
We will discuss only the clamped cubic spline here. From the condition (i), it immediately follows that
aj = fj , j = 0, 1 , 2 , ..., n − 1.