You are on page 1of 6

4

Polynomial Interpolation

The goal of the first half of this course will be to discuss how we can improve on the idea of
the tangent line approximation, but in order to do that we need one more digression. We hope
that youll find this material to be useful in its own right.
Suppose we are given n + 1 points, which well label as (x0 , y0 ), (x1 , y1 ), . . . (xn , yn ), and
we would like to find a smooth curve which passes through all of them. The simplest such
curve will be a polynomial of degree n (for two points the simplest option is a line, for three
points it is a parabola, for four points it is a cubic, and so on).
For simplicity, lets begin by supposing that n = 3, and that the x values are

x0 = 0,

x1 = 1,

x2 = 2,

x3 = 3.

How do we proceed? Well, we want a cubic, so we write


y = a + bx + cx2 + dx3 .

(1)

If we plug in our four points (0, y0 ) , (1, y1 ) , (2, y2 ) , and (3, y3 ), we find
y0 = a
y1 = a + b + c + d

(2)

y2 = a + 2b + 4c + 8d
y3 = a + 3b + 9c + 27d.
We now have a system of four equations in four unknowns, for the coecients a, b, c, and d.
We could just solve this system with our familiar linear algebra techniques. However, Newton,
who didnt have standard linear algebra techniques at his disposal, found a useful formula for
the interpolating polynomail by solving for the coecients in an ingenious way. Heres what
he did:

First, he introduced some new notation. Well define the first finite dierences to be
y0 = y 1

y0

y1 = y 2

y1

y2 = y 3

y2

(and so on, if we have more than four points).


Calculating these quantities from the original system(2), we find
y0 = b + c + d
y1 = b + 3c + 7d
y2 = b + 5c + 19d,
and youll notice that all of the as have disappeared; weve reduced the problem to three
equations in three unknowns!
Next, we continue by defining the second finite dierences as

yn =

( yn ) =

yn+1

yn , which gives
2y

= 2c + 6d

2y

= 2c + 12d.
3

Finally, the third finite dierence, defined generally by


3

yn =

yn+1

yn , is

y0 = 6d.

Now we can solve for our coecients (in terms of the finite dierences):
d =

1
6

1
2

3y

2y

y0

3y

0
1
2

2y

1
3

3y

a = y0 .
Notice that weve kept only the finite dierences involving the zero subscript. Plugging these
results into (1) and collecting terms (by order of finite dierence) gives us (after a little bit of
work)
y = y0 + x y0 + x (x

1)

2y

2
2

+ x (x

1) (x

2)

3y

First Generalization
You can probably spot the pattern in the formula above, and guess that if we repeat these
calculations using more than four points well obtain this:

y = y0 + x y0 + x (x
. . . + x (x

1)
1) (x

2y
0
2!

+ x (x

2) (x

1) (x
n + 1)

2)
ny

3y
0
3!

+ ...

(3)

n!

This will look much simpler once you realize that we can calculate the finite dierences
very easily. If were working by hand, well usually use a triangular table; we start by writing
down all the y-values, then write the first finite dierences beside them, and then the second
finite dierences beside those, and so on... like this:
y0
y0
2y

y1

0
3y

y1
2y

y2

4y

1
3y

y2
2y

y3

0
0

y3
y4
All the coecients we need end up in the top diagonal row.
Example Find the 4th-order polynomial which passes through the points (0, 2), (1, 2),
(2, 12), (3, 62), and (4, 206).

Solution: Find the finite dierences:


2
0
2

10
10

30

12

40

24

50

54

62

94
144

206
Inserting them into formula (3) yields the following expression:
y = y0 + x y0 +
+ 4!1 x (x
= 2 + 0 + 5x (x

1
2! x (x

1) (x

1)

2) (x

1) + 5x (x

2y

3)

1) (x

1
3! x (x

4y

2) + x (x

1) (x

1) (x

2)

3y

2) (x

3) .

We wouldnt normally bother simplifying these expressions, but this one happens to simplify
to y = 2

x + x2

x3 + x4 .

Generalization to Non-integer Nodes


Lets now remove the restriction that the nodes x0 , x1 , x2 , . . .. be precisely the numbers
0, 1, 2, etc. We will still require them to be equidistant, however. That is, well require that
xn = x0 + nh for n = 0, 1, 2, . . . (so h is the distance between each pair of nodes). Nonequidistant nodes can also be dealt with, but we wont investigate that case in this course.
To find the appropriate form of the interpolating polynomials, we would repeat the procedure we used to find formula (3). The calculations are a bit messier, so we wont go through
them here; instead well just state the result.

The Newton Forward Dierence Formula Given n + 1 equidistant nodes x0 , xn =


x0 + nh, the nth -order polynomial passing through all of them is given by
y = y0 +
... +

(x x0 )
h

y0 +

(x x0 )(x x1 )
2!h2

(x x0 )(x x1 )(x xn+1 )


n!hn

ny

2y

+ ...

(4)

You should be able to see immediately that if we set x0 = 0 and h = 1, then we recover our
previous formula.
Example: Estimate the value of f (2.45) if f (x) passes through the points (2, 4), (2.2, 5),
(2.4, 4), and (2.6, 2).
Solution: The finite dierences are
4
1
5

2
1

1
2

2
and so we obtain the cubic

y =4+

(x 2) (x 2.2)
(x 2)
(x
(1) +
( 2) +
2
0.2
2! (0.2)

= 4 + 5 (x

2)

25 (x

2) (x

2.2) +

125
(x
6

2) (x 2.2) (x
3! (0.2)3

2.4)

2) (x

2.4) .

2.2) (x

(1)

Evaluating this at 2.45 suggests that f (2.45) 3.555.


Comments:
Notice that the last node, 2.6, doesnt appear explicitly in our formula. However, the
information about f at this node was included in the calculation of

3y

0.

Keep in mind that we have absolutely no knowledge about the error in our approximation,
5

because we have no information about how f behaves between the nodes. We are simply
assuming that its behaviour is predictable, and finding the simplest polynomial that
matches the information we do have.
Linear Interpolation
If you try a few examples, youll discover that polynomial interpolation can give surprising
results. If we dont trust the results, it may be more sensible to use just the closest two points
for each approximation. Our formula (4) is usually written dierently in this case.
First, we write
x1

y0 as y1

y0 (which is how we defined it in the first place), and h as

x0 . Then (4) reads


y = y0 +

(x
(x1

x0 )
(y1
x0 )

y0 ) .

This can be re-arranged:

(x
(x1

y= 1

(x
(x0

x1 )
(x
y0 +
x0 )
(x1

x1 )
(x
y0 +
x1 )
(x1

x0 )
y1
x0 )

x0 )
y1 .
x0 )

Finally, since y = f (x), you may see this expressed as

f (x)

(x
(x0

x1 )
(x
f1 +
x1 )
(x1

x0 )
f2 .
x0 )

This is known as the Lagrange Linear Interpolation Formula.


Exercise: Show that linear interpolation gives f (2.45) 3.5 in our previous example.