You are on page 1of 18

Engineering

Mathematics
2 Week 5_2
Interpolation

(BEng in CE / CSE / CGE Intake 14)

Interpolation and Polynomial


Approximation
Introduction:

A census of the population of the United


States is taken every 10 years. The following table lists
the population, in thousands of people, from 1940 to
1990.
Year

1940

Popula 132,16
tion
5
In

1950

1960

1970

151,32
6

179,32 203,30
3
2

1980
226,54
2

1990
249,633

reviewing these data, we might ask whether they


could be used to provide a reasonable estimate of the
population, say, in 1965, or even in the year 2010.
Predictions of this type can be obtained by using a
function that fits the given data.

Lagrangian Polynomials (Interpolation


with unevenly spaced points)

We assume that the given data are exact and represent values of some unknown function. If
we desire to find a polynomial that passes through the same points as our unknown function,
we could set up a system of equations involving the coefficients of the polynomial. For
example, suppose we want to fit a cubic to these data:

First,

F (x)

3.2

22.0

2.7

17.8

1.0

14.2

4.8

38.3

5.6

51.7

we need to select four points to determine our polynomial. (The


maximum degree of the polynomial is always one less than the number of
points.) Suppose we choose the first four points. If the cubic is ax 3 + bx2 + cx +
d. We can write 4 equations involving the unknown coefficients a, b, c and d:

Lagrangian Polynomials
When x = 3.2: a(3.2)3 + b(3.2)2 + c(3.2) + d = 22.0

x =2.7: a(2.7)3 + b(2.7)2 + c(2.7) + d = 17.8

x = 1.0: a(1.0)3 + b(1.0)2 + c(1.0) + d = 14.2

x = 4.8: a(4.8)3 + b(4.8)2 + c(4.8) + d = 38.3


The set of equations gives a= -0.5275, b= 6.4952, c=
-16.1177, d= 24.3499
And our polynomial is -0.5275 x 3 + 6.4952 x2 -16.1177 x +
24.3499
We can then estimate the values of the function at some
value of x , say, x = 3.0 by substituting 3.0 for x in the
polynomial. At x=3.0,the estimated value is 20.21.
We seek a better and simpler way of finding such
interpolating polynomials. The Lagrangian polynomial is
perhaps the simplest way to exhibit the existence of a
polynomial for interpolation with unevenly spaced data.

Lagrangian Polynomials

Suppose we have a table of data with four pairs of x and f(x) values.
x f(x)
-------------x 0 f0
x 1 f1
x 2 f2
x 3 f3

Here we do not assume uniform spacing between the x values, nor do


we need the x-values arranged in a particular order. The x values
must all be distinct, however. Through these four data pairs we can
pass a cubic. The Lagrangian form for this is

p3 ( x )

( x x1 )( x x2 )( x x3 )
( x x0 )( x x2 )( x x3 )
f0
f1
( x0 x1 )( x0 x2 )( x0 x3 )
( x1 x0 )( x1 x2 )( x1 x3 )

( x x0 )( x x1 )( x x3 )
( x x0 )( x x1 )( x x2 )
f2
f3
( x2 x0 )( x2 x1 )( x2 x3 )
( x3 x0 )( x3 x1 )( x3 x2 )

Lagrangian
Polynomials
Example:

Certain corresponding values of x and log 10x are (300,


2.4771),(304, 2.4829), (305,2.4843) and (307, 2.4871). Find log 10 301.

(3)(4)(6)
(1)( 4)( 6)
(2.4771)
(2.4829)
(4)(5)(7)
(4)(1)(3)
(1)( 3)(6)
(1)(3)(4)
(2.4843)
(2.4871)
(5)(1)( 2)
(7)(3)(2)

log10 301

= 1.2739+ 4.9658 4.4717 + 0.7106 = 2.4786


Example:

If y1 = 4, y3 = 12, y4 = 19 and yx = 7, find x.

(5)(12)
(3)(12)
(3)( 5)
(1)
(3)
(4)
(8)(15)
(8)(7)
(15)(7)
1 27 4

