Professional Documents
Culture Documents
VENKATESAN
CURVE FITTING
In many branches of Applied Mathematics, Engineering and Sciences we come across experiments
and problems which involve two variables. Let ( xi , yi ) : i 1, 2, , n be n sets of numerical values
of two variables x (independent) and y (dependent). If we plot these n sets on the graph we get a
diagram, which is called the scatter diagram. In the scatter diagram, a smooth curve can be drawn
to pass through near the plotted points. Such a curve is called an approximating curve. The equation
of this curve may be taken as an approximate relation between x and y and it is called empirical
law. The general problem of finding exact equations of approximating curves which fit given data
is called curve fitting.
For example it is known that the speed v of a ship varies with the horse power p of an engine
according to the formula p a b v 3 . For this purpose we take several sets of readings of speeds
and the corresponding horse powers. The problem is to find the best values for a and b using the
observed values of v and p. Thus the general problem is to find a suitable relation or law that may
exist between the two variables from a given set of observed paired values. Such a relation
connecting the two variables is known as empirical law.
The process of finding the equation of the curve of best fit which may be most suitable for
predicting the unknown values is known as curve fitting.
Linear Law:
Suppose the relationship between the variables x and y is linear, and of the form y a x b . Thus
the curve to be fitted for the given data is a straight line. In simple cases a straight line may be fitted
by eye. But if the points are scattered then it becomes unreliable. Hence we use some mathematical
principles to determine the values of a and b. But it must be noted that sometimes the given data
may not follow a liner law. In such cases it may be possible to find some other nonlinear law which
can be reduced to linear law by suitable transformation.
The following EXAMPLES are some laws which are reducible to Linear Law.
1) y a x n b
2) y a x b
3) y a eb x
Putting Y log10 y , X x then the equation takes the linear form Y A X B where
A b log10 e , B log10 a .
4) x y n a
1
log10 x n log10 y log10 a that is, log10 y log10 a log10 x .
n
Putting Y log10 y , X log10 x then the equation takes the linear form Y A X B
1 1
where A and B log10 a .
n n
EXERCISE – 1.1
Convert the following equations into linear form
x a xb
(a) y ; (b) y ; (c) y a b x y ;
abx x
b
(d) y ; (e) x y a x b ; (f) y a x b x 2 ;
x ( x a)
(g) x a y b ; (h) y a b x .
Y
Pi
P1 P4 Li
L2 L3
y = f(x) L4
L1
P2 P3
O(0 , 0)
M1 M2 M3 M4 Mi
Fig: 1.1
It is obvious that some of ei ' s may be ve or ve . Thus by giving equal weightage to each
n n
residuals, consider E ei2 [ yi f ( xi ) ]2 (1.2 )
i 1 i 1
Now, if E 0 then yi f ( xi ) i ; that is, all the points lie on the curve.
Otherwise the minimum of E results the best fitting curve to the data.
The Principle of Least Squares states that the sum of the squares of the residuals is minimum.
This principle does not suggest to determine the form of the curve y f ( x) but it determine the
values of the parameters or constants of the equation of the curve.
E E
have to determine the parameters a and b so that E is minimum i.e., 0 and 0 .
a b
E
0 2 ( yi a xi b ) xi 0 ( yi xi a xi2 b xi ) 0
a
yi xi a xi2 b xi (1.4 )
E
0 2 ( yi a xi b ) 0 yi a xi nb (1.5)
b
Since xi , yi are known, equations (1.4) and (1.5) results two equations in a and b. Solving
these, the best values for a and b can be known and hence equation (1.3) straight line.
The equations (1.4) and (1.5) are called Normal equations to the straight line (1.3).
Note to obtain the normal equations: y a x b is the straight line and its normal
E E E
a , b , c by Principles of Least Squares i.e., 0, 0 and 0 .
a b c
E
0 2 ( yi a xi2 b xi c ) xi 0 ( yi xi a xi3 b xi2 c xi ) 0
b
E
0 2 ( yi a xi2 b xi c ) 0 yi a xi2 b xi n c (1.9 )
c
Equations (1.7), (1.8) and (1.9) are called Normal equations of the parabola (1.6).
Solving these normal equations we get the best values of a , b , c and hence best fit of
equation (1.6).
both sides we get y a x2 b x nc . In the second degree parabola multiply by x both
sides and then take on both sides we get xy a x 3 b x 2 c x . Again in the second
degree parabola multiply by x 2 both sides and then take on both sides we get
By using the Principle of Least Squares, the Normal equations for (1.11) are
Curves of the form, equation (1.14), equation (1.15) or any other form, can be brought to
linear form by suitable transformation of variables. { Refer equations converting into linear
law }. Then using the Principle of Least Squares the curve of best fit can be achieved.
----------------------------------------------------------------------------------------------------------- -------
Calculation of the sum of the squares of the residuals in the case of Straight line fit:
In fitting a straight line, we know that the sum of the squares of the residuals E is given by
E [ y (a x b ) ]2 [ y (a x b )][ y (a x b )]
y [ y (a x b )] a x [ y (a x b )] b [ y (a x b )]
y [ y (a x b )] a x [ y (a x b )] b [ y (a x b )] y [ y (a x b )] a (0) b (0)
Since the last two sums vanish due to normal equations of the straight line.
Therefore, E y 2 a xy b y . When we fit a straight line by the method of least squares, the
Calculation of the sum of the squares of the residuals in the case of Parabola fit:
In fitting a parabola, we know that the sum of the squares of the residuals E is given by
E [ y (a x 2 b x c) ]2 [ y (a x 2 b x c) ][ y (a x 2 b x c) ]
y[ y (ax 2 bx c)] ax 2 [ y (ax 2 bx c)] bx[ y (ax 2 bx c)] c[ y (ax 2 bx c)]
Problem 1: By the Method of Least Squares, find the straight line that best fit the following data:
x 1 2 3 4 5
y 14 27 40 55 68
y a x nb ( ii ) and x y a x2 b x ( iii )
y 13.6 x
Problem 2: Fit a second degree Parabola by taking x as the independent variable in Least Square
sense to the given data:
x 0 1 2 3 4
y 1 5 10 22 38
Solution: Let the second degree Parabola to be fitted to the given data be y a x2 b x c (i )
Here n 5 . The Normal equations of the Parabola ( i ) to find a , b , c are given by
x 2 y a x 4 b x3 c x 2 ( iv )
Problem 3: Fit the curve of best fit of the type y a eb x to the following data by the Method of
Least Squares:
x 1 5 7 9 12
y 10 15 12 15 21
Solution: Let the Exponential equation to be fitted for the given data be y a eb x (i )
Taking common logarithms { log10 } on both sides of equation (i),
Y A X n B ( iii ) and X Y A X 2 B X ( iv ) .
NUMERICAL ANALYSIS – CURVE FITTING Page 8 of 12
COLLEGE OF SCIENCE AND TECHNOLOGY, R.U.B, P/LING:: BHUTAN S.T.VENKATESAN
The parameters A and B are got from the Normal equations.
A
Hence, a anti log10 ( B ) and b A log e 10 . Here n 5 .
log10 e
Substituting the table values in the Normal equations (iii) and (iv), we get
5.75358 34 A 5 B ( v ) and 40.88616 300 A 34 B ( vi )
On solving (v) and (vi) A 0.02561 ; B 0.97658 .
A
Therefore, a anti log10 ( B ) 9.47502 and b A log e 10 0.05897 .
log10 e
Problem 4: Obtain a relation of the form y a . b x for the following data by the Method of Least
Squares:
x 2 3 4 5 6
y 8.3 15.4 33.1 65.2 127.4
Y A X n B ( iii ) and X Y A X 2 B X ( iv ) .
Substituting the value of X , Y , X 2 and X Y from the above table in the Normal equations
(iii) and (iv), we get 7.54585 20 A 5 B ( v ) and 33.18231 90 A 20 B ( vi )
On solving (v) and (vi) A 0.29989 ; B 0.30961 .
-------------------------------------------------------------------------------------------------------------------
EXERCISE – 1.2
1) 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. Find a law of the type Y a b P .
2) 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 data:
P 12 15 21 25
W 50 70 100 120
where P and W are taken in kg – wt.
4) The pressure of the gas corresponding to various volumes V is measured, given by the
following data:
V (cm 3 ) 50 60 70 90 100
P (kg / cm 2 ) 64.7 51.3 40.5 25.9 78
a
5) Use the method of Least Squares to fit the curve: y b x to the following table of
x
values:
6) The voltage V across a capacitor at time t seconds is given by the following table. Use the
Principle of Least Squares to fit a curve of the form V a e k t to the data:
t 0 2 4 6 8
V 150 63 28 12 5.6
7) Find the second degree Parabola which fits most closely with observations:
x -3 -2 -1 0 1 2 3
y 4.63 2.11 0.67 0.09 0.63 2.15 4.58
8) By proper transformation, convert the relation y a b x y to a linear form and find the
equation to fit the data:
x -4 1 2 3
y 4 6 10 8
9) Fit a straight line and a parabola to the following data and find out which one is most
appropriate. Reason out for your conclusion.
x 0 1 2 3 4
y 1 1.8 1.3 2.5 6.3
11) Say True or False: (i) In fitting the best fitting Straight line, the line must pass through
two paired data. (ii) You are given ( xi , yi ), i 1, , n and a Parabola is fitted to them. It is