Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

7.

1 Introduction
Very often, the students of Engineering and Science are required to obtain data involving two variables, say, 𝑥 and 𝑦 (𝑦
dependent on 𝑥) from experimental observations. The data obtained is required to be expressed in the form of a law
connecting the two variables 𝑥 and 𝑦. In such cases, the corresponding values (𝑥𝑖 , 𝑦𝑖 ) of the given data are plotted on a
graph paper and a smooth curve is drawn passing through the plotted points. Such a curve is called an approximating
curve. Its equation, say, 𝑦 = 𝑓(𝑥) is known as an empirical equation. Since it is possible to draw a number of such curves
through or near the points, different empirical equations can be obtained to express the data. Now the problem is to find
the equation of the curve which is best suited to predicting the unknown values. The process of finding such an equation
of the “best fit” is known as curve fitting.

7.2 Curve fitting


Curve fitting is the process of constructing a curve (named as an approximating curve) or mathematical function that has
the best fit to a given set of data points, possibly subject to constraints. In this case the curve drawn is such that the
discrepancy between the data points and the curve is least. The method of least squares is most commonly used in fitting
curve.

Or

Curve Fitting is most often used by scientists and engineers to visualize and plot the curve that best describes the shape &
behavior of their data. Curve fitting is the procedure in finding a curve which matches a series of data points and possibly
other constraints.

Or

A procedure in which the basic problem is to pass a curve through a set of points, representing experimental data, in such
a way that the curve shows as well as possible the relationship between the two quantities plotted. It is always possible to
pass some smooth curve through all the points plotted, but since there is assumed to be some experimental error present,
such a procedure would ordinarily not be desirable.

Fig 7.1: Linear curve fitting Fig 7.2: Non-linear curve fitting
The method curve fitting was suggested early in the 19th century by the French mathematician Adrien Legendre.

7.3 Least Squares Method for Linear Equation


If the equation of line is, y  ax  b then the normal equations are,

a  x 2  b x   xy

And

a  x  bn   y

7.4 Least Squares Method for Non-Linear Equation


Let, the general second degree polynomial equation is, 𝑦 = 𝑎𝑥 2 + 𝑏𝑥 + 𝑐
Be a parabola to be fitted for the data (𝑥𝑖 , 𝑦𝑖 ), 𝑖 = 1,2,3, … … … … , 𝑛. For solving this type of problem, we use this normal
equations,
𝑎∑𝑥 4 + 𝑏∑𝑥 3 + 𝑐∑𝑥 2 = ∑𝑥 2 𝑦

𝑎∑𝑥 3 + 𝑏∑𝑥 2 + 𝑐∑𝑥 = ∑𝑥𝑦

𝑎∑𝑥 2 + 𝑏∑𝑥 + 𝑐𝑛 = ∑𝑦

7.5 Mathematical Problem (Linear type problem)


Problem 01: Use the method of least squares to fit a straight line to the following data:

𝑥 0 5 10 15 20
𝑦 7 11 16 20 26

Also comment on the best fit of given data.


Solution:
Assume that the least square straight line to be fitted to the given data be y  ax  b .
Then we have the normal equations are,
a  x 2  b x   xy  (i )
and
a  x  bn   y  (ii )
Here the number of data points n= 5.
Now for finding the coefficients 𝑎 and 𝑏 of the least square line we will use following table,

𝑥 0 5 10 15 20 ∑𝑥 = 50
𝑦 7 11 16 20 26 ∑𝑦 = 80
𝑥𝑦 0 55 160 300 520 ∑𝑥𝑦 = 1035
2
𝑥 0 25 100 225 400 ∑𝑥 2 = 750
Now putting these values in the above equations (i) and (ii) we get

750a  50b  1035 and 50a  5b  80


Solving above two equations by calculator, we get values of a  0.94 and b  6.6 .

Putting these values in the equation y  ax  b we get the required line as y  0.94 x  6.6 .

Now if we put the given data in graph paper and draw the line y  0.94 x  6.6 on the graph then we get,

