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

W EEK

4
Newton’s forward / backward differ-
ences, Error in Polynomial Interpolation

Study Organiser

Before you begin this note, please check through your study organiser given below. It shows
the topics that we’ll be covering, the skills you need to acquire (the learning outcomes) and
the resources and activities you are given to help you acquire these skills.

Topics Learning Outcomes Learning Learning


Resources Activities
Newton’s forward Construct the forward difference Readings - Section 4.1 Tutorial 4
differences table and use it to estimate the Examples 4.1-4.2 Quiz 4
value of f (x) for a given x value. Glossary 4
Newton’s backward Construct the backward difference Readings - Section 4.2 Homework 4
differences table and use it to estimate the Examples 4.3-4.5 Assignment 1
value of f (x) for a given x value. Test 1
Error in Polynomial Calculate the upper bound of the Readings - Section 4.3
Interpolation absolute error involved in Examples 4.6-4.8
polynomial interpolation.

4.1 Newton’s Forward-Difference Formula

When x0 , x1 , x2 , . . . , xn are arranged consecutively with equal spacing, Newton form of the
interpolating formula can be expressed in a simplified form.
s(s − 1) 2 s(s − 1) · · · (s − n + 1) n
Pn (x) = f (x0 ) + s△f (x0 ) + △ f (x0 ) + · · · + △ f (x0 )
2! n!
x−x0
where s = h , h is the length of each interval and △f (xj ) = f (xj+1 ) − f (xj ).
2 W EEK 4

Proof
x−x0
Since s = h , we see that x = x0 + sh. So

x − xi = x0 + sh − xi
= sh + x0 − xi
= sh − ih
= (s − i)h

Since △f (xj ) = f (xj+1 ) − f (xj ), we can write the divided differences f [x0 ], f [x0 , x1 ], . . .,
f [x0 , x1 , . . . , xn ] as follows

f [x0 ] = f (x0 )
f [x1 ] − f [x0 ] 1
f [x0 , x1 ] = = △f (x0 )
x1 − x0 h
1
f [x1 , x2 ] − f [x0 , x1 ] △f (x1 ) − h1 △f (x0 )
f [x0 , x1 , x2 ] = = h
x2 − x0 2h
1
= △2 f (x0 )
2h2
1 2 1 2
f [x1 , x2 , x3 ] − f [x0 , x1 , x2 ] 2 △ f (x1 ) − 2h2 △ f (x0 )
f [x0 , x1 , x2 , x3 ] = = 2h
x3 − x0 3h
1 3
= △ f (x0 )
6h3
..
.
1
f [x0 , x1 , x2 , . . . , xn ] = △n f (x0 )
n!hn

The Newton interpolating polynomial can be written as

Pn (x) = c0 + c1 (x − x0 ) + c2 (x − x0 )(x − x1 ) + · · · + cn (x − x0 )(x − x1 ) · · · (x − xn−1 )


= f [x0 ] + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) + · · ·
+f [x0 , x1 , x2 , . . . , xn ](x − x0 )(x − x1 ) · · · (x − xn−1 )
1 1
= f (x0 ) + △f (x0 )(s)h + 2 △2 f (x0 )(s)h(s − 1)h + · · ·
h 2h
1 n
+ △ f (x0 )(s)h(s − 1)h · · · (s − n + 1)h
n!hn
s(s − 1) 2 s(s − 1) · · · (s − n + 1) n
= f (x0 ) + s△f (x0 ) + △ f (x0 ) + · · · + △ f (x0 )
2! n!

Newton’s Forward-Difference Table


If a table of function values (xi , f (xi )) is given we can construct from it a table of forward
differences. For example
W EEK 4 3

x f (x) △f (x) △2 f (x) △3 f (x)


x0 f (x0 )
△f (x0 )
x1 f (x1 ) △2 f (x0 )
△f (x1 ) △3 f (x0 )
x2 f (x2 ) △2 f (x1 )
△f (x2 )
x3 f (x3 )

Example 4.1. Construct the Newton’s forward difference table for the following data. Use it to
approximate f (0.5).

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

Solution

xi f (x) △f △2 f △3 f
0 3
-5
1 -2 3
-2 8
2 -4 11
9
3 5

x−x0 0.5−0
To approximate f (0.5), first note that s = h = 1 = 0.5. Thus

s(s − 1) 2 s(s − 1)(s − 2) 3


f (0.5) ≈ f (x0 ) + s△f (x0 ) + △ f (x0 ) + △ f (x0 )
2! 3!
(0.5)(−0.5) (0.5)(−0.5)(−1.5)
= 3 + (0.5)(−5) + (3) + (8)
2! 3!
= 0.625