1.86
2 14 7
x

The

actual value is 2.0,since the above value is obtained from the


polynomial y(x)=x2 +3

Finite Differences

Assume that we have a table of values ( xi , yi ) , i = 0,1,2,,n of


any function y = f(x), the values of x being equally spaced, i.e. x i =
x0 + ih, i = 0,1,2,,n. Suppose that we are required to recover the
values of f(x) for some intermediate value of x, or to obtain the
derivative of f(x) for some x in the range x0 < x < xn. The methods
for the solution of these problems are based on the concept of the
differences of a function which we now proceed to define.

Forward Differences
If y0, y1,,yn denote a set of values of y, then y 1-y0, y2 y1,,yn yn-1
are called the differences of y. Denoting these differences by
y0 , y1 ,..., yn
respectively, we have

y0 y1 y0 , y1 y2 y1 ,..., yn 1 yn yn 1

Where is called the forward difference operator and


called the first forward differences.

y0 , y1 ,..., yn
are

Finite Differences
The differences of the first forward differences are called second forward
2 y0 , 2 y1 ,...
differences and are denoted by
Similarly, one can define third forward differences, fourth forward differences. etc.
2 y0 y1 y0 ( y2 y1 ) ( y1 y0 ) y2 2 y1 y0
Thus

3 y0 2 y1 2 y0 ( y3 2 y2 y1 ) ( y2 2 y1 y0 )
y3 3 y2 3 y1 y0
It is therefore clear that any higher order difference can easily be expressed in
terms of the ordinates.
The following table shows how the forward differences of all orders can be
performed:

Newtons Formulae for


Interpolation
Given

the set of (n+1) values, viz., ( x 0, y0), ( x1, y1),,( xn, yn), of x
and y, it is required to find yn (x), a polynomial of the nth degree
such that y and yn(x) agree at the tabulated points. Let the values
of x be equidistant, i.e., let xi = x0 + ih, i = 0,1,2,,n.
Since yn(x) is a polynomial of the nth degree, it may be written as
yn(x) = a0 + a1 (x x0 ) + a2 (x x0) (x x1)+ +an(x x0)( x x1)
( x xn-1) (i)
Imposing now the condition that y and y n(x) should agree at the
set of tabulated points, we obtain

Setting

y1 y0 y0
2 y0
a0 y0 ; a1

, a2 2 ,...
x1 x0
h
h 2

x = x0 + ph and substituting for a 0, a1,, equation (i) gives

p ( p 1) 2
p ( p 1)( p 2)...( p n 1) n
yn ( x) y0 py0
y0 ...
y0 ...(ii )
2
n
which is Newtons forward difference interpolation formula.

Newtons Formulae for Interpolation

Example:Find the cubic polynomial which takes the following values:


y (0) = 1, y (1) = 0 , y (2) = 1 and y (3) = 10. Hence or otherwise , obtain y(4).

We form the difference table:

Here h = 1, hence using the formula x = x 0+ph and choosing x0=0, we obtain p=x.
Substituting this value of p in (ii), we get y (x) = 1 + x(-1) + x(x-1).(2) / 2 + x(x-1)(x-2).(6)/6
= x3 2x2 + 1, which is the polynomial from which we obtained the above tabular values.
y (4) = 1 + 4(-1) +12 +24 = 33
Which is the same value as that obtained by substituting x = 4 in the cubic polynomial
above.
Note: This process of finding the value of y for some value of x outside the given range is
called extrapolation.

Newtons Formulae for Interpolation


Example: The table below gives the values of tanx for 0.10 < x < 0.30.
Find (i) tan 0.12
(ii) tan 0.26
(iii) tan 0.40
(iv) tan 0.50
The table of difference is
x
y
0.10 0.1003
0.0508
0.15 0.1511
0.0008
0.0516
0.0002
0.20 0.2027
0.0010
0.0002
0.0526
0.0004
0.25 0.2553
0.0014
0.0540
0.30 0.3093
To find tan(0.12),we have 0.12 = 0.10 + p(0.05) which gives p = 0.4.
Hence formula (ii) gives tan(0.12) = 0.1003 + 0.4(0.0508) + 0.4(0.4 1) (0.0008) /2
+ 0.4(0.4 1)( 0.4 2)(0.0002) / 6 + 0.4(0.4 1)( 0.4 2) ( 0.4 3)(.0002) / 24
= 0.1205
Task: ii, iii & iv