y  0.94 x  6.6

Comment: From the above graph we may say that (𝟏𝟎, 𝟏𝟔) point gives the best fit.

Problem 02: Find the least square line y  ax  b for the data points  1,10 , 0,9  , 1,7 , 2,5 , 3,4  , 4,3
5,0 and 6,1 .
Solution:
Given that least square straight is y  ax  b and number of data points n= 8.
Then we have the normal equations are
a  x 2  b x   xy  (i )
and
a  x  bn   y  (ii )
Calculation for finding the coefficients 𝑎 and 𝑏 of the least square line.

𝑥 −1 0 1 2 3 4 5 6 ∑𝑥 = 20
𝑦 10 9 7 5 4 3 0 −1 ∑𝑦 = 37
𝑥𝑦 −10 0 7 10 12 12 0 −6 ∑𝑥𝑦 = 25
𝑥2 1 0 1 4 9 16 25 36 ∑𝑥 2 = 92

Now putting these values in the above equations (i) and (ii) we get
92a  20b  25 and 20a  8b  37
Solving above two equations by calculator, we get values of a  1.60714 and b  8.64286 .
Putting these values in the equation y  ax  b we get the required line as y  1.60714x  8.64286 .
Now if we put the given data in graph paper and draw the line y  1.60714x  8.64286 on the graph then we get,

Comment: From the above graph we may say that (𝟏, 𝟕) and (𝟔, −𝟏) both points gives the best fit.

7.5.1 Exercise

Q1. Find the least square line y  ax  b for the data


x -2 -1 0 1 2
y 1 2 3 3 4

Q2. Find the values of a 0 and a1 so that y  a0  a1 x fits the data given in the table:
x 0 1 2 3 4
y 1 2.9 4.8 6.7 8.6

Q3. Fit a straight line of the form y  a0  a1 x to the data:


x 1 2 3 4 6 8
y 2.4 3.1 3.5 4.2 5 6

Q4. The table below gives the temperature T (in 00C) and length l (in mm) of a heated rod. If l  a 0  a1T
find the values of a 0 and a1 using linear least squares
T 40 50 60 70 80
l 600.5 600.6 600.8 600.9 601

Q5. Fit a straight line to the following data regarding x as the independent variable

x 0 1 2 3 4
y 1 1.8 3.3 4.5 6.3
Q6. Find the least square fit straight line of the form y  ax  b for the data of fertilize application and yield
of a plant
fertilizer 0 10 20 30 40 50
Yield (kg) 0.8 0.8 1.3 1.6 1.7 1.8

7.6 Mathematical Problem (Non-linear type problem)


Problem 01: Use the method of least squares to fit a parabola to the following data:

𝑥 10 12 15 23 20
𝑦 14 17 23 25 21

Also comment on the best fit of given data.

Solution:
Assume that the curve to be fitted to the given data be y  ax 2  bx  c .
Then the normal equations for the curve is,
𝑎∑𝑥 4 + 𝑏∑𝑥 3 + 𝑐∑𝑥 2 = ∑𝑥 2 𝑦 ………………… (1)
𝑎∑𝑥 3 + 𝑏∑𝑥 2 + 𝑐∑𝑥 = ∑𝑥𝑦 ………………… (2)
2
𝑎∑𝑥 + 𝑏∑𝑥 + 𝑐𝑛 = ∑𝑦 …………………. (3)
Here the number of data points n= 5.
Now for finding the coefficients 𝑎, 𝑏 and 𝑐 of the curve we use following table.

𝑥 10 12 15 23 20 ∑𝑥 = 80
𝑦 14 17 23 25 21 ∑𝑦 = 100
𝑥2 100 144 225 529 400 ∑𝑥 2 = 1398
𝑥3 1000 1728 3375 12167 8000 ∑𝑥 3 = 26270
𝑥4 10000 20736 50625 279841 160000 ∑𝑥 4 = 521202
𝑥2𝑦 1400 2448 5175 13225 8400 ∑𝑥 2 𝑦 = 30648
𝑥𝑦 140 204 345 575 420 ∑𝑥𝑦 = 1684

