Error Theory Interpolation
Error Theory Interpolation
Sep 3, 2021
1 Theory
Given some function f ∈ C[a, b]. Choose n + 1 distinct nodes in [a, b] and let pn (x) ∈ Pn satisfy the
interpolation condition
pn (xi ) = f (xi ), i = 0, . . . , n.
1
Exercise 1: Interpolation of 1+x2
Repeat the previous experiment with Runge’s function
1
f (x) = , x ∈ [−5, 5].
1 + x2
Note that the Taylor polynomial is in fact a polynomial of order n which not only interpolates f in x0 ,
but also its first, second etc. and n-th derivative f 0 , f 00 , . . . f (n) in x0 !
So the Taylor polynomial the unique polynomial of order n which interpolates the first n derivatives of
f in a single point x0 . In contrast, the interpolation polynomial pn is the unique polynomial of order n
which interpolates only the 0-order (that is, f itself), but in n distinctive points x0 , x1 , . . . xn .
For the Taylor polynomial Txn0 f (x) we have the error representation
f (n+1) (ξ)
f (x) − Txn0 f (x) = Rn+1 (x0 ) where Rn+1 (x0 ) = (x − x0 )n+1 ,
(n + 1)!
with ξ between x and x0 . Of course, we usually don’t know the exact location of ξ and thus not the exact
error, but we can at least estimate it and bound it from above:
M
|f (x) − Txn0 f (x)| 6 hn+1
(n + 1)!
where
M = max |f (n+1) (x)| and h = |x − x0 |.
x∈[a,b]
The next theorem gives us an expression for the interpolation error e(x) = f (x) − pn (x) which is similar
to what we have just seen for the error between the Taylor polynomial and the original functio f .
2
Given f ∈ C (n+1) [a, b]. Let pn ∈ Pn interpolate f in n + 1 distinct nodes xi ∈ [a, b]. For each
x ∈ [a, b] there is at least one ξ(x) ∈ (a, b) such that
n
f (n+1) (ξ(x)) Y
f (x) − pn (x) = (x − xi ).
(n + 1)! i=0
Before we turn to the proof of the theoreom, it might be useful to recall Rolle’s theorem and the mean
value theorem from Calculus 1, see also the Preliminaries.pdf notes:
Rolle’s theorem. Let f ∈ C 1 [a, b] and f (a) = f (b) = 0. Then there exists at least one ξ ∈ (a, b) such
that f 0 (ξ) = 0.
Mean value theorem. Let f ∈ C 1 [a, b]. Then there exists at least one ξ ∈ (a, b) such that
f (b) − f (a)
f 0 (ξ) = .
b−a
Clearly, the error in the nodes, e(xi ) = 0. Choose an arbitrary x ∈ [a, b] where x 6= xi , i = 0, 1, . . . , n. For
this fixed x, define a function in t as:
where e(t) = f (t) − pn (t). Notice that ϕ(t) is as differentiable with respect to t as f (t). The function ϕ(t)
has n + 2 distinct zeros (the nodes and the fixed x). As a consequence of Rolle’s theorem, the derivative
ϕ0 (t) has at least n + 1 distinct zeros, one between each of the zeros of ϕ(t). So ϕ00 (t) has n distinct zeros,
etc. By repeating this argument, we can see that ϕn+1 (t) has at least one zero in [a, b], let us call this ξ(x),
as it does depend on the fixed x. Since ω (n+1) (t) = (n + 1)! and e(n+1) (t) = f (n+1) (t) we obtain
Observation. The interpolation error consists of three elements: The derivative of the function f , the
number of interpolation points n + 1 and the distribution of the nodes xi . We cannot do much with
the first of these, but we can choose the two others. Let us first look at the most obvious choice of
nodes.
Equidistributed nodes. The nodes are equidistributed over the interval [a, b] if xi = a+ih, h = (b−a)/n.
In this case it can be proved that:
hn+1
|ω(x)| ≤ n!
4
such that
hn+1
|e(x)| ≤ Mn+1 , Mn+1 = max |f (n+1) (x)|.
4(n + 1) x∈[a,b]
3
Exercise 2: Interpolation error for sin(x) revisited
Let again f (x) = sin(x) and pn (x) the polynomial interpolating f (x) in n+1 equidistributed points on [0, 1].
An upper bound for the error for different values of n can be found easily. Clearly, maxx∈[0,2π] |f (n+1) (x)| =
Mn+1 = 1 for all n, so
n+1
1 2π
|en (x)| = |f (x) − pn (x)| ≤ , x ∈ [a, b].
4(n + 1) n
Use the code in the first Example of this lecture to verify the result for n = 2, 4, 8, 16. How close is the
bound to the real error?
# Plot omega(x)
n = 8 # Number of interpolation points is n+1
a, b = -1, 1 # The interval
x = np.linspace(a, b, 501)
xdata = np.linspace(a, b, n)
plt.plot(x, omega(xdata, x))
plt.grid(True)
plt.xlabel(’x’)
plt.ylabel(’omega(x)’)
print("n = {:2d}, max|omega(x)| = {:.2e}".format(n, max(abs(omega(xdata, x)))))
1
= max |ωCheb (x)| ≤ max |q(x)|
2n x∈[−1,1] x∈[−1,1]
4
The distribution of nodes can be transferred to an interval [a, b] by the linear transformation
b−a b+a
x= x̃ +
2 2
where x ∈ [a, b] and x̃ ∈ [−1, 1]. By doing so we get
n n
n+1 Y n+1
Y b−a b−a
ω(x) = (x − xi ) = (x̃ − x̃i ) = ωCheb (x̃).
j=0
2 j=0
2
Given f ∈ C (n+1) [a, b], and let Mn+1 = maxx∈[a,b] |f (n+1) (x)|. Let pn ∈ Pn interpolate f i n + 1
Chebyshev-nodes xi ∈ [a, b]. Then
(b − a)n+1
max |f (x) − pn (x)| ≤ Mn+1 .
x∈[a,b] 22n+1 (n + 1)!
The Chebyshev nodes over an interval [a, b] are evaluated in the following function:
def chebyshev_nodes(a, b, n):
# n Chebyshev nodes in the interval [a, b]
i = np.array(range(n)) # i = [0,1,2,3, ....n-1]
x = np.cos((2*i+1)*pi/(2*(n))) # nodes over the interval [-1,1]
return 0.5*(b-a)*x+0.5*(b+a) # nodes over the interval [a,b]
For information: Chebfun is software package which makes it possible to manipulate functions and
to solve equations with accuracy close to machine accuracy. The algorithms are based on polynomial
interpolation in Chebyshev nodes.