Newtons Formulae for Interpolation


Task:

The population of a town in the


decennial census was as given below.
Estimate the population for the year
1895.

Divided Differences
Let

( x0, y0), ( x1,y1), , ( xn,yn) be the given (n+1) points. Then the divided
differences of orders 1,2,,n are defined by the relations

x0 , x1

y1 y0
,
x1 x0

x0 , x1 , x2

x1 , x2 x0 , x1
x2 x0

..............................................

x0 , x1 ,..., xn

x1 , x2 ,..., xn x0 , x1 ,..., xn 1

xn x0

Even

if the arguments are equal, the divided difference may still have a meaning.
We then set x1=x0 +

x0 , x1 lim 0 x0 , x0 lim 0

It

is easy to see that:

Hence

x0 , x1

y x0 y x0
y ' ( x0 )

y0
y1

x1 , x0
x0 x1 x1 x0

the divided differences are symmetrical in their arguments.

Divided Differences
Now

let the arguments be equally spaced so that


x1-x0 = x2 x1 = = xn xn-1 = h. Then

x0 , x1
x0 , x1 , x2

y1 y0 1
y0
x1 x0 h

x1 , x2 x0 , x1

x2 x0

generally, x0 , x1 ,..., xn
If

1 y1 y0
1 2
2 y0

2h h
h
2h

1 n
y0
n
hn

the tabulated function is a polynomial of nth


degree, then n y0 would be a constant and
hence the nth divided difference would also be a
constant.

Newtons General Interpolation Formula


We

have, from the definition of divided differences,

x, x0

y y0
x x0

y y0 ( x x0 ) x, x0
Again x, x0 , x1

x, x0 x0 , x1
x x1

x, x0 x0 , x1 ( x x1 ) x, x0 , x1

y y0 ( x x0 ) x0 , x1 ( x x0 )( x x1 ) x, x0 , x1
But x, x0 , x1 , x2

x, x0 , x1 x0 , x1 , x2
x x2

So x, x0 , x1 x0 , x1 , x2 ( x x2 ) x, x0 , x1 , x2

y y0 ( x x0 ) x0 , x1 ( x x0 )( x x1 ) x0 , x1 , x2 ( x x0 )( x x1 )( x x2 ) x, x0 x1 , x2

Similarly , y y0 ( x x0 ) x0 , x1 ( x x0 )( x x1 ) x0 , x1 , x2 ( x x0 )( x x1 )( x x2 ) x0 , x1 x2 , x3

..................................................... ( x x0 )( x x1 )...( x xn ) x, x0 , x1 x2 ,..., xn

This

formula is called Newtons general interpolation formula with divided


differences, the last term being the remainder term after (n+1) terms.

Newtons General Interpolation


Formula
Example: Certain corresponding values of x and log 10x are
(300, 2.4771),(304, 2.4829), (305,2.4843) and (307,
2.4871). Find log10 301.
The divided difference table is

x
log10x
300 2.4771
0.00145
304 2.4829

-0.00001
0.00140

305 2.4843

0
0.00140

307 2.4871

Hence Newtons formula gives log 10 301= 2.4771


+0.00145 + (-3)(-0.00001) = 2.4786.

Newtons General Interpolation


Formula

Example: Using the following table find f(x) as a polynomial in x.

The divided difference table is


x
f(x)
-1 3
-9
0
-6
6
15
5
3
39
41
1
261
13
6
822
132
789
7
1611

Hence f (x ) = 3 + (x+1)(-9) + x(x+1)(6) + x(x+1)(x-3)(5) + x(x+1)(x-3)(x-6)

= x4 3x3 + 5x2 6.

Next
More

Numerical Methods

You might also like