Curve fitting, Various methods of Curve fitting, Straight Line fit, Parabola fit, Fitting of other curve
Size: 138.19 KB
Language: en
Added: Feb 10, 2016
Slides: 5 pages
Slide Content
Atmiya Institute of Technology & Science – General Department Page 1
B.E. Sem-IV
Sub: NUMERICAL AND STATISTICAL METHODS FOR COMPUTER ENGINEERING
(2140706)
Topic: Curve fitting
I Introduction
All engineering experiments land into collection of data which has discrete values. This section deals with
techniques to fit curves to such data in order to obtain intermediate estimates.
The simplest method for fitting a curve to data is to plot the points and then sketch a line that visually
conforms to the data. But this approach results into different results as illustrated in below figure.
In many engineering and science applications, it is required to express the data, obtained from various
observations and experiments in the form of a low. The low gives mathematical relation between the two
variables and is called as Empirical law.
e.g. if the temperature of the body increases, as the time increases so for various values of time, the
difference temperature is measured. If we want to know the effect of time on temperature of body, then we
write a mathematical relationship between them as t
n time (sec) and T n Temperature (◦C). The variable t is
independent variable and T is dependent variable. The relationship between them is either linear or non-
linear.
The process of finding such a relation or equation of ‘best fit’ is called as curve fitting.
Curve Fitting
Atmiya Institute of Technology & Science – General Department Page 2
I Applications for Curve fitting
Is a straight line suitable for each of these cases ?
No. But we’re not stuck with just straight line fits. We’ll start with straight lines, then expand the concept.
Curve fitting - capturing the trend in the data by assigning a single function across the entire range.
I Various methods of Curve fitting
If there are different values of x and the various corresponding values of y, then a mathematical relationship
y=f(x) between these two variable can be obtained by
1. Graphical method
2. Method of group averages
3. Method of moments
4. Method of least squares
Curve Fitting
Atmiya Institute of Technology & Science – General Department Page 3
∑ Fitting of Simple curves using methods of Least Square
The least square technique is applied in such a way that it represents the curve of best fit. It represents best
possible constants in the equation. To fit the given data, the data available is having the following relations.
1. Linear
2. Quadratic
3. Power
4. Exponential
∑ Straight Line fit (Linear regression):
The equation of line y= ax + b
Normal equations:
2
a x bn y
a x b x xy
+ =
+ =
∑ ∑
∑ ∑ ∑
Solving the above equations simultaneously we get the values of a and b then we can write the relation
between y and x as the line of equation y= ax + b.
Using Cramer’s rule the value of a and b can be obtained as follows:
2
x n
x x
∑
D =
∑ ∑
y n
a
xy x
∑
D =
∑ ∑
2
x y
b
x xy
∑ ∑
D =
∑ ∑
b
b
D
=
D
a
a
D
=
D
Ex. Fit a straight line to the following data:
x 1 2 3 4 5 6 8
y 0.5 2.5 2 4 3.5 6 5.5
Ans.: a=0.7333, b=0.384
Ex. 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 following data:
P=12 15 21 25
W=50 70 100 120
Where P and W are taken in kg-wt. compute P when W=150kg.
Ans. M=0.1879, c= 2.2785, P=30.4635
Ex. Fit the straight line for the data given below:
X 100 120 140 160 180 200
Y 0.45 0.55 0.60 0.70 0.80 0.85
Ans. Y=0.004x+0.0476
Curve Fitting
Atmiya Institute of Technology & Science – General Department Page 4
∑ Parabola fit :
The equation of line y= ax
2
+ bx +c
Normal equations:
2
3 2
4 3 2 2
a x b x cn y
a x b x c x xy
a x b x c x x y
+ + =
+ + =
+ + =
∑ ∑ ∑
∑ ∑ ∑ ∑
∑ ∑ ∑ ∑
Solving the above equations simultaneously we get the values of a, b and c then we can write the relation
between y and x as the line of equation y= ax
2
+ bx +c.
Using Cramer’s rule the value of a, b and c can be obtained as follows:
2
3 2
4 3 2
x x n
x x x
x x x
∑ ∑
D =∑ ∑ ∑
∑ ∑ ∑
2
2 3 2
y x n
a xy x x
x y x x
∑ ∑
D =∑ ∑ ∑
∑ ∑ ∑
2
3
4 2 2
x y n
b x xy x
x x y x
∑ ∑
D =∑ ∑ ∑
∑ ∑ ∑
2
3 2
4 3 2
x x y
c x x xy
x x x y
∑ ∑ ∑
D =∑ ∑ ∑
∑ ∑ ∑
,
a
a
D
=
D
,
b
b
D
=
D
c
c
D
=
D
Ex. Fit a second degree parabola to the following data:
x 0 1 2 3 4
y 1 1.8 1.3 2.5 6.3
Ans.: a=0.55, b=-1.07, c=1.42
Ex. Fit a second degree parabola to the following data:
x 1 1.5 2 2.5 3 3.5 4
y 1.1 1.3 1.6 2 2.7 3.4 4.1
Ans.: a = 0.244, b = -0.198 , c=1.04
Ex. 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
Ans.: a = 0.244, b = -0.198 , c=1.04
Curve Fitting
Atmiya Institute of Technology & Science – General Department Page 5
∑ Fitting of other curve:
(1) y= ax
b
Taking logarithms,
10 10 10
log log logy a b x= +
i.e. Y A bX= + where
10
logX x= ,
10
logY y= and
10
logA a=
Therefore the normal equations are: Y nA b X= +∑ ∑ ,
2
XY A X b X= +∑ ∑ ∑
From which A and b can be determined. Then a can be calculated from
10
log
A a= .
Ex. An experiment gave the following values:
V(ft/min) 350 400 500 600
t(min) 61 26 7 2.6
It is known that v and t are connected by the relation v= at
b
. Find the best possible values of a and b.
Ans.: A=2.845, b = -0.1697, a=699.8
(2) y= ae
bx
Taking logarithms,
10 10 10
log log logy a bx e= +
i.e. Y A Bx= + where
10
logY y= ,
10
logA a= and
10
logB b e=
Therefore the normal equations are: Y nA B x= +∑ ∑ ,
2
xY A x B x= +∑ ∑ ∑
From which A and B can be found and consequently, a, b can be calculated.
Ex. Fit a curve of the form y= ae
bx
to the following data: x 0 1 2 3
y 1.05 2.10 3.85 8.30
Ans.: A=0.0185, B = 0.2956, a=1.0186, b=0.6806