Example 4.2. Construct the Newton forward difference table for the following data and use it to
approximate f (0.2).

x 0 0.5 1.0 1.5 2.0


f (x) 1 2 0 -1 3

Solution:
4 W EEK 4

x f (x) ∆f ∆2 f ∆3 f ∆4 f
0 1
1
0.5 2 -3
-2 4
1 0 1 0
-1 4
1.5 -1 5
4
2 3

0.2−0 3 4
s= 0.5 = 0.4 and f (0.2) ≈ 1 + 1s − 2! s(s − 1) + 3! s(s − 1)(s − 2) = 2.016.

4.2 Newton’s Backward-Difference Formula

If the nodes are reordered as xn , xn−1 , xn−2 , . . . , x0 , the Newton form of the interpolating
polynomial may be written as
s(s + 1) 2 s(s + 1) · · · (s + n − 1) n
Pn (x) = f (xn ) + s∇f (xn ) + ∇ f (xn ) + · · · + ∇ f (xn )
2! n!
x−xn
where s = h , h is the length of each interval and ∇f (xj ) = f (xj ) − f (xj−1 ).

Proof:
x−xn
Since s = h , we see that x = xn + sh. So

x − xi = xn + sh − xi
= sh + xn − xi
= sh + (n − i)h
= (s + n − i)h

Since ∇f (xj ) = f (xj ) − f (xj−1 ), we can write the divided differences f [xn ], f [xn , xn−1 ], . . .,
f [xn , xn−1 , . . . , x0 ] as follows

f [xn ] = f (xn )
f [xn ] − f [xn−1 ] 1
f [xn , xn−1 ] = = ∇f (xn )
xn − xn−1 h
1
f [xn , xn−1 ] − f [xn−1 , xn−2 ] h ∇f (xn ) − h1 ∇f (xn−1 )
f [xn , xn−1 , xn−2 ] = =
xn − xn−2 2h
1 2
= ∇ f (x0 )
2h2
..
.
1
f [xn , xn−1 , . . . , x0 ] = ∇n f (xn )
n!hn
W EEK 4 5

The Newton interpolating polynomial can be written as

Pn (x) = f [xn ] + f [xn , xn−1 ](x − xn ) + f [xn , xn−1 , xn−2 ](x − xn )(x − xn−1 ) + · · ·
+f [xn , xn−1 , . . . , x0 ](x − xn )(x − xn−1 ) · · · (x − x0 )
1 1
= f (xn ) + ∇f (xn )(s)h + 2 ∇2 f (x0 )(s)h(s + 1)h + · · ·
h 2h
1 n
+ ∇ f (xn )(s)h(s + 1)h · · · (s + n − 1)h
n!hn
s(s + 1) 2 s(s + 1) · · · (s + n − 1) n
= f (xn ) + s∇f (xn ) + ∇ f (xn ) + · · · + ∇ f (xn )
2! n!

Newton’s Backward-Difference Table


If a table of function values (xi , f (xi )) is given we can construct from it a table of backward
differences. For example

x f (x) ∇f (x) ∇2 f (x) ∇3 f (x)


x0 f (x0 )
∇f (x1 )
x1 f (x1 ) ∇2 f (x2 )
∇f (x2 ) ∇3 f (x3 )
x2 f (x2 ) ∇2 f (x3 )
∇f (x3 )
x3 f (x3 )

Example 4.3. Construct the Newton’s backward difference table for the following data. Use it to
approximate f (2.3).

x 1 1.5 2 2.5
f (x) -3 2 3 -5

Solution

xi f (x) ∇f ∇2 f ∇3 f
1 -3
5
1.5 2 -4
1 -5
2 3 -9
-8
2.5 -5
6 W EEK 4

x−xn 2.3−2.5
To approximate f (2.3), first note that s = h = 0.5 = −0.4. Thus

s(s + 1) 2 s(s + 1)(s + 2) 3


f (2.3) ≈ f (xn ) + s∇f (xn ) + ∇ f (xn ) + ∇ f (xn )
2! 3!
(−0.4)(0.6) (−0.4)(0.6)(1.6)
= −5 + (−0.4)(−8) + (−9) + (−5)
2! 3!
= −0.4

Example 4.4. Construct the Newton’s backward difference table for the following data. Use it to
approximate f (1.8).

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

Solution:

x f (x) ∇f ∇2 f ∇3 f ∇4 f
-2 -3
5
-1 2 -11
-6 28
0 -4 17 -62
11 -34
1 7 -17
-6
2 1

x−xn 1.8−2
To approximate f (1.8), first note that s = h = 1 = −0.2. Thus

(−0.2)(0.8) (−0.2)(0.8)(1.8)
f (1.8) ≈ 1 + (−0.2)(−6) + (−17) + (−34) +
2! 3!
(−0.2)(0.8)(1.8)(2.8)
(−62)
4!
= 7.2752

Example 4.5. Prove that


1. △ f (xi ) + g(xi ) = △f (xi ) + △g(xi )

2. ∇ f (xi ) + g(xi ) = ∇f (xi ) + ∇g(xi )

Solution
W EEK 4 7

1. Note that △f (xi ) = f (xi+1 ) − f (xi ). Thus


  
△ f (xi ) + g(xi ) = f (xi+1 ) + g(xi+1 ) − f (xi ) + g(xi )
 
= f (xi+1 ) − f (xi ) + g(xi+1 ) − g(xi )
= △f (xi ) + △g(xi )

2. Note that ∇f (xi ) = f (xi ) − f (xi−1 ). Thus


  
∇ f (xi ) + g(xi ) = f (xi ) + g(xi ) − f (xi−1 ) + g(xi−1 )
 
= f (xi ) − f (xi−1 ) + g(xi ) − g(xi−1 )
= ∇f (xi ) + ∇g(xi )

4.3 The Error in Polynomial Interpolation

Let f (n+1) be continuous in [a, b], and let p be the polynomial of degree at most n that inter-
polates the function f at n + 1 distinct points x0 , x1 , x2 , . . . , xn in the interval [a, b]. Then to
each x ∈ [a, b], there corresponds a point ξx in (a, b) such that
n
1 Y
f (x) − p(x) = f (n+1) (ξx ) (x − xi )
(n + 1)!
i=0

Proof: Omitted.

Example 4.6. If the function f (x) = sin x is approximated by a polynomial of degree 12 that inter-
polates f at 13 points in the interval [0, 1], how large is the absolute error on this interval?

Solution
The absolute error in the interpolation is
12
1 (13) Y
|f (x) − P12 (x)| = |f (ξx )| |x − xi |
13!
i=0

Note that

f (x) = sin x
f ′ (x) = cos x
f ′′ (x) = − sin x
f ′′′ (x) = − cos x
..
.
| sin x|, if k is even
(k)
|f (x)| =
| cos x|, if k is odd
8 W EEK 4

So |f (13) (ξx )| = | cos ξx | ≤ 1. On the interval [0,1], |x − xi | ≤ 1 so


12
Y
|x − xi | ≤ (1)13 = 1.
i=0

Thus
1
|f (x) − P12 (x)| ≤ (1)(1) ≈ 1.61 × 10−10 .
13!

Equally Spaced Nodes


When the nodes x0 , x1 , x2 , . . . , xn are equally spaced then
n
Y 1
|x − xi | ≤ hn+1 n!
4
i=0

b−a
where h = n .

Example 4.7. Let the function f (x) = ln x be approximated by an interpolation polynomial of degree
8 with the nodes equally spaced in the interval [2, 4]. What upper bound can be placed on the error?

Solution
The absolute error in the interpolation is
8
1 (9) Y
|f (x) − P8 (x)| = |f (ξx )| |x − xi |
9!
i=0

Note that

f (x) = ln x
1
f ′ (x) =
x
1
f ′′ (x) = − 2
x
′′′ 2
f (x) =
x3
6
f (4) (x) = − 4
x
..
.
(k − 1)!
|f (k) (x)| =
|xk |
8! 8!
So |f (9) (ξx )| = |ξx |9
≤ 29
. Since the nodes are equally spaced

8
Y 1 8!
|x − xi | ≤ h9 8! = 10 .
4 4
i=0
W EEK 4 9

Thus
1 8! 8!
|f (x) − P8 (x)| ≤ = 8.34 × 10−6 .
9! 29 410

Example 4.8. More Examples on Error in Polynomial Interpolation

1. Let the function f (x) = ln x be approximated by an interpolation polynomial of degree


8 with the nodes equally spaced in the interval [2, 4]. What upper bound can be placed
on the error?

Solution
The absolute error in the interpolation is

8
1 Y
|f (x) − P8 (x)| = |f (9) (ξx )| |x − xi |
9!
i=0

Note that

