Interpolation and Approximation
Interpolation and Approximation
Interpolation and Approximation
6
FINITE DIFFERENCES
Chapter Objectives
O Introduction
O Finite differences
O Differences of a polynomial
O Factorial notation
O Reciprocal factorial function
O Inverse operator of
O Effect of an error on a difference table
O Other difference operators
O Relations between the operators
O To find one or more missing terms
O Application to summation of series
O Objective type of questions
6.1 Introduction
The calculus of finite differences deals with the changes that
take place in the value of the function (dependent variable), due to
finite changes in the independent variable. Through this, we also
study the relations that exist between the values assumed by the
function, whenever the independent variable changes by finite
jumps whether equal or unequal. On the other hand, in infinitesi-
mal calculus, we study those changes of the function which occur
234 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Value of x Value of y 1st diff. 2nd diff. 3rd diff. 4th diff. 5th diff.
x0 y0
y0
x0 h y1 2y0
y1 3y0
x0 2h y2 2y1 4y0
y2 3y1 5y0
x0 3h y3 y2
2
y1
4
y3 y2
3
x0 4h y4 y3
2
y4
x0 5h y5
FINITE DIFFERENCES • 235
Value of x Value of y 1st diff. 2nd diff. 3rd diff. 4th diff. 5th diff.
x0 y0
y1
x0 h y1 2y2
y2 3y3
x0 2h y2 2y3 4y4
y3 3y4 5y5
x0 3h y3 2y4 4y5
y4 y5
3
x0 4h y4 y5 2
y5
x0 5h y5
236 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Value of x Value of y 1st diff. 2nd diff. 3rd diff. 4th diff. 5th diff.
x0 y0
y1/2
x0 h y1 2y1
y3/2 3y3/2
x0 2h y2 2y2 4y2
y5/2 3y5/2 5y5/2
x0 3h y3 y3
2
y3
4
y7/2
x0 4h y4 2y4 3y7/2
y9/2
x0 5h y5
We see from this table that the central differences on the same horizon-
tal line have the same suffix. Also the differences of odd order are known
only for half values of the suffix and those of even order for only integral
values of the suffix.
It is often required to find the mean of adjacent values in the same col-
umn of differences. We denote this mean by .
1 1
Thus y1 (y1/2 y3/2 ), 2 y3/2 (2 y1 2 y2 ), etc.
2 2
Obs. The reader should note that it is only the notation which
NOTE
changes and not the differences. e.g.
252 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
10. Write down the polynomial of lowest degree which satisfies the fol-
lowing set of numbers: 0, 7, 26, 63, 124, 215, 342, 511
2 2
1/2 1/2
E E
1 1 1
1
1 1 1
(iv) yx y 1 y 1 E 2 yx E 2 yx E 2 E 2 yx
2 x2 h x h
2
2 2
1 1/2
E E1/2
2
(v) Eyx E(yx yx h) Eyx Eyx h yx + h yx yx
∴ E
Eyx yx + h yx + h yx yx
E
1 1 1
E1/2 yx y 1 y 1 h y 1 h h yxh – yx yx
x h
2
x h
2
2 x h
2
2 2
E1/2
Hence E E E1/2
h2
(vi) Ef ( x) f ( x h) f ( x) hf ( x) f ( x)
2!
[by Taylor’s series]
h2 2
f ( x) hDf x D f x ....
2!
h 2 D2 h 3 D3
1 hD f ( x) ehD f ( x)
2! 3!
E ehD
hD
Cor. E 1 e
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.
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
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
5
EMPIRICAL LAWS AND
CURVE-FITTING
Chapter Objectives
O Introduction
O Graphical method
O Laws reducible to the linear law
O Principle of least squares
O Method of least squares
O Fitting a curve of the type y a bx2, etc.
O Fitting of other curves
O Most Plausible values
O Method of group averages
O Laws containing three constants
O Method of moments
O Objective type of questions.
5.1 Introduction
In many branches of Applied Mathematics, it is required to ex-
press a given data, obtained from observations, in the form of a law
connecting the two variables involved. Such a law inferred by some
scheme, is known as the empirical law. For example, it may be de-
sirable to obtain the law connecting the length and the tempera-
ture of a metal bar. At various temperatures, the length of the bar
is measured. Then, by one of the methods explained below, a law
194 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 5.1
R is the resistance to motion of a train at speed V; find a law of the type
R a bV2 connecting R and V, using the following data:
V (km/hr): 10 20 30 40 50
R (kg/ton): 8 10 15 21 30
196 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
Given law is R a bV2 (i)
Taking V2 x and R y,
(i) becomes, y a bx (ii)
which is a linear law.
Table for the values of x and y is as follows:
x: 100 400 900 1600 2500
y: 8 10 15 21 30
Plot these points. Draw the straight line of best fit through these points
(Figure 5.1).
Y
40
(2500,30)
30
N
20 (1600,21)
L
(900,15) M
10 (400,10)
(100,8)
0 X
(0, 0) 400 800 1200 1600 2000 2400 2800
FIGURE 5.1
EXAMPLE 5.2
The following values of x and y are supposed to follow the law
y ax2 b log10x. Find graphically the most probable values of the constants
a and b.
EMPIRICAL LAWS AND CURVE-FITTING • 197
Solution:
Given law is y ax2 b log10x
y x2
i.e., a b (i)
log10 x log10 x
Putting x2/log10 x X and y/ log10x Y,
(i) becomes Y aX b (ii)
This is a linear law.
Table for the values of X and Y is as follows:
X x2/log10 x 17.93 25.56 32.49 42.87 53.75 67.80 80.83
Y y/log10 x 35.59 44.83 52.50 69.90 73.65 87.04 99.56
Points P1 P2 P3 P4 P5 P6 P7
Plot these points and draw the straight line of best fit through these points
(Figure 5.2).
95
P6
85
75
P5
65
P4
55
P3
M
P2
45
35 P1
X
0 15 25 35 45 55 65 75
FIGURE 5.2
MP5 73.65 52.50 21.15
Slope of this line ( a) 0.99
P3 M 53.75 32.49 21.26
198 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 5.3
The values of x and y obtained in an experiment are as follows:
x 2.30 3.10 4.00 4.92 5.91 7.20
y 33.0 39.1 50.3 67.2 85.6 125.0
The probable law is y aebx. Test graphically the accuracy of this law
and if the law holds good, find the best values of the constants.
Solution:
Given law is y aebx (i)
Taking logarithms to base 10, we have
log10y log10a (b log10e) x
Putting x X and log10y Y, it becomes
y (b log10e) X log10a (ii)
Table for the values of X and Y is as under:
Xx 2.30 3.10 4.00 4.92 5.91 7.20
Y log10 y 1.52 1.59 1.70 1.83 1.93 2.10
Points P1 P2 P3 P4 P5 P6
2.1
P6
2.0
P5
1.9
P4 N(5,1.83)
1.8
L(4,1.71) M
1.7 P3
1.6
P2
P1
0 X
(2, 1.5) 3 4 5 6 7 8
FIGURE 5.3
Exercises 5.1
1. If p is the pull required to lift the weight by means of a pulley block, find
a linear law of the form p a bw, connecting p and w, using the follow-
ing data:
w(lb): 50 70 100 120
p(lb): 12 15 21 25
Compute p, when w 150 lb.
a
Assuming a law of the form R b, find by graphical method the best
values of a and b. V
5. The following table gives the pressure p and the volume v at various
instants during the expansion of steam in a cylinder. Show that the equa-
tion of the expansion is of the form pvn c and find the values of n and c
approximately.
p: 200 100 50 30 20 10
v: 1.0 1.7 2.9 4.8 5.9 10
6. The following values of T and l follow the law T aln. Test if this is so
and find the best values of a and n.
T 1.0 1.5 2.0 2.5
l 25 56.2 100 1.56
Fit the curve y ae to the following data:
bx
x: 0 2 4
y: 5.1 10 31.1
The following are the results of an experiment on friction of bearings.
The speed being kept constant, corresponding values of the coefficient
of friction and the temperature are shown in the table:
t: 120 110 100 90 80 70 60
: 0.0051 0.0059 0.0071 0.0085 0.00102 0.00124 0.00148
If and t are given by the law aebt, find the values of a and b by
plotting the graph for and t.
Y Pn
(1)
en
Pi(xi, yi)
ei Mn
P1(x1, y1)
e1 Mi
e2 M2
M1
P2
0 X
L1 L2 Li Ln
FIGURE 5.4
Now we have to determine the constants a, b, c,... k such that they
represents the curve of best fit. In the case of n m, when substituting the
values (xi, yi) in (1), we get n equations from which a unique set of n con-
stants can be found. But when n > m, we obtain n equations which are more
than the m constants and hence cannot be solved for these constants. So we
try to determine the values of a, b, c, k which satisfy all the equations as
nearly as possible and thus may give the best fit. In such cases, we apply the
principle of least squares.
At x xi, the observed (experimental) value of the ordinate is yi and the
corresponding value on the fitting curve (1) is a bxi cxi2 kxim ( i,
say) which is the expected (or calculated) value (Figure 5.4). The difference
of the observed and the expected values, i.e., yi – i( ei) is called the error
(or residual) at x xi. Clearly some of the errors e1, e2,, en will be positive
and others negative. Thus to give equal weightage to each error, we square
each of these and form their sum, i.e., E e12 e22 en2.
The curve of best fit is that for which e’s are as small as possible, i.e., the
sum of the squares of the errors is a minimum. This is known as the prin-
ciple of least squares and was suggested by a French mathematician Adrien
Marie Legendre in 1806.
E
0 2 x1 [y1 (a bx1 cx12 )] 2 x2 [y2 (a bx2 cx22 )] (2)
b
2 x2 [y5 (a bx5 cx52 )]
E
0 2 x12 [y1 (a bx1 cx12 )] 2 x22 [y2 (a bx2 cx22 )] (3)
b
2 x52 [y5 (a bx5 cx52 )]
Equation (1) simplifies to
y1 y2 y5 5a b( x1 x2 x5 ) c( x12 x22 x52 )
EXAMPLE 5.4
If P is the pull required to lift a load W by means of a pulley block, find
a linear law of the form P mW c connecting P and W, using the follow-
ing data:
P 12 15 21 25
W 50 70 100 120
where P and W are taken in kg-wt. Compute P when W 150 kg.
Solution:
The corresponding normal equations are
P 4c m W
(i)
2
WP c W m W
The values of W etc. are calculated by means of the following table:
W P W2 WP
50 12 2500 600
70 15 4900 1050
100 21 10000 2100
120 25 14400 3000
Total = 340 73 31800 6750
The equations (i) become 73 4c 340m and 6750 340c 31800m
i.e., 2c 170m 365 (ii)
and 34c 3180m 675 (iii)
Multiplying (ii) by 17 and subtracting from (iii), we get m 0.1879
from (ii), c 2.2785
Hence the line of best fit is P 2.2759 0.1879 W
When W 150 kg, P 2.2785 0.1879 × 150 30.4635 kg.
EXAMPLE 5.5
Fit a straight line to the following data:
x 6 7 7 8 8 8 9 9 10
y 5 5 4 5 4 3 4 3 3
EMPIRICAL LAWS AND CURVE-FITTING • 205
Solution:
Let the straight line be y ax b.
Then the normal equations are y ax 9b
xy ax2 bx (i)
The values of x, y etc. are calculated below:
x y xy x2
6 5 30 36
7 5 35 49
7 4 28 16
8 5 40 64
8 4 32 64
8 3 24 64
9 4 36 81
9 3 27 81
10 3 30 100
x 72 y 36 xy 282 x2 588
The equations (i) become 36 72a 9b and 282 588a 72b
i.e., 8a b 4 (ii)
98a 12b 47 (iii)
Multiplying (ii) by 12 and subtracting from (iii), we get a – 0.5.
From (ii), b 8.
Hence the required line of best fit is y – 0.5x 8.
EXAMPLE 5.6
Fit a second degree parabola to the following data:
x 0 1 2 3 4
y 1 1.8 1.3 2. 6.3
Solution:
Let u x – 2 and v y so that the parabola of fit y a bx cx2 becomes
v A Bu Cu2
The normal equations are
v 5 A Bu Cu2 or 12.9 5 A 10C
uv Au Bu2 Cu2 or 11.3 10B
2 2 3 4
u v Au Bu Cu or 33.5 10 A 34C
206 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 5.7
Fit a second degree parabola to the following data:
x 1.0 1.5 2.0 2.5 3.0 3.5 4.0
y 1.1 1.3 1.6 2.0 2.7 3.4 4.1
Solution:
We shift the origin to (2.5, 0) and take 0.5 as the new unit. This amounts
to changing the variable x to X, by the relation X 2x – 5.
Let the parabola of fit be y a bX cX2.
The values of X etc. are calculated as below:
x X y Xy X2 X2y X3 X4
1.0 –3 1.1 –3.3 9 9.9 –27 81
1.5 –2 1.3 –2.6 4 5.2 –8 16
2.0 –1 1.6 –1.6 1 1.6 –1 1
2.5 0 2.0 0.0 0 0.0 0 0
3.0 1 2.7 2.7 1 2.7 1 1
3.5 2 3.4 6.8 4 13.6 8 16
4.0 3 4.1 12.3 9 36.9 27 81
Total 0 16.2 14.3 28 69.9 0 196
The normal equations are
7a 28c 16.2, 28b 14.3, 28a 196c 69.9
Solving these as simultaneous equations, we get
a 2.07, b 0.511, c 0.061.
y 2.07 0.511X 0.061 X2
EMPIRICAL LAWS AND CURVE-FITTING • 207
EXAMPLE 5.8
Fit a second degree parabola to the following data:
x: 1989 1990 1991 1992 1993 1994 1995 1996 1997
y: 352 356 357 358 360 361 361 360 359
Solution:
Taking u x – 1993 and v y – 357, the equation y a bx cx2
becomes
v A Bu Cu2 (i)
x u y v uv u2 u2v u2 u4
x – 1993 y – 357
1989 –4 352 –5 20 16 –80 –64 256
1990 –3 356 –1 3 9 –9 –27 81
1991 –2 357 0 0 4 0 –8 16
1992 –1 358 1 –1 1 1 –1 1
1993 0 360 3 0 0 0 0 0
1994 1 361 4 4 1 4 1 1
1995 2 361 4 8 4 16 8 16
1996 3 360 3 9 9 27 27 81
1997 4 359 2 8 16 32 64 256
Total u 0 v 11 uv 51 u2 60 u2v – 9 u3 0 u4 708
694 17 247
or y 357 ( x 1993) ( x 1993)2
231 20 924
694 33881 247 17 247 3986 247 2
or y (1993)2 x x x
231 20 924 20 924 924
or y 3 – 1694.05 – 1061792.32 357 0.85 x 1065.52 x – 0.267 x2
2
Hence y –1062526.37 1066.37 x – 0.267 x
Exercises 5.2
1. By the method of least squares, find the straight line that best fits the fol-
lowing data:
x: 1 2 3 4 5
y: 14 27 40 55 68
2. In some determinations of the value v of carbon dioxide dissolved in a
given volume of water at different temperatures , the following pairs of
values were obtained:
0 5 10 15
v 1.80 1.45 1.18 1.00
Obtain by the method of least squares, a relation of the form v a b
which best fits to these observations.
3. A simply supported beam carries a concentrated load P(lb) at its mid-
point. Corresponding to various values of P, the maximum deflection Y
(in) is measured. The data are given below:
P: 100 120 140 160 180 200
Y: 0.45 0.55 0.60 0.70 0.80 0.85
Find a law of the form Y a bP.
Fit a straight line to the given data by the method of least squares.
6. Find the parabola of the form y a bx cx2 which fits most closely
with the observations:
x: –3 –2 –1 0 1 2 3
y: 4.63 2.11 0.67 0.09 0.63 2.15 4.58
7. By the method of least squares, fit a parabola of the form
y a bx cx2, to the following data:
x: 2 4 6 8 10
y: 6.07 12.85 31.47 57.38 91.29
Fit a parabola y a bx cx2 to the following data:
x: 1 2 3 4 5 6 7 8 9
y: 2 6 7 8 10 11 11 10 9
8. The velocity V of a liquid is known to vary with temperature T according
to a quadratic law V a b T CT2. Find the best values of a, b, c for
the following table:
T: 1 2 3 4 5 6 7
V: 2.31 2.01 3.80 1.66 1.55 1.46 1.41
9. The following table gives the results of the measurements of train resis-
tance, V is the velocity in miles per hour, R is the resistance in pounds
per ton:
V: 20 40 60 80 100 120
R: 5.5 9.1 14.9 22.8 33.3 46.0
If R is related to V by the relation R a bV cV , find a, b and c. 2
(1) y a bx2
Putting x2 X, we have y a bX (i)
which is a linear equation. Its normal equations are
y na bX; yX aX bX2
Solving these, we get a and b. Substituting these values of a, b and re-
placing X by x2 in (i), we obtain the desired equation of best fit.
(2) y ax bx2
Rewriting this equation as y/x a bx and putting y/x Y, we have
Y a bx (i)
Its normal equations are
Y na bx; Yx ax bx2
Solving these we get a and b. Replacing Y by y/x in (i), we obtain the
desired equation of best fit.
(3) y ax b/x
Rewriting this equation as xy ax2 b
and putting x2 X and xy Y, we have Y b aX (i)
Its normal equations are
Y nb X; XY bX aX2
Solving these equations, we get a and b. Replacing X by x2 and Y by xy
in (i), we obtain the desired equation of best fit.
(4) y ax2 b/x
Rewriting this equation as xy ax3 b and putting x3 X and xy Y,
we have
Y b aX (i)
Its normal equations are
Y bn aX; XY bX X2
Solving these equations, we get a and b. Replacing X by x3 and Y by xy,
we obtain the desired equation of best fit.
EMPIRICAL LAWS AND CURVE-FITTING • 211
EXAMPLE 5.9
Find the least squares fit of the form y a0 a1x2 to the following data
x: –1 0 1 2
y: 2 5 3 0
Solution:
Putting x2 X, we have y a0 a1X (i)
The normal equations are
y 4a a1X; Xy a0X a1X2.
The values of X, X2 etc. are calculated below:
X y X X2 XY
–1 2 1 1 2
0 5 0 0 0
1 3 1 1 3
2 0 4 16 0
y 10 X 6 X2 18 XY 5
The normal equations become 10 400 6a1; 5 600 18a1
Solving these equations we get, a0 4.167, a1 – 1.111.
Hence the curve of best fit is
y 4.167 – 1.111X i.e., y 4.167 – 1.111x2.
EXAMPLE 5.10
Using the method of least squares, fit the curve y ax2 b/x to the fol-
lowing data:
x: 1 2 3 4
y: –1.51 0.99 8.88 7.66
Solution:
Rewriting the given equation as xy ax3 b and putting x3 X and
xy Y, we get
Y aX b (i)
The normal equations are
Y aX 4b; XY aX2 bX
212 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
or
EXAMPLE 5.11
An experiment gave the following values:
v (ft/min): 350 400 50 600
t (min): 61 26 7 2.6
It is known that v and t are connected by the relation v atb. Find the
best possible values of a and b.
Solution:
We have log10 v log10 a b log10 t
or Y A bX where X log10t, Y log10 v, A log10 a.
The normal equations are
Y 4A bX (i)
XY AX bX2 (ii)
Now X etc. are calculated as in the following table:
v t X log10t Y log10v XY X2
350 61 1.7853 2.5441 4.542 3.187
400 26 1.4150 2.6021 3.682 2.002
500 7 0.8451 2.6990 2.281 0.714
600 2.6 0.4150 2.7782 1.153 0.172
Total 4.4604 10.6234 11.658 6.075
Equations (i) and (ii) become
4A 4.46b 10.623; 4.46A 6.075b 11.658
Solving these, A 2.845, b – 0.1697
a antilog A antilog 2.845 699.8.
214 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
EXAMPLE 5.12
Predict the mean radiation dose at an altitude of 3000 feet by fitting an
exponential curve to the given data:
Altitude (x): 50 450 780 1200 4400 4800 5300
Dose of radiation (y): 28 30 32 36 51 58 69
Solution:
Let y abx be the exponential curve.
Then log10y log10a x log10b
or Y A Bx where Y log10 y, A log10 a, B log10 b
The normal equations are
Y 7A B x (i)
x Y Ax B x2 (ii)
Now x etc., are calculated as follows:
x Y Y log10 y xY x2
50 28 1.447158 72.3579 2500
450 30 1.477121 664.7044 202500
780 32 1.505150 1174.0170 608400
1200 36 1.556303 1867.5636 1440000
4400 51 1.707570 7513.3080 19360000
4800 58 1.763428 8464.4544 23040000
5300 69 1.838849 9745.8997 28090000
16980 11.295579 29502.305 72743400
EXAMPLE 5.13
Fit a curve of the form y aebx to the following data:
x: 0 1 2 3
y: 1.05 2.10 3.85 8.30
Solution:
Taking logarithms of both sides, the given equation becomes
log10 y log10 a bx log10 e
i.e., Y A bx where Y log10 y, A log10 a, B b log10 e
The normal equations are
Y 4A Bx; xY Ax Bx2.
Now x, Y etc. are calculated as in the table below:
x Y Y x2 xY
0 1.05 0.0212 0 0
1 2.10 0.3222 1 0.3222
2 3.85 0.5855 4 1.1710
3 8.30 0.9191 9 2.7573
x 6 Y 1.8480 x 14
2
xY 4.2505
EXAMPLE 5.14
The pressure and volume of a gas are related by the equation pV k,
and k being constants. Fit this equation to the following set of observa-
tions:
p (kg/cm2): 0.5 1.0 1.5 2.0 2.5 3.0
V (litres): 1.62 1.00 0.75 0.62 0.52 0.46
216 • NUMERICAL METHODS IN ENGINEERING AND SCIENCE
Solution:
We have log10 p log10 V log10 k
1 1
or log10 V log10 k log10 P
1 1
or Y A BX where X log10 P, Y log10 V , A log10 k, B
The normal equations are
Y 6A BX (i)
XY AX BX 2
(ii)
Now X etc. are calculated as follows:
p V X log10 p Y log10 V XY X2
0.5 1.62 –0.3010 0.2095 –0.0630 0.0906
1.0 1.00 0.0000 0.0000 –0.0000 0.0000
1.5 0.75 0.1761 –0.1249 –0.0220 0.0310
2.0 0.62 0.3010 –0.2076 –0.0625 0.0906
2.5 0.52 0.3979 –0.2840 –0.1130 0.1583
3.0 0.46 0.4771 –0.3372 –0.1609 0.2276
Total 1.0511 – 0.7442 – 0.4214 0.5981
Equations (i) and (ii) become
6A 1.0511B – 0.7442; 1.0511A 0.5981B – 0.4214
Solving these, we get A 0.0132, B – 0.7836.
– 1/B 1.276
and k antilog (A) antilog (0.0168) 1.039.
Hence the equation of best fit is pV1.276 1.039.
Exercises 5.3
10. Growth of bacteria (N) in a culture after t hrs. is given in the following
table:
t: 0 1 2 3 4 5 6
N: 32 47 65 92 132 190 275
Fit a curve of the form N abt and estimate N when t 7.
11. The voltage v across a capacitor at time t seconds is given by the follow-
ing table:
t: 0 2 4 6 8
v: 15 0 63 28 12 5.6
Use the method of least squares to fit a curve of the form v aekt to this
data.
12. Obtain the least square fit of the form f(t) ae–3t be–2t for the data:
x: 0.1 0.2 0.3 0.4
f(t): 0.76 0.58 0.44 0.35
13. Find the most plausible values of x and y from the equations x 3y
7.03, x y 3.01, 2x – y 0.03, 3x y 4.97, by forming the normal
equations.
14. Obtain the most plausible values of x, y and z from the equations:
x 2y z 1, – x y 2z 3, 2x y z 4, 4x 2y – 5z – 7
Pn(xn, yn)
Y P2(x2, y2)
Mn
P1(x1, y1) M3
+ bx M2 P3(x3, y3)
y=a M1
0
L1 L2 L3 Ln X
FIGURE 5.5