Professional Documents
Culture Documents
202004032250571912siddharth Bhatt Engg Interpolation
202004032250571912siddharth Bhatt Engg Interpolation
7
INTERPOLATION
Chapter Objectives
O Introduction
O Newton’s forward interpolation formula
O Newton’s backward interpolation formula
O Central difference interpolation formulae
O Gauss’s forward interpolation formula
O Gauss’s backward interpolation formula
O Stirling’s formula
O Bessel’s formula
O Everett’s formula
O Choice of an interpolation formula
O Interpolation with unequal intervals
O Lagrange’s interpolation formula
O Divided differences
O Newton’s divided difference formula
O Relation between divided and forward differences
O Hermite’s interpolation formula
O Spline interpolation—Cubic spline
O Double interpolation
O Inverse interpolation
O Lagrange’s method
274 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
O Iterative method
O Objective type of questions
7.1 Introduction
Suppose we are given the following values of y f(x) for a set of values
of x:
x: x0 x1 x2 xn
y: Y0 y1 y y.
2 n
y( x) a0 a1 ( x – x0 ) a2 ( x – x0 )( x – x1 ) a3 ( x – x0 )( x – x1 )( x – x2 )
an ( x – x0 )( x – x1 )( x – xn–1 ) (1)
Putting x x0, x1, , xn successively in (1), we get
y0 a0 , y1 a0 a1 ( x1 – x0 ), y2 a0 a1 ( x2 – x0 ) a2 ( x2 – x0 )( x2 – x1 )
and so on.
From these, we find that a0 y0 , y0 y1 – y0 a1 ( x1 – x0 ) a1 h
1
a1 y0
h
Also y1 y2 y1 a1 ( x2 x1 ) a2 ( x2 x0 )( x2 x1 )
a1 h a2 hh y0 2h2 a2
1
a2 2
y1 y0 1 2 2 y0
2h 2! h
1
Similarly a3 3 y0 and so on.
3! h3
Substituting these values in (1), we obtain
y0 2 y0 3 y0
y( x) y0 ( x x0 ) ( x x0 )( x x1 ) ( x x0 )( x x1 )( x x2 )
h 2! h2 3! h3
(2)
Now if it is required to evaluate y for x x0 ph, then
( x x0) ph, x x1 x x0 ( x x0) ph h ( p 1) h,
( x x0 ) x x0 ( x x0 ) (p 1)h h (p 2)h
etc.
Hence, writting y(x) = y(x0 + ph) = yp, (2) becomes
p(p 1) 2 p(p 1)(p 2) 3
yp y0 py0 y0 y0
2! 3!
p(p 1) p n - 1
n y0 (3)
3!
It is called Newton’s forward interpolation formula as (3) contains y0
and the forward differences of y0
Otherwise: Let the function y f(x) take the values y0, y1, y2, corre-
sponding to the values x0, x0 h, x0 2h, of x. Suppose it is required to
evaluate f(x) for x x0 ph, where p is any real number.
276 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
yp f ( x0 ph) E p f ( x0 ) (1 )p y0 [ E 1 ]
p(p 1) 2 p(p 1)(p 2) 3
1 p y0 y0 (4)
2! 3!
[Using binomial theorem]
p(p 1) 2 p(p 1)(p 2) 3
i.e., yp y0 py0 y0 y0
2! 3!
If y f(x) is a polynomial of the nth degree, then n1y0 and higher dif-
ferences will be zero.
Hence (4) will become
p(p 1) 2 p(p 1)(p 2) 3
yp y0 py0 y0 y0
2! 3!
p(p 1) p n 1 n
y0
3!
Which is same as (3)
EXAMPLE 7.1
The table gives the distance in nautical miles of the visible horizon for
the given heights in feet above the earth’s surface:
x height: 100 150 200 250 300 350 400
y distance: 10.63 13.03 15.04 16.81 18.42 19.90 21.27
Find the values of y when
(i) x 160 ft. (ii) x 410.
Solution:
The difference table is as under:
x y 2 3 4
100 10.63
2.40
150 13.03 – 0.39
2.01 0.15
200 15.04 – 0.24 – 0.07
1.77 0.08
250 16.81 – 0.16 – 0.05
1.61 0.03
300 18.42 – 0.13 – 0.01
1.48 0.02
350 19.90 – 0.11
1.37
400 21.27
(i) If we take x0 160, then y0 13.03, y0 2.01, 2y0 – 0.24,
0.08, 4 y0 – 0.05
3
278 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
x x0 10
Since x 160 and h 50, p 0.2
h 50
Using Newton’s forward interpolation formula, we get
p(p 1) 2 p(p 1)(p 2) 3
y218 yp y0 py0 y0 y0
2! 3!
p(p 1)(p 2)(p 3) 4
y0
4!
y160 13.03 0.402 0.192 0.0384 0.00168 13.46 nautical miles
(ii) Since x 410 is near the end of the table, we use Newton’s back-
ward interpolation formula.
x xn 10
Taking xn 400, p 0.2
h 50
Using the line of backward difference
yn 21.27, yn 1.37, 2 yn – 0.11, 3 yn 0.02 etc.
Newton’s backward formula gives
p p 1 2
y410 y400 py400 y400
2!
p(p 1)(p 2) 3 p(p 1)(p 2)(p 3) 4
y400 y400
3! 4!
0.2 1.2
21.27 0.2 1.37 0.11
2!
0.2 1.2 2.2 0.2 1.2 2.2 3.2
0.02 0.01
3! 4!
21.27 0.274 0.0132 0.0018 0.0007
21.53 nautical miles
EXAMPLE 7.2
From the following table, estimate the number of students who ob-
tained marks between 40 and 45:
Marks: 30—40 40—50 50—60 60—70 70—80
No. of students: 31 42 51 35 31
INTERPOLATION • 279
Solution:
First we prepare the cumulative frequency table, as follows:
Marks less than (x): 40 50 60 70 80
No. of students (yx): 31 73 124 159 190
Now the difference table is
x yx yx 2 yx 3yx 4yx
40 31
42
50 73 9
51 – 25
60 124 – 16 37
35 12
70 159 –4
31
80 190
We shall find y45, i.e., the number of students with marks less than 45.
Taking x0 40, x 45, we have
x x0 5
p 0.5 [ h 10]
h 10
Using Newton’s forward interpolation formula, we get
p(p 1) 2 p(p 1)(p 2) 3
y45 y40 py40 y40 y40
2! 3!
p(p 1)(p 2)(p 3) 4
y40
4!
0.50.5 0.50.515
31 0.5 42 9 25
2 6
0.50.5152.5
37
24
31 21 – 1.125 – 1.5625 – 1.4453
47.87, on simplification.
The number of students with marks less than 45 is 47.87, i.e., 48. But
the number of students with marks less than 40 is 31.
Hence the number of students getting marks between 40 and 45
48 – 31 17.
280 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.3.
Find the cubic polynomial which takes the following values:
x: 0 1 2 3
f(x): 1 2 1 10
Hence or otherwise evaluate f(4).
Solution:
The difference table is
x f(x) f(x) 2f(x) 3f(x)
0 1
1
1 2 –2
–1 12
2 1 10
9
3 10
x0
We take x0 0 and p x [ h 1]
h
Using Newton’s forward interpolation formula, we get
x x( x 1) 2 x( x 1)( x 2) 3
f ( x) f (0) f (0) f (0) f (0)
1 1.2 1.2.3
x( x 1) x( x 1)( x 2)
1 x 1 2 12
2 6
2 x3 7 x2 6 x 1
which is the required polynomial.
x xn
To compute f(4), we take xn 3, x 4 so that p 1 [ h 1]
h
EXAMPLE 7.4
Using Newton’s backward difference formula, construct an interpolat-
ing polynomial of degree 3 for the data: f (– 0.75) – 0.0718125, f (– 0.5)
– 0.02475, f (– 0.25) 0.3349375, f (0) 1.10100. Hence find f (– 1/3).
Solution:
The difference table is
x y y 2y 3y
– 0.75 – 0.0718125
0.0470625
– 0.50 – 0.02475 0.312625
0.3596875 0.09375
– 0.25 0.3349375 0.400375
0.7660625
0 1.10100
We use Newton’s backward difference formula
p p(p 1) 2 p(p 1)(p 2) 3
y( x) y3 y3 y3 y3
1! 2! 3!
x0 x h 0.25
taking x3 0, p 4x
h 0.25
4 x(4 x 1)
y x 1.10100 4 x(0.7660625) 0.400375
2
4 x(4 x 1)(4 x 2)
(0.09375)
6
1.101 3.06425 x 3.251 x2 0.81275 x x3 0.75 x2 0.125 x
x3 4.001 x2 4.002 x 1.101
1
Put x , so that
3
282 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
1 1 1 2 1
y 34.001 4.002 1.101
3 3 3 3
0.1745
EXAMPLE 7.5
In the table below, the values of y are consecutive terms of a series of
which 23.6 is the 6th term. Find the first and tenth terms of the series:
x: 3 4 5 6 7 8 9
y: 4.8 8.4 14.5 23.6 36.2 52.8 73.9
Solution:
The difference table is
x y y 2y 3y 4y
3 4.8
3.6
4 8.4 2.5
6.1 0.5
5 14.5 3.0 0
9.1 0.5
6 23.6 3.5 0
12.6 0.5
7 36.2 4.0 0
16.6 0.5
8 52.8 4.5
21.1
9 73.9
To find the first term, use Newton’s forward interpolation formula with
x0 3, x 1, h 1, and p – 2. We have
2 2 3 2 34
y(1) 4.8 3.6 2.5 0.5 3.1
1 1.2 1.2.3
To obtain the tenth term, u se Newton’s backward interpolation for-
mula with xn 9, x 10, h 1, and p 1.This gives
1 1 2 1(2) 3
y 10 73.9 21.1 4.5 0.5 100
1 1.2 1.2.3
INTERPOLATION • 283
EXAMPLE 7.6
Using Newton’s forward interpolation formula show
2
n(n 1)
n3
2
Solution:
If sn sn3, then sn1 (n 1)3
sn sn1 sn n 1 n3 3
n 1
3
3 3
Then 2 sn sn1 sn n 2 n 1 3n2 9 n 7
3 sn 2 sn1 2 sn
3 n 9 n 7 6 n 12
3 n 1 9 n 1 7
2 2
4 sn 3 sn1 3 sn 6 n 1 12 6 n 12 6
and 5 sn 5 sn ...... 0
Since the first term of the given series is 1, therefore taking n 1, s1 1,
s1 8, 2 s1 19, 3s1 18, 4 s1 6.
Substituting these in the Newton’s for war d interpolation formula, i.e.,
(n 1)(n 2) 2 (n 1)(n 2)(n 3) 3
s s(n – 1)s1 s1 s1
2! 3!
(n 1)(n 2)(n 3)(n 4) 4
s1
4!
19
sn 1 8(n – 1) (n – 1)(n – 2) 3(n – 1)(n – 2)(n – 3)
2
1 1 4 3 2 n(n 1)2
(n – 1)(n – 2)(n – 3)(n – 4) (n 2 n n )
4 4 2
Exercises 7.1
11. From the following data, estimate the number of persons having in-
comes between 2000 and 2500:
Income Below 500 500–1000 1000–2000 2000–3000 3000–4000
No. of persons 6000 4250 3600 1500 650
12. Construct Newton’s forward interpolation polynomial for the following
data:
x: 4 6 8 10
y: 1 3 8 16
Hence evaluate y for x 5.
13. 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).
Evaluate f (0.6)
15. Apply Newton’s backward difference formula to the data below, to ob-
tain a polynomial of degree 4 in x:
x: 1 2 3 4 5
y: 1 –1 1 –1 1
16. The following table gives the population of a town during the last six
censuses. Estimate the increase in the population during the period
from 1976 to 1978:
Year: 1941 1951 1961 1971 1981 1991
Population: 12 15 20 27 39 52
(in thousands)
17. In the following table, the values of y are consecutive terms of a series of
which 12.5 is the fifth term. Find the first and tenth terms of the series.
x: 3 4 5 6 7 8 9
y: 2.7 6.4 12.5 21.6 34.3 51.2 72.9
286 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
18. Using a polynomial of the third degree, complete the record given be-
low of the export of a certain commodity during five years:
Year: 1989 1990 1991 1992 1993
Export: 443 384 — 397 467
(in tons)
19. Given u1 40, u3 45, u5 54, find u2 and u4.
20. If u1 10, u1 8, u2 10,u4 50, find u0 and u3.
21. Given y0 3, y1 12, y2 81, y3 200, y4 100, y5 8, without form-
ing the difference table, find 5y0.
NOTE Obs. 1. This formula contains odd differences above the central
line and even differences on the central line as shown below:
y–2 3y–2 5y–3
1
2 p p(p 1)
2
Hence y y py p(p 1) y1 y0 2 3 y1 (4)
p 0 0
2! 2 3!
Which is known as Bessel’s formula.
NOTE Obs. 1. This formula is extensively used and involves only even
differences on and below the central line as shown below:
the Bessel’s formula and the coefficients of Bessel’s formula decrease more
rapidly than those of Newton’s formula. As such, whenever possible, central
difference formulae should be used in preference to Newton’s formulae.
The right choice of an interpolation formula however, depends on the
position of the interpolated value in the given data.
The following rules will be found useful:
1. To find a tabulated value near the beginning of the table, use Newton’s
forward formula.
2. To find a value near the end of the table, use Newton’s backward for-
mula.
3. To find an interpolated value near the center of the table, use either
Stirling’s or Bessel’s or Everett’s formula.
1 1
If interpolation is required for p lying between and , prefer Stirling’s
4 4
formula
1 3
If interpolation is desired for p lying between and , use Bessel’s
4 4
or Everett’s formula.
EXAMPLE 7.7
Find f(22) from the Gauss forward formula:
x: 20 25 30 35 40 45
f (x): 354 332 291 260 231 204
Solution:
Taking x0 25, h 5, we have to find the value of f(x) for x 22.
x x0 22 25
i.e., for p – 0.6
h 5
294 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.8
Use Gauss’s forward formula to evaluate y30, given that y21 18.4708,
y25 17.8144, y29 17.1070, y33 16.3432 and y37 15.5154.
Solution
Taking x0 29, h 4, we require the value of y for x 30
x x0 30 29
i.e., for p 0.25
h 4
INTERPOLATION • 295
25 –1 17.8144 – 0.0510
– 0.7074 – 0.7074
29 0 17.1070 – 0.0564 – 0.0022
– 0.7638 – 0.0076
33 1 16.3432 – 0.0640
– 0.8278
37 2 15.5154
EXAMPLE 7.9
Using Gauss backward difference formula, find y (8) from the following
table.
x 0 5 10 15 20 25
y 7 11 14 18 24 32
Solution:
Taking x0 10, h 5, we have to find y for x 8, i.e., for
x x0 8 10
p –0.4.
h 5
296 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.10
Interpolate by means of Gauss’s backward formula, the population of a
town for the year 1974, given that:
Year: 1939 1949 1959 1969 1979 1989
Population: 12 15 20 27 39 52
(in thousands)
Solution:
Taking x0 1969, h 10, the population of the town is to be found for
1974 – 1969
p 0.5
10
INTERPOLATION • 297
1949 –2 15
5
1959 –1 20 2
7 3
1969 0 27 5 −7
12 –4
1979 1 39 1
13
1989 2 52
Gauss’s backward formula is
(p 1)p 2 (p 1)p(p 1) 3
yp y0 py1 y1 y2
2! 3!
(p 2)p(p 1)p(p 1) 4
y2
4!
(p 2)(p 1)p(p 1)(p 2) 5
y3
5!
1.50.5 1.50.50.5
y0.5 27 (0.5)(7) 5
2 6
2.51.50.5 2.51.50.50.51.5
7 10
24 120
27 3.5 1.875 – 0.1875 0.2743 – 0.1172
32.532 thousands approx.
EXAMPLE 7.11
Employ Stirling’s formula to compute y12.2 from the following table
(yx 1 log10sinx):
x°: 10 11 12 13 14
105 yx: 23,967 28,060 31,788 35,209 38,368
298 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
Taking the origin at x0 12°, h 1 and p x – 12, we have the following
central difference table:
p yx yx 2yx 3yx 4yx
– 2 x2 0.23967 y2
0.04093 y2
– 1 x1 0.28060 y1 – 0.00365 2y2
0.03728 y1 0.00058 3y2
0 x0 0.31788 y0 – 0.00307 y1
2
– 0.00013 4y2
0.03421 y0 – 0.00045 2y1
1 x1 0.35209 y1 – 0.00062 y0
2
0.03159 y1
2 x2 0.38368 y2
1 1
At x 12.2, p 0.2. (As p lies between and , the use of String’s
4 4
formula will be Quite suitable.)
Stirling’s formula is
p y1 y0 p2 2 p(p2 1) 3 y2 3 y1
yp y0 y1 .
1 2 2! 3! 2
2 2
p (p 1) 4
y2
4!
When p 0.2, we have
0.03728 0.03421 0.2 2
y0.2 0.3178 0.2 0.00307
2 2
0.2 2
0.2 1
2
0.00058 0.00054 0.2
2
0.2 1
2
0.00013
6 2 24
EXAMPLE 7.12
Given
: 0 5 10 15 20 25 30
tan : 0 0.0875 0.1763 0.2679 0.3640 0.4663 0.5774
INTERPOLATION • 299
EXAMPLE 7.13
Apply Bessel’s formula to obtain y25, given y20 2854, y24 3162,
y28 3544, y32 3992.
300 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
Taking the origin at x0 24, h 4, we have p (x – 24).
The central difference table is
p y y 2y 3y
–1 2854
308
0 3162 74
382 –8
1 3544 66
448
2 3992
25 – 24 1 1 3
At x 25, p . . (As p lies between and , the use of
4 4 4 4
Bessel’s formula will yield accurate results)
Bessel’s formula is
1
p p(p 1)
p(p 1) 2 y1 2 y0 2
yp y0 py0 3 y1 (1)
2! 2 2!
When p 0.25, we have
0.25(0.75) 74 66 0.25 0.25(0.75)
yp 3162 0.25 382 8
2! 2 2!
3162 95.5 – 6.5625 – 0.0625
3250.875 approx.
EXAMPLE 7.14
Apply Bessel’s formula to find the value of f (27.5) from the table:
x: 25 26 27 28 29 30
f(x): 4.000 3.846 3.704 3.571 3.448 3.333
Solution:
Taking the origin at x0 27, h 1, we have p x – 27
INTERPOLATION • 301
EXAMPLE 7.15
Using Everett’s formula, evaluate f(30) if f(20) 2854, f(28) 3162,
f(36) 7088, f(44) 7984
Solution:
Taking the origin at x0 28, h 8, we have p x 28 . The central table
is 8
302 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
x p y y 2y 3y
20 –1 2854
308
28 0 3162 3618
3926 – 6648
36 1 7088 – 3030
896
44 2 7984
30 28
At x 30, p 0.25 and q 1 p 0.75
8
Everett’s formula is
q(q2 12 ) 2 q(q2 12 )(q2 22 ) 4
yp qy0 y1 y2
3! 5!
p(p2 12 ) 2 p(p2 12 )(p2 22 ) 4
py1 y0 y2
3! 5!
0.75(0.752 1)
0.75 3162 3618
6
0.25 0.252 1
0.25 7080 3030
6
2371.5 – 351.75 1770 94.69 3884.4
Hence f (30) 3884.4
EXAMPLE 7.16
Given the table
x: 310 320 330 340 350 360
log x: 2.49136 2.50515 2.51851 2.53148 2.54407 2.55630
find the value of log 337.5 by Everett’s formula.
Solution:
Taking the origin at x0 330 and h 10, we have p x 330
10
INTERPOLATION • 303
Exercises 7.2
1. Find they (25), given that y20 24, y24 32, y28 35, y32 40, using Gauss
for ward difference formula.
2. Using Gauss’s forward formula, fin d a polynomial of degree four which
takes the following values of the function f (x):
x: 1 2 3 4 5
f (x): 1 –1 1 –1 1
3. Using Gauss’s forward formula, evaluate f(3.75) from the table:
3 a c 2.5 c b c where a y0 y5 , b y1 y4 , c y2 y3 .
y5/2
256 2
[HINT: Use Bessel’s formula taking p 1/2.]
306 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.17
Given the values
x: 5 7 11 13 17
f(x): 150 392 1452 2366 5202
evaluate f(9), using Lagrange’s formula
Solution:
(i) Here x0 5, x1 7, x2 11, x3 13, x4 17
and y0 150, y1 392, y2 1452, y3 2366, y4 5202.
Putting x 9 and substituting the above values in Lagrange’s formula,
we get
(9 7)(9 11)(9 13)(9 17) (9 5)(9 11)(9 13)(9 17)
f (9) 150 392
(5 7)(5 11)(5 13)(5 17) (7 5)(7 11)(7 13)(7 17)
(9 5)(9 7)(9 13)(9 17)
1452
(11 5)(11 7)(11 13)(11 17)
(9 5)(9 7)(9 11)(9 17)
2366
(13 5)(13 7)(13 11)(13 17)
(9 5)(9 7)(9 11)(9 13)
5202
(17 5)(17 7)(17 11)(17 13)
50 3136 3872 2366 578
810
3 15 3 3 5
308 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.18
Find the polynomial f (x) by using Lagrange’s formula and hence find
f(3) for
x: 0 1 2 5
f (x): 2 3 12 147
Solution:
Here x0 0, x1 1, x2 2, x35
and y0 2, y1 3, y2 12, y3147.
Lagrange’s formula is
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y y0 y
( x0 x1 )( x0 – x2 )( x0 x3 ) ( x1 – x0 )( x1 – x2 )( x1 x3 ) 1
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y y
( x2 – x0 )( x2 – x1 )( x2 x3 ) 2 ( x3 – x0 )( x3 – x1 )( x3 x2 ) 3
( x 1)( x 2)( x 5) ( x 0)( x 2)( x 5)
(2) (3)
(0 1)(0 2)(0 5) (1 0)(1 2)(1 5)
( x 0)( x 1)( x 5) ( x 0)( x 1)( x 2)
12 (147)
(2 0)(2 1)(2 5) (5 0)(5 1)(5 2)
3 2
Hence f ( x) x x – x 2
f (3) 27 9 – 3 2 35
EXAMPLE 7.19
A curve passes through the points (0, 18), (1, 10), (3, –18) and (6, 90).
Find the slope of the curve at x 2.
Solution:
Here x0 0, x1 1, x2 3, x3 6 and y0 18, y1 10, y2 –18, y3 90.
Since the values of x are unequally spaced, we use the Lagrange’s for-
mula:
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y y0 y
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x1 x3 ) 1
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y2 y
( x2 – x0 )( x2 – x1 )( x2 x3 ) ( x3 – x0 )( x3 – x1 )( x3 x2 ) 3
INTERPOLATION • 309
EXAMPLE 7.20
3 x2 x 1
Using Lagrange’s formula, express the function as
a sum of partial fractions. x 1 x 2 x 3
Solution:
Let us evaluate y 3x2 x 1 for x 1, x 2 and x 3
These values are
x: x0 1 x1 2 x2 3
y: y0 5 y1 15 y2 31
Lagrange’s formula is
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
y y0 y1 y
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 – x0 )( x2 – x1 ) 2
EXAMPLE 7.21
Find the missing term in the following table using interpolation:
x: 0 1 2 3 4
y: 1 3 9 ... 81
Solution:
Since the given data is unevenly spaced, therefore we use Lagrange’s
interpolation formula:
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
y y0 y
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x1 x3 ) 1
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
y2 y
( x2 – x0 )( x2 – x1 )( x2 x3 ) ( x3 – x0 )( x3 – x1 )( x3 x2 ) 3
Here we have x0 0 x1 1 x2 2 x3 4
y0 1 y1 3 y2 9 y3 81
( x 1)( x 2)( x 4) ( x 0)( x 2)( x 4)
y 1 3
(0 1)(0 2)(0 4) (1 0)(1 2)(1 4)
( x 0)( x 1)( x 4) ( x 0)( x 1)( x 2)
9 (81)
(2 0)(2 1)(2 4) (4 0)(4 1)(4 2)
When x 3, then
(3 1)(3 2)(3 4) 3(3 1)(3 4) 9
y 3(3 2)(3 4)
8 4
3(3 1)(3 2) 1 27 81
(81) 3 31
24 4 2 24
Hence the missing term for x 3 is y 31.
EXAMPLE 7.22
Find the distance moved by a particle and its acceleration at the end of
4 seconds, if the time verses velocity data is as follows:
t: 0 1 3 4
v: 21 15 12 10
INTERPOLATION • 311
Solution:
Since the values of t are not equispaced, we use Lagrange’s formula:
(t t1 )(t t2 )(t t3 ) (t t0 )(t t2 )(t t3 )
v v v
(t0 t1 )(t0 t2 )(t0 t3 ) 0 (t1 t0 )(t1 t2 )(t1 t3 ) 1
(t t0 )(t t1 )(t t3 ) (t t0 )(t t1 )(t t3 )
v2 v
(t1 t0 )(t1 t2 )(t1 t3 ) (t1 t0 )(t1 t2 )(t1 t3 ) 3
(t 1)(t 3)(t 4) t(t 3)(t 4)
i.e. , v (21) (15)
(1)(2)(4) (1)(2)(3)
t(t 1)(t 4) t(t 1)(t 3)
(12) (10)
(3)(2)(1) (4)(3)(1)
1
i.e., v (–5t 3 38 t 2 – 105t 252)
12
4 4 ds
Distance moved s 0 vdt 0 (–5t 3 38 t 2 – 105t 252) v dt
1 5t 4 38 t 3 105t 2 4
– – 252 t
12 4 3 2 0
1 2432
–320 – 840 1008 54.9
12 3
dv 1
Also acceleration 15t 2 76 t 105 0
dt 2
1
Hence acceleration at (t 4) 15 76 4 105 3.4
2
Exercises 7.3
yo
1
2 8 2
y1 y1 1 1 y3 y1 1 y1 y3 .
2
[Hint: Here x0 – 3, x1 – 1, x2 1, x3 3.]
INTERPOLATION • 313
y1 y0 y0
x0 , x1
x1 x0 h
x1 , x2 x0 x1 1 y1 y0
x0 , x1 , x2
x2 x0 2h h h
1 1
2y0 and in general, [ x0 , x1 , x2 ,......, xn ] n y0
2!h 2
n! hn
If the tabulated function is a nth degree polynomial, then ny0 will be
constant. Hence the nth divided differences will also be constant
III. The divided difference operator 䊖 is linear
i.e., 䊖aux bvx a䊖 ux b䊖 vx
x1 x1 x0
ux ux0 vx vx0
a 1 b 1
x1 x0 x1 x0
a 䊖 ux0 b 䊖 vx0
x1 x0
y y0
x, x0
x x0
So that y y0 x x0
x, x0
x, x0
x0 , x1
Again
x, x0 , x1
x x1
which gives [ x, x0 ] [ x0 , x1 ] ( x – x1 )[ x, x0 , x1 ]
INTERPOLATION • 315
2 y1
Similarly [ x0 , x1 , x2 ]
2! h2
2 2
2 y1 2h 2 y0 2h 2 y1 2 y0
[ x0 , x1 , x2 , x3 ] x3 x0 3h
x3 x0 2h2 (3)
3 y0
Thus [ x0 , x1 , x2 , x3 ]
3! h3
n y0
In general, [ x0 , x1 , xn ]
n! h n
This is the relation between divided and forward differences.
EXAMPLE 7.23
Given the values
x: 5 7 11 13 17
f(x): 150 392 1452 2366 5202
evaluate f(9), using Newton’s divided difference formula
Solution:
The divided differences table is
x y 䊖y 䊖2y 䊖3y
5 150 392 150
121
75
7 392 265 121
24
11 5
1452 392 32 24
265 1
11 7 13 5
11 1452 457 265
32
13 7
2366 1452 42 32
457 1
13 11 17 7
13 2366 709 457
42
17 11
5202 2366
709
17 13
17 5202
INTERPOLATION • 317
EXAMPLE 7.24
Using Newton’s divided differences formula, evaluate f(8) and f(15)
given:
x: 4 5 7 10 11 13
y f(x): 48 100 294 900 1210 2028
Solution:
The divided differences table is
x f(x) 䊖y 䊖2y 䊖3y 䊖4y
4 48 0
52
5 100 15
97 1
7 294 21 0
202 1
10 900 27 0
310 1
11 1210 33
409
13 2028
Taking x 8 in the Newton’s divided difference formula, we obtain
f(8) 48 (8 – 4) 52 (8 – 4) (8 – 5) 15 (8 – 4) (8 – 5) (8 – 7) 1
448.
Similarly f(15) 3150.
EXAMPLE 7.25
Determine f(x) as a polynomial in x for the following data:
x: –4 –1 0 2 5
y f(x): 1245 33 5 9 1335
318 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
The divided differences table is
x f(x) 䊖y 䊖2y 䊖3y 䊖4y
–4 1245
– 404
–1 33 94
– 28 – 14
0 5 10 3
2 13
2 9 88
442
5 1335
Applying Newton’s divided difference formula
f ( x) f ( x0 ) ( x – x0 )[ x0 , x1 ] ( x – x0 )( x – x1 )[ x0 , x1 , x2 ]
1245 (x 4) (– 404) (x 4) (x 1) (94)
(x 4)(x 1)(x – 0)(– 14) (x 4)(x 1)x(x – 2)(3)
3x 5x + 6x2 14x + 5
4 2
EXAMPLE 7.26
Using Newton’s divided difference formula, find the missing value
from the table:
x: 1 2 4 5 6
y: 14 15 5 ... 9
Solution:
The divided difference table is
x y 䊖y 䊖2y 䊖3y
1 14
15 14
1
2 1
2 15 5 1
2
4 1
5 15 7 / 42 3
5
42 6 1 4
INTERPOLATION • 319
x y 䊖y 䊖2y 䊖3y
4 5 25 7
62 4
96
2
64
6 9
Newton’s divided difference formula is
y y0 ( x – x0 )[ x0 , x1 ] ( x – x0 )( x – x1 )[ x0 , x1 , x2 ]
( x – x0 )( x – x1 )( x – x2 )[ x0 , x1 , x2 , x3 ]
3
14 (x – 1) (1) (x – 1) (x – 2) (– 2) (x – 1) (x – 2) (x – 4)
4
Putting x 5, we get
3
y(5) 14 4 (4) (3) (– 2) (4) (3) (1) 3.
4
Hence missing value is 3
Exercises 7.4
where Ui (x) and Vi (x) are polynomials in x of degree (2n 1). These are to
be determined. Using the conditions (1), we get
INTERPOLATION • 321
EXAMPLE 7.27
For the following data:
x: f(x) f(x)
0.5 4 – 16
1 1 –2
Find the Hermite interpolating polynomial.
Solution:
We have x0 0.5, x1 1, y(x0) 4, y(x1) 1; y(x0) – 16, y(x1) – 2
x x0 x 1
Also Li ( x0 ) 2 x 1; Li ( x0 ) 2
xi x0 0.5
x x0 x 0.5
Li ( x1 ) 2 x 1; Li ( x1 ) 2
xi x0 1 0.5
Hermite’s interpolation formula in this case, is
P x [1 – 2( x – x0 )L( x0 )][L( x0 )]2 y( x0 ) ( x – x0 )[L( x0 )]2 y( x0 )
[1 – 4( x – 1)](4 x2 – 4 x 1) – 2 x – 1 (4 x2 – 4 x 1)
EXAMPLE 7.28
Apply Hermite’s formula to interpolate for sin (1.05) from the following
data:
x sin x cos x
1.00 0.84147 0.54030
1.10 0.89121 0.45360
INTERPOLATION • 323
Solution:
Here y(x) sin x and y(x) cos x
so that y(x0) 0.84147, y(x0) 0.54030, y(x1) 0.89121,
y(x1) 0.45360
x x0
Also Li ( x0 ) 11 10 x, Li ( x0 ) 10
xi x0
x x0
Li ( x1 ) 10 10 x, Li ( x1 ) 10
xi x0
Hence the Hermite’s interpolation formula in this case is
P( x) [1 – 2( x – x0 )L( x0 )][L( x0 )]2 y( x0 ) ( x – x0 )[L( x0 )]2 y( x0 )
[1 – 2( x – x1 )L( x1 )][L x1 )]2 y( x1 ( x – x1 )[L( x1 )]2 y( x1 )
EXAMPLE 7.29
Determine the Hermite polynomial of degree 4 which fits the following
data:
x: 0 1 2
y(x): 0 1 0
y(x): 0 0 0
Solution:
Here x0 0, x1 1, x2 2, y(x0) 0, y(x1) 1, y(x2) 0 and y(x0) 0,
y(x1) 0, y(x2) 0.
324 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.30
Using Hermite’s intropolation, find the value of f(– 0.5) from the fol-
lowing
x: –1 0 1
f(x): 1 1 3
f (x): –5 1 7
Solution:
Here x0 – 1, x1 0, x2 1; f(x0) 1, f(x1) 1, f(x2) 3 and f (x0) – 5,
f (x1) 1, f(x2) 7.
Hermite’s formula in this case is
P( x) U0 f ( x0 ) V0 f ( x0 ) U1 f ( x1 ) V1 f ( x1 ) U2 f ( x2 ) V2 f ( x2 ) (i)
2 2
where U0 [1 – 2 L0 ( x0 )( x – x0 )][L0 ( x)] , V0 ( x – x0 )[L0 ( x)]
U1 [1 – 2 L1 ( x1 )( x – x1 )][L1 ( x)]2 , V1 ( x – x1 )[L1 ( x)]2
U2 [1 – 2 L2 ( x2 )( x – x2 )][L2 ( x2 )]2 , V2 ( x – x2 )[L2 ( x)]2
( x x1 )( x x2 ) x( x 1) 1
and L0 ( x) , L0 ( x) x
( x0 x1 )( x0 x2 ) 2 2
( x − x0 )( x − x2 )
L1 ( x) = = 1 − x 2 = L1′( x) = −2 x
( x1 − x0 )( x1 − x2 )
( x x0 )( x x1 ) x( x 1) 1
L2 ( x) L2 ( x) x
( x2 x0 )( x2 x1 ) 2 2
INTERPOLATION • 325
1 1
U2 3 x 5 2 x 4 5 x3 4 x2 , V2 x 5 x 4 x3 x2
4 4
Substituting the values of U0,, V0, U1, V1; U2, V2 in (i), we get
1 1
P( x) 3 x 5 2 x 4 5 x3 4 x2 1 x 5 x 4 x3 x2
4 4
( x 4 – 2 x2 1)(1) ( x 5 – 2 x3 x)(1)
1 1
(3 x 5 2 x 4 5 x3 4 x2 )(3) ( x 5 x 4 x3 x2 )(7)
4 4
4 2
2 x – x x 1
Hence f (–0.5) 2(–0.5)4 – (–0.5)2 (–0.5) 1 0.375
Exercises 7.5
1. Find the Hermite’s polynomial which fits the following data:
x: 0 1 2
f(x): 1 3 21
f (x): 0 3 36
2. A switching path between parallel rail road tracks is to be a cubic poly-
nomial joining positions (0, 0) and (4, 2) and tangents to the lines y 0
and y 2. Using Hermite’s method, find the polynomial, given:
x y y
0 0 0
4 2 0
3. Apply Herm it e’s formula estimate the values of log 3.2 from the follow-
ing data:
x y log x y 1/ x
3.0 1.0986 0.3333
3.5 1.2528 0.2857
4.0 1.3863 0.2500
326 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
A2
f1(x) An–1
fi+1(x) fn–1(x)
f0(x) fi(x)
A0 Ai+2
Ai Ai+1 An
A1
y0 y1 y2 yi yi+1 yi+2 yn–1 yn
FIGURE 7.1
Cubic spline
Consider the problem of interpolating between the data points (x0, y0),
(x1, y1),(xn, yn) by means of spline fitting.
Then the cubic spline f(x) is such that
(i) f(x) is a linear polynomial outside the interval (x0, xn),
(ii) f(x) is a cubic polynomial in each of the subintervals,
(iii) f(x) and f(x) are continuous at each point.
Since f(x) is cubic in each of the subintervals f(x) shall be linear.
INTERPOLATION • 327
1 h2 1 h2
ai yi f ( xi ) and bi yi1 f ( xi1 )
h 3! h 3!
Substituting the values of ai, bi and writing f(xi) Mi, (1) takes the form
3 3
f ( x) =
( xi +1 – x )
M +
( x – xi )
M
i i +1
6h 6h
xi1 – x h2 x – xi h2
yi Mi yi1 Mi1 (2)
h 6 h 6
xi1 – x2 x – xi 2 h
f ( x) Mi Mi1 Mi1 Mi 1 yi1 yi
2h 6h 6 h
To impose the condition of continuity of f (x), we get
f ′( x – ε ) = f ′( x + ε ) as ε → 0
h 1 h 1
(2Mi Mi –1 ) (yi – yi –1 ) – (2Mi Mi1 ) (yi1 – yi )
6 h 6 h
6
Mi –1 4Mi Mi1 2 (yi –1 – 2 yi yi1 ), i 1 to n 1 (3)
h
Now since the graph is linear for x < x0 and x > xn, we have
M0 0, Mn 0 (4)
(3) and (4) give (n 1) equations in (n 1) unknowns Mi (i 0, 1, n)
which can be solved. Substituting the value of Mi in (2) gives the concerned
cubic spline.
328 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 7.31
Obtain the cubic spline for the following data
x: 0 1 2 3
y: 2 –6 –8 2
Solution:
Since the points are equispaced with h 1 and n 3, the cubic spline
can be determined from Mi–1 4Mi Mi+1 6 (yi–1 – 2yi yi+1), i 1, 2.
M0 4M1 M2 6 (y0 – 2y1 y2)
M1 4M2 M3 6 (y1 – 2y2 y3)
i.e., 4M1 M2 36; M1 4M2 72 [ M0 0, M3 0]
Solving these, we get M1 4.8, M2 16.8.
Now the cubic spline in (xi x xi 1) is
1 1 1
f ( x) = ( xi +1 − x )3 M i + ( x − xi )3 M i +1 + ( xi +1 − x ) ⎛⎜ yi − M i ⎞⎟
6 6 ⎝ 6 ⎠
1
x xi yi1 Mi1
6
Taking i 0 in (A) the cubic spline in (0 x 1) is
1 1 1
f ( x) (1 – x)3 (0) ( x – 0)3 4.8 (1 – x)( x – 0) x[–6 – 4.8
6 6 6
0.8x3 – 8.8x 2 (0 x 1)
Taking i 1 in (A), the cubic spline in (1 x 2) is
1 1 1
f ( x) = (2 – x)3 (4.8) + ( x – 1)3 (16.8) + (2 – x)[– 6 – ( 4.8 )]
6 6 6
+( x – 1)[– 8 – 1(16.8 )]
2x3 – 5.84x2 – 1.68x 0.8
Taking i 2 in (A), the cubic spline in (2 x 3) is
1 1
f ( x) (3 – x)3 (4.8) ( x – 2)3 (0) (3 – x)[– 8 – 1 16.8 ]
6 6
( x – 2)[2 – 1 2 ]
– 0.8x3 2.64x2 9.68x – 14.8
INTERPOLATION • 329
EXAMPLE 7.32
The following values of x and y are given:
x: 1 2 3 4
y: 1 2 5 11
Find the cubic splines and evaluate y(1.5) and y(3).
Solution:
Since the points are equispaced with h 1 and n 3, the cubic splines
can be obtained from
Mi–1 4Mi Mi+1 6(yi–1 – 2yi yi+1), i 1, 2.
M0 4M1 M2 6(y0 – 2y1 y2)
M1 4M2 M3 6(y1 – 2y2 y3)
i.e., 4M1 M2 12, M1 4M2 18 [ M0 0, M3 0]
which give, M1 2, M2 4.
Now the cubic spline in (xi x xi+1) is
1 1 1
f ( x) = ( xi +1 − x )3 M i + ( x − xi )3 M i +1 + ( xi +1 − x ) ⎛⎜ yi − M i ⎞⎟
6 6 ⎝ 6 ⎠
1
x xi yi1 Mi1 (A)
6
Thus, taking i 0, i 1, i 2 in (A), the cubic splines are
1 3
x 3 x 5 x 1 x 2
2
3
1
f ( x) x3 3 x2 5 x 2 x 3
3
1
3
2 x3 24 x2 76 x 81 3 x 4
y(1.5) f(1.5) 11/8
EXAMPLE 7.33
Find the cubic spline interpolation for the data:
x: 1 2 3 4 5
f (x): 1 0 1 0 1
330 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
Since the points are equispaced with h 1, n 4, the cubic spline can
be found by means of
Mi –1 4Mi Mi1 6(yi –1 – 2 yi yi1 ), i 1,2, 3
M0 4M1 M2 6 y0 – 2 y1 y2 12
M1 4M2 M3 6(y1 – 2 y2 y3 ) –12
M2 4 M3 M4 6(y2 – 2 y3 y4 ) 12
Since M0 y 0 0 and M4 y 4 0
4M1 M2 12; M1 4M2 M3 –12; M1 4M3 12
Solving these equations, we get M1 30/7, M2 – 36/7, M3 30/7
Now the cubic spline in (xi x xi1) is
1 1
f ( x) x x3 Mi x xi 3 Mi1 xi1 x
6 i1 6
⎛ 1 ⎞ ⎛ 1 ⎞
⎜ yi − M i ⎟ + ( x − xi ) ⎜ yi +1 − M i +1 ⎟ (A)
⎝ 6 ⎠ ⎝ 6 ⎠
Taking i 0, in (A), the cubic spline in (1 x 2) is
1 1
y
x1 x M0 x x0 M1
3 3
x1 x
y0 M0
6 6
1
x x0 y1 M1
6
1
3 3 2 x
2 x 0 x x0 (30 / 7)
1
1 0
6 6
1 30
x 1 0
6 7
i.e., y 0.71x – 2.14x 0.42x 2 (1 < x 2)
3 2
Exercises 7.6
Similarly, we can extend the said procedure for functions of three vari-
ables.
EXAMPLE 7.34
The following table gives the values of x and y:
x: 1.2 2.1 2.8 4.1 4.9 6.2
y: 4.2 6.8 9.8 13.4 15.5 19.6
Find the value of x corresponding to y 12, using Lagrange’s tech-
nique.
Solution:
Here x0 1.2, x1 2.1, x2 2.8, x3 4.1, x4 4.9, x5 6.2 and y0 4.2,
y1 6.8, y2 9.8, y3 13.4, y4 15.5, y5 19.6.
INTERPOLATION • 333
EXAMPLE 7.35
Apply Lagrange’s formula inversely to obtain a root of the equation
f(x) 0, given that f(30) – 30, f(34) – 13, f(38) 3, and f (42) 18.
Solution:
Herex0 30, x1 34, x2 38, x3 42
and y0 – 30, y1 – 13, y2 3, y3 18
It is required to find x corresponding to y f(x) 0.
Taking y 0, Lagrange’s formula gives
(y y1 )(y y2 )(y y3 ) (y y0 )(y y2 )(y y3 )
x x x
(y0 y1 )(y0 y2 )(y0 y3 ) 0 (y1 y0 )(y1 y2 ).(y1 y3 ) 1
(y y0 )(y y1 ).(y y3 ) (y y0 )(y y1 )(y y2 )
x x
(y2 y0 )(y2 y1 )(y2 y3 ) 2 (y3 y0 )(y3 y1 )(y3 y2 ) 3
13 318 30 3 18
30 34
17 3348 17 16 31
30 1318 30 133
38 42
33 16 15 48 3115
– 0.782 6.532 33.682 – 2.202 37.23.
Hence the desired root of f(x) 0 is 37.23.
334 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
1 p p 1 2
p2 yp y0 1 1 y0 (3)
y0
2!
To find the third approximation, retaining the term with third differ-
ences in (1) and replacing every p by p2, we have
1 p p 1 2 p2 p2 1 p2 2 3
p3 yp y0 2 2 y0 y0
y0
2! 3!
and so on. This process is continued till two successive approximations of p
agree with each other
EXAMPLE 7.36
The following values of y f(x) are given
x: 10 15 20
y: 1754 2648 3564
INTERPOLATION • 335
EXAMPLE 7.37
Using inverse interpolation, find the real root of the equation x3 x –
3 0, which is close to 1.2.
Solution:
The difference table is
x y Y x3 x 3 y 2y 3y 4y
1 – 0.2 –1 0.431
0.066
1.1 – 0.1 – 0.569 0.497 0.006
0.072 0
1.2 0 – 0.072 0.006
336 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
y 0
or 0 = –0.072 + 0.532 x + 0.036 x 2 + 0.001x3 (i)
This equation can be written a s
0.072 0.036 2 0.001 3
x x – x
0.532 0.532 0.532
0.072
First approximation x (1) = = 0.1353
0.532
Putting x x(1) on R.H.S. of (i), we get
Second approximation
x(2) 0.1353 – 0.067(0.1353)2 – 1.8797(0.1353)3 0.134
Hence the desired root 1.2 0.1 × 0.134 1.2134.
Exercises 7.7
1. Apply Lagrange’s method to find the value of x when f(x)5 from the
given data:
x: 5 6 9 11
f(x): 12 13 14 16
INTERPOLATION • 337
2. Obtain the value of t when A 85 from the following table, using La-
grange’s method:
t: 2 5 8 14
A: 94.8 87.9 81.3 68.7
3. Apply Lagrange’s formula inversely to obtain the root of the equation
f(x) 0, given that f(30) – 30, f(34) – 13, f(38) 3 and f(42) 18.
4. From the following data:
x: 1.8 2.0 2.2 2.4 2.6
y: 2.9 3.6 4.4 5.5 6.7,
find x when y 5 u sin g the iterative method.
Exercises 7.8
1. Select the correct answer or fill up the blanks in the following question:
Newton’s back war d interpolation formula is.........