Now putting these values in the above equations (1), (2) and (3) we get

521202𝑎 + 26270𝑏 + 1398𝑐 = 30648

26270𝑎 + 1398𝑏 + 80𝑐 = 1684 ……………… (4)

1398𝑎 + 80𝑏 + 5𝑐 = 100

Solve the equation (4), we get values of a  0.07 , b  3.03 and 𝑐 = −8.89.

Putting these values in the equation y  ax 2  bx  c we get the required curve as y  0.07 x 2  3.03x  8.89 .

Now if we put the given data in graph paper and draw the curve y  0.07 x 2  3.03x  8.89 on the graph then we get,
Comment: From the graph we may say that (𝟏𝟎, 𝟏𝟒) point gives the best fit.

Problem 02: Fit a second degree parabola to the following data using the least square method,

𝑥 0 1 2 3 4
𝑦 1 1.8 1.3 2.5 6.3

Solution:
Assume that the second degree parabola is, y  ax 2  bx  c .
Then the normal equations for the curve is,
𝑎∑𝑥 4 + 𝑏∑𝑥 3 + 𝑐∑𝑥 2 = ∑𝑥 2 𝑦 ………………… (1)
𝑎∑𝑥 3 + 𝑏∑𝑥 2 + 𝑐∑𝑥 = ∑𝑥𝑦 ………………… (2)
𝑎∑𝑥 2 + 𝑏∑𝑥 + 𝑐𝑛 = ∑𝑦 …………………. (3)
Here the number of data points n= 5.
Now for finding the coefficients 𝑎, 𝑏 and 𝑐 of the curve we use following table.

𝑥 0 1 2 3 4 ∑𝑥 = 10
𝑦 1 1.8 1.3 2.5 6.3 ∑𝑦 = 12.9
2
𝑥 0 1 4 9 16 ∑𝑥 2 = 30
𝑥3 0 1 8 27 64 ∑𝑥 3 = 100
𝑥4 0 1 16 81 256 ∑𝑥 4 = 354
𝑥2𝑦 0 1.8 5.2 22.5 100.8 ∑𝑥 2 𝑦 = 130.3
𝑥𝑦 0 1.8 2.6 7.5 25.2 ∑𝑥𝑦 = 37.1

Now putting these values in the above equations (1), (2) and (3) we get

354𝑎 + 100𝑏 + 30𝑐 = 130.3

100𝑎 + 30𝑏 + 10𝑐 = 37.1 ……………… (4)

30𝑎 + 10𝑏 + 5𝑐 = 12.9

Solve the equation (4), we get values of a  0.55 , b  1.07 and 𝑐 = 1.42 .
Putting these values in the equation y  ax 2  bx  c we get the required curve as y  0.55x 2  1.07 x  1.42 .

Now if we put the given data in graph paper and draw the curve y  0.07 x 2  3.03x  8.89 on the graph then we get,

Comment: From the graph we may say that (𝟏𝟎, 𝟏𝟒) point gives the best fit.

7.6.1 Exercise

Q1. Fit a parabola to the following data using the least square method,
𝑥 1 2 3 4 5 6
𝑦 4 8 10 12 16 20

Q2. By using method of least square fit a parabola to the following data,
𝑥 1 2 3 4
𝑦 0.30 0.64 1.32 5.40

Q3. Find the parabola of the form 𝑦 = 𝑎 + 𝑏𝑥 + 𝑐𝑥 2 which fits most closely with the following observations
by the method of least squares.
𝑥 −3 −2 −1 0 1 2 3
𝑦 4.63 2.11 0.67 0.09 0.63 2.15 4.58

Answer:

Q1. y  0.011x 2  3.0255x  1.254 .

Q2. y  0.6567 x 2  1.7856x  1.399 .

Q3. y  1.243  0.004x  0.22x 2 .

You might also like