INTERPOLATION
Interpolation means to adjust data to fit a relation. Mathematically it is the science of
fitting a set of (n +1) points to a polynomial of degree n.
An efficient method is due to Lagrange by which a set of (n+1) points can satisfy an nth
degree polynomial.
a) Lagrange Method:
To demonstrate this on a simple example, suppose we wish to pass a straight line by the
two points: ( x0 , y0 ) , ( x1, y1)
y y0 y1 y0
It is easy to see that the equation is
x x0 x1 x0
or in the more tractable form of Lagrange
x x1 x x0
y P1( x) y0 y1
x0 x1 x1 x0
Lagrange was also able to write for (n+1) points, namely
( x0 , y 0 ) , ( x1, y1) , ( x2 , y 2 ) , . . . . . , ( xn , yn )
in the simple form
n
( x x )( x x ).....( x x )( x x )....(x x )
y Pn ( x) yi ( xi x00)( xi x11)....(xi xii11)( xi xii11).....(xi nxn )
i 0
Or
( x x1 )( x x2 ).....( x xn 1 )( x xn )
y Pn ( x) y0
( x0 x1 )( x0 x2 ).....( x0 xn 1 )( x0 xn )
( x x0 )( x x2 ).....( x xn 1 )( x xn )
y1 ............
( x1 x0 )( x1 x2 ).....( x1 xn 1 )( x1 xn )
( x x0 )( x x1 ).....( x xn 2 )( x xn 1 )
yn
( xn x0 )( xn x1 ).....( x1 xn 2 )( xn xn 1 )
Page 1 of 12
or that
n
y Pn ( x) yi Ln,i
i 0
in which
n
(x x j )
Ln,i ( xi x j )
j 0
j i
Notice that the polynomial Pn (x) is called the rational function and is used to evaluate the
approximate value of y at a given value of x xi , i 0,1,2,..., n
A similar formula is used to evaluate the approximate value of x at a given value of y .
This formula is
( y y1 )( y y 2 ).....( y y n 1 )( y y n )
x Pn ( y ) x0
( y0 y1 )( y0 y 2 ).....( y 0 y n 1 )( y 0 y n )
( y y0 )( y y 2 ).....( y y n 1 )( y y n )
x1 ............
( y1 y0 )( y1 y 2 ).....( y1 y n 1 )( y1 y n )
( y y0 )( y y1 ).....( y y n 2 )( y y n 1 )
xn
( y n y 0 )( y n y1 ).....( y1 y n 2 )( y n y n 1 )
Example 1. Interpolate y 2.3 using the data in the given table:-
x 1.1 1.7 3
y 10.6 15.2 20.3
Solution:
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
y P2 ( x) y0 y1 y2
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
( x 1.7)( x 3) ( x 1.1)( x 3) ( x 1.1)( x 1.7)
y ( x) 10.6 15.2 20.3
(1.1 1.7)(1.1 3) (1.7 1.1)(1.7 3) (3 1.1)(3 1.7)
1.97031x 2 13.18354 x 1.51781
P 2.3 18.38132
Page 2 of 12
Example 2. Construct the Lagrange Interpolation polynomial for the function y sin x ,
choose the points x0 0 , x1 16 , x2 12
Solution:
Substitute in the given equation by the given values of x to get the table:
x 0 1 1
6 2
y 0 1 1
2
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
y P2 ( x) y0 y1 y2
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
( x 16 )( x 12 ) 1 ( x 0)( x 12 ) ( x 0)( x 16 )
y P2 ( x) 0 2 1
(0 16 )(0 12 ) ( 16 0)( 16 12 ) ( 12 0)( 12 16 )
9 x x 1 6 x x 1 3x 2 3.5 x
2 6
Example 3. Fit the points (0,0) , (1,2) , (2,3) , (3,5) to a third degree polynomial
(rational function).
( x 1)( x 2)( x 3) ( x 0)( x 2)( x 3)
Solution: y 0 2
(0 1)(0 2)(0 3) (1 0)(1 2)(1 3)
( x 0)( x 1)( x 2) ( x 0)( x 1)( x 2)
3 5
(2 0)(2 1)(2 3) (3 0)(3 1)(3 2)
1 3 19
x 1.5 x 2 x
3 6
Example 4. Use Lagrange’s formula to find the rational function used to evaluate y and
hence evaluate y 2 that fits the points given in the following table:
x 1 3 4 6
Solution: y -7 5 8 14
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y P3 ( x) y0 y1
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y2 y3
( x2 x0 )( x2 x1 )( x2 x3 ) ( x3 x0 )( x3 x1 )( x3 x2 )
Page 3 of 12
( x 3)( x 4)( x 6) ( x 1)( x 4)( x 6)
y 7 5
(1 3)(1 4)(1 6) (3 1)(3 4)(3 6)
8 ( x 1)( x 3)( x 6) 14 ( x 1)( x 3)( x 4)
(4 1)(4 3)(4 6) (6 1)(6 3)(6 4)
1
x 3 13 x 2 69 x 92
5
1
f 2 x 3 13 x 2 69 x 92 0.4
5
Example 5. Use Lagrange’s formula to obtain P x , P 0.5 , and P 3.2 that fit the following
readings:
x 0 1 2 3
Solution: y 0 1 8 28
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y P3 ( x) y0 y1
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y2 y3
( x2 x0 )( x2 x1 )( x2 x3 ) ( x3 x0 )( x3 x1 )( x3 x2 )
( x 1)( x 2)( x 3) ( x 0)( x 2)( x 3)
y 0 1
(0 1)(0 2)(0 3) (1 0)(1 2)(1 3)
8 ( x 0)( x 1)( x 3) 28 ( x 0)( x 1)( x 2)
(2 0)(2 1)(2 3) (3 1)(3 1)(3 2)
0.5 x x 2 x 3 4 x x 1 x 3 14
3
x x 1 x 2
7 3 1 2 1
P3 x x x x
6 2 3
7 1 1
P 0.5 0.53 0.52 0.5 0.1875
6 2 3
7 1 1
P 3.2 3.2 3 3.2 2 3.2 34.176
6 2 3
Example 6. Use Lagrange’s formula to get y at x 6 ,and y at x 2.5 that fit the
following data:
x 3 5 8 9
Solution: y 2 1 5 7
Page 4 of 12
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y P3 ( x) y0 y1
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y2 y3
( x2 x0 )( x2 x1 )( x2 x3 ) ( x3 x0 )( x3 x1 )( x3 x2 )
( x 5)( x 8)( x 9) ( x 3)( x 8)( x 9)
y 2 1
(3 5)(3 8)(3 9) (5 3)(5 8)(5 9)
5 ( x 3)( x 5)( x 9) 7 ( x 3)( x 5)( x 8)
(8 3)(8 5)(8 9) (9 3)(9 5)(9 8)
1 1
y ( x 5)( x 8)( x 9) ( x 3)( x 8)( x 9)
30 24
1 7
( x 3)( x 5)( x 9) ( x 3)( x 5)( x 8)
3 24
1 1
y 6 (6 5)(6 8)(6 9) (6 3)(6 8)(6 9)
30 24
1 7
(6 3)(6 5)(6 9) (6 3)(6 5)(6 8)
3 24
y6 1.8
Similarly
1 1
y 2.5 (2.5 5)(2.5 8)(2.5 9) (2.5 3)(2.5 8)(2.5 9)
30 24
1 7
(2.5 3)(2.5 5)(2.5 9) (2.5 3)(2.5 5)(2.5 8)
3 24
y2.5 2.9375
Example 7. Calculate the approximate value of the real root of the equation:
x 3 5x 5 0
Solution:
Since the root is the value of x at which y =0.
Since the equation is of degree three, so, the rational function is also of degree three, i.e.
contains four constants, so, we form a table contains four points , around the required root,
satisfy the equation y x 3 5 x 5
Suppose the table is in the form
x -1 0 1 2
y -11 -5 1 13
To evaluate x use the formula:
Page 5 of 12
( y y1 )( y y2 )( y y3 ) ( y y0 )( y y2 )( y y3 )
x x0 x1
( y0 y1 )( y0 y2 )( y0 y3 ) ( y1 y0 )( y1 y2 )( y1 y3 )
( y y0 )( y y1 )( y y3 ) ( y y0 )( y y1 )( y y2 )
x2 x3
( y2 y0 )( y2 y1 )( y2 y3 ) ( y3 y0 )( y3 y1 )( y3 y2 )
(0 5)(0 1)(0 13) (0 11)(0 1)(0 13)
x 1 0
(11 5)(11 1)(11 13) (5 11)(5 1)(5 13)
1 (0 11)(0 5)(0 13) 2 (0 11)(0 5)(0 1)
(1 11)(1 5)(1 13) (13 11)(13 5)(13 1)
x = 0.844 which is the required root.
3
Example 8. Find approximately the real root of the equation: x 2 x 5 0
Solution:
Since the root is the value of x at which y =0.
Since the equation is of degree three, so, the rational function is also of degree three, i.e.
contains four constants, so, we form a table contains four points , around the required root,
satisfy the equation y x 3 2 x 5
Suppose the table is in the form
x 1.9 2 2.1 2.3
y -1.941 -1 0. 61 2.567
To evaluate x use the formula:
( y y1 )( y y2 )( y y3 ) ( y y0 )( y y2 )( y y3 )
x x0 x1
( y0 y1 )( y0 y2 )( y0 y3 ) ( y1 y0 )( y1 y2 )( y1 y3 )
( y y0 )( y y1 )( y y3 ) ( y y0 )( y y1 )( y y2 )
x2 x3
( y2 y0 )( y2 y1 )( y2 y3 ) ( y3 y0 )( y3 y1 )( y3 y2 )
( y 1)( y 0.61)(2 2.567) ( y 1.941)( y 0.61)( y 2.567)
x 1.9 2
(1.941 1)(1.941 0.61)(1.941 2.567) (1 1.941)(1 0.61)(1 2.567)
( y 1.941)( y 1)( y 2.567) ( y 1.941)( y 1)( y 0.61)
2.1 2.3
(0.61 1.941)(0.61 1)(0.61 2.567) (2.567 1.941)(2.567 1)( 2.567 0.61)
Substituting in this formula by y =0 → x= 2.07 which is the required root.
b) Newton Divided Difference Method:
Page 6 of 12
Lagrange interpolation method is quite tedious, especially when wishes to expand L n ,i .
Another simpler method is due to Newton in which the polynomial Pn ( x) is written in the
form
Pn ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) ...... .... a n ( x x0 )............( x x n )
It is easy to see by substituting x x0 that
a0 Pn ( x0 ) f [ x0 ]
and that by substituting for x x1 that
Pn ( x1 ) a0
a1
x1 x 0
f [ x1 ] f [ x 0 ]
x1 x 0
which we shall call f [ x0 , x1 ] etc.... Thus the following table is obtained
x0 f [ x0 ]
f [ x1 ] f [ x0 ]
f [ x0 , x1 ]
x1 x0
f [ x1, x2 ] f [ x0 , x1 ]
x1 f [ x1] f [ x0 , x1 , x2 ]
x2 x0
f [ x2 ] f [ x1 ] f [ x1 , x 2 , x3 ] f [ x 0 x1 , x2 ]
f [ x1 , x2 ] f [ x0 , x1 , x 2 , x3 ]
x2 x1 x3 x0
f [ x2 , x3 ] f [ x1 , x2 ]
x2 f [ x2 ] f [ x1 , x2 , x3 ]
x3 x1
f [ x3 ] f [ x2 ] f [ x 2 , x3 , x 4 ] f [ x1 , x2 , x3 ]
f [ x2 , x3 ] f [ x1 , x 2 , x3 , x 4 ]
x2 x1 x 4 x1
.
.
.
.
xn f [ xn ]
Example 1. For the points (0,0) , (1,2) , (2,3) , (3,5) obtain a third degree polynomial
Solution:
0 a0 0
Page 7 of 12
20
a1 f [ x0 , x1 ] 2
1 0
1 2 1
1 2 a 2 f [ x0 , x1 , x2 ]
20 2
1 1
3 2 1
f [ x1 , x2 ] 1 a3 f [ x0 , x1 , x 2 , x3 ] 2 2
2 1 30 3
2 1 1
2 3 f [ x1 , x2 , x3 ]
3 1 2
53
f [ x2 , x3 ] 2
32
3 5
from which it follows that the polynomial is
P3 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
1 1
P3 ( x ) 0 2( x 0) ( x 0)( x 1) ( x 0)( x 1)( x 2)
2 3
1 1
2 x ( x 2 x ) ( x 3 3x 2 2 x )
2 3
1 19
x 3 15 . x2 x
3 6
Example 2. Obtain a fourth degree polynomial to fit the points
(1,0.7651977) , (13
. ,0.620086) , (16
. ,0.4554022) , (19
. ,0.2818186) ,(2.2,01103623
. )
Solution:
1 0.7651977
-0.4837057
1.3 0.6200860 -0.1087339
-0.548946 0.0658784
1.6 0.4554022 -0.0494433 0.0018251
-0.578612 0.0680685
1.9 0.2818186 0.0118183
-0.571521
2.2 0.1103623
from which it follows that the polynomial is
P4 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
a4 ( x x0 )( x x1 )( x x2 )( x x3 )
P4 ( x ) 0.7651977 0.4837057( x 1) 0.1087339( x 1)( x 1.3)
0.0658784( x 1)( x 1.3)( x 1.6) 0.001825( x 1)( x 1.3)( x 1.6)( x 1.9)
Example 3. Find the value of f 2 and the function with least degree (the rational function)
for the following readings:
Page 8 of 12
x -1.0 0.0 0.5 1.0 2.5 3.0
y 3.0 -2.0 -0.375 3.0 16.125 19.0
Solution:
-1 3.0
-5.0
0.0 -2.0 5.5
3.25 -1.0
0.5 -0.375 3.5 0
6.75 -1.0 0
1.0 3.0 1.0 0
8.75 -1.0
2.5 16.125 -1.5
5.75
3.0 19.0
from which it follows that the polynomial is
P3 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
P3 ( x ) 3 5( x 1) 5.5( x 1)( x 0) 1( x 1)( x 0)( x 0.5)
x 3 5x 2 x 2
3 2
f 2 2 52 2 2 12
Example 4. Find the value of log 4.01 from the following table:
X 4.0002 4.0104 4.0232 4.0294
Y 0.6020817 0.6031877 0.6045716 0.6052404
Solution:
4.0002 0.6020817
1.08431
4.0104 0.6031877 -0.013652
1.08117 0.024144
4.0232 0.6045716 -0.012947
1.07871
4.0294 0.6052404
from which it follows that the polynomial is
P3 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
P3 ( x ) 0.6020817 1.08431( x 4.0002) 0.0136521( x 4.0002)( x 4.0104)
0.024144( x 4.0002)( x 4.0104)( x 4.029)
f ( 4.01) 0.6020817 1.08431( 4.01 4.0002) 0.0136521( 4.01 4.0002)( 4.01 4.0104)
0.024144( 4.01 4.0002)( 4.01 4.0104)( 4.01 4.029)
f ( 4.01)
Page 9 of 12
Example 5. Find the value of y 0.5, y 3.2 using the data in the following table:
x 0 1 2 3
y 0 1 8 28
Solution:
0 0
1
1 1 3
7
7 6
2 8 6.5
20
3 28
from which it follows that the polynomial is
P3 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
7
P3 ( x ) 0 1( x 0) 3( x 0)( x 1) ( x 0)( x 1)( x 2)
6
7 1 1
y ( x) x 3 x 2 x
6 2 3
7 1 1
y (0.5) 0.53 0.52 0.5 0.18749997
6 2 3
Example 6. Form the interpolation polynomial for the function y f x for the data in the
given table using the general Newton’s formula, then use it to get the value of f 3.7608 .
X 0 2.5069 5.0154 7.5277
Y 0.3989423 0.39888169 0.3984408 0.398138
Solution:
0 0.3989423
-0.00005
2.5069 0.39888169 -0.0000199
-0.0001499 0.0
5.0154 0.3984408 -0.0000199
-0.0002496
7.5277 0.398138
from which it follows that the polynomial is
P2 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
P2 ( x ) 0.3989423 0.00005( x 0) 0.0000 ( x 0)( x 2.5069 )
y ( x) 1.99 10 5 x 2 1.1269 10 7 x 0.3989423
y (3.7608) 1.99 10 5 3.76082 1.1269 10 7 3.7608 0.3989423
0.3986604
Page 10 of 12
Example 7. Use Newton’s interpolation general formula to get the value of y at x 6
from the following set of data.
x 2 4 5 7 10
y 3 1 5 6 15
Solution:
2 3
-1
5
4 1 3
4 - 17
30
19
5 5 - 76 180
5
0.5 18
7 6 0.5
3
10 15
from which it follows that the polynomial is
P4 ( x) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 ) a3 ( x x0 )( x x1 )( x x2 )
a4 ( x x0 )( x x1 )( x x2 )( x x3 )
P4 ( x) 3 1( x 2) 53 ( x 2)( x 4) 17
30
( x 2)( x 4)( x 5)
19
180 ( x 2)( x 4)( x 5)( x 7 )
y (6) 3 1(6 2) 53 (6 2)(6 4) 17
30
19
(6 2)(6 4)(6 5) 180 (6 2)(6 4)(6 5)(6 7)
313
y (6) 3 4 53 (4)(2) 17
30
19
(4)(2)(1) 180 (4)(2)(1)(1) 6.955555555555556
45
Example 18. Interpolate y 2.3 using the data in the given table:-
x 1.1 1.7 3
y 10.6 15.2 20.3
Solution: using Newton’s general formula
1.1 10.6
7.66667
1.7 15.2 -1.97031
3.92308
3 20.3
from which it follows that the polynomial is
Page 11 of 12
P2 ( x ) a0 a1 ( x x0 ) a2 ( x x0 )( x x1 )
P2 ( x) 10.6 7.66667 ( x 1.1) 1.9731( x 1.1)( x 1.7)
y ( 2.3) 10.6 7.66667 ( 2.3 1.1) 1.9731( 2.3 1.1)( 2.3 1.7)
10.6 7.66667 (1.2) 1.9731(1.2)(0.6) 18.38135
Exercises:
1. Use Lagrange interpolation to fit a fourth-degree polynomial to the points
(1,0.765) (1.3,0.62) (1.6,0.455) (1.9,0.281) (2.2,0.11)
2. Use the divided-difference to fit a third-degree polynomial to the points
(-1,0.22) (-0.5,0.62) (0,0.55) (0.5,0.35)
3. Use Lagrange interpolation to find an approximate value for cos 0.75 if
cos 0.733 0.7432 cos 0.803 0.6946
++++++++++++++++++++++++++++++++++++++++++
Page 12 of 12