f (x) = ln x
1
f ′ (x) =
x
1
f ′′ (x) = − 2
x
′′′ 2
f (x) =
x3
6
f (4) (x) = − 4
x
..
.
(k) (k − 1)!
|f (x)| =
|xk |

8! 8!
So |f (9) (ξx )| = |ξx |9
≤ 29
. Since the nodes are equally spaced

8
Y 1 8!
|x − xi | ≤ h9 8! = 10 .
4 4
i=0

Thus
1 8! 8!
|f (x) − P8 (x)| ≤ = 8.34 × 10−6 .
9! 29 410

2. If the function f (x) = sinh x is approximated by a polynomial of degree 22 that inter-


polates f at 23 points in the interval [0, 1], how large is the error on this interval?
10 W EEK 4

Solution
The absolute error in the interpolation is
22
1 (23) Y
|f (x) − P22 (x)| = |f (ξx )| |x − xi |
23!
i=0

Note that
f (x) = sinh x
f ′ (x) = cosh x
f ′′ (x) = sinh x
f ′′′ (x) = cosh x
..
.
| sinh x|, if k is even
(k)
|f (x)| =
| cosh x|, if k is odd

So |f (23) (ξx )| = | cosh ξx | ≤ | cosh 1|. On the interval [0,1], |x − xi | ≤ 1 so,


22
Y
|x − xi | ≤ 123 = 1.
i=0

Thus
1
|f (x) − P22 (x)| ≤ | cosh 1|(1) ≈ 5.97 × 10−23 .
23!
3. If we interpolate the function f (x) = ex with a polynomial p of degree 12 using 13
nodes in [−2, 0], what is a good upper bound for |f (x) − p(x)| on [−2, 0]?

Solution
The absolute error in is
12
1 (13) Y
|f (x) − p(x)| = |f (ξx )| |x − xi |
13!
i=0

Note that
f (x) = ex
f ′ (x) = ex
f ′′ (x) = ex
f ′′′ (x) = ex
..
.
|f (k) (x)| = |ex | = ex
So |f (13) (ξx )| = eξx ≤ 1 for ξx ∈ [−2, 0]. On the interval [-2,0], |x − xi | ≤ 2 so,
12
Y
|x − xi | ≤ 213 .
i=0
W EEK 4 11

Thus
1
|f (x) − p(x)| ≤ (1)(213 ) ≈ 1.32 × 10−6 .
13!
4. Let the function f (x) = −1/x2 be approximated by an interpolating polynomial of de-
gree 12 with the nodes equally spaced in the interval [1, 3]. What bound can be placed
on the absolute error?

Solution
The absolute error is
12
1 (13) Y
|f (x) − P12 (x)| = |f (ξx )| |x − xi |
13!
i=0

Note that
1
f (x) = −
x2
2
f ′ (x) =
x3
6
f ′′ (x) = −
x4
24
f ′′′ (x) =
x5
120
f (4) (x) = − 6
x
..
.
(k + 1)!
|f (k) (x)| = .
|xk+2 |
14! 14!
So |f (13) (ξx )| = |ξx |15
≤ 115
= 14! for ξx ∈ [1, 3]. Since the nodes are equally spaced

12  13
Y 1 12! 2
|x − xi | ≤ h13 12! = .
4 4 12
i=0

Thus  13
1 12! 2
|f (x) − P12 (x)| ≤ (14!) ≈ 0.128.
13! 4 12

5. Suppose cos x is to be approximated by an interpolating polynomial p(x) of degree n,


using n + 1 equally spaced nodes in the interval [0, π/2]. Find max | cos x − p(x)|.
0≤x≤π/2
(Express your answer in terms of n.)

Solution
The absolute error is
n
1 Y
|f (x) − p(x)| = |f (n+1) (ξx )| |x − xi |.
(n + 1)!
i=0
12 W EEK 4

Note that

f (x) = cos x
f ′ (x) = − sin x
f ′′ (x) = − cos x
f ′′′ (x) = sin x
..
.
| cos x|, if k is even
(k)
|f (x)| =
| sin x|, if k is odd

So |f (n+1) (ξx )| ≤ 1 for ξx ∈ [0, π/2]. Since the nodes are equally spaced
n  n+1
Y 1 n! π/2 − 0 n!  π n+1
|x − xi | ≤ hn+1 n! = = .
4 4 n 4 2n
i=0

Thus
1 n!  π n+1 1  π n+1
|f (x) − p(x)| ≤ (1) = .
(n + 1)! 4 2n 4(n + 1) 2n
1  π n+1
Hence max | cos x − p(x)| = .
0≤x≤π/2 4(n + 1) 2n

You might also like