WOLDIA UNIVERSITY
INSTITUTE OF TECHNOLOGY
School of Mechanical and Chemical Engineering
Department of Mechanical Engineering
Numerical Methods
Chapter Three
Curve Fitting
Curve Fitting
• Curve Fitting is a process of finding equations of
approximating curves which best fit the given set of data.
Fig 3.1 Linear and Non Linear relationship
Least Square Regression
Linear Regression Analysis
• A regression model is a mathematical equation that
describes the relationship between two or more
variables.
• A single regression model includes only two variables:
one independent and one dependent.
• The relationship between two variables in a regression
analysis is expressed by a mathematical equation called a
regression equation or model.
• regression equation that gives a straight-line relationship
between two variables is called a linear regression model;
otherwise, it is called a non-linear regression model.
Cont …
Figures 3.2(a) and (b) show a linear and a non-linear
relationship between independent variable and the
dependent variable.
Fig. 3.2: (a) Linear relationship, (b) Non-linear relationship
Cont…
• The
equation of a linear relationship between two
variables x and y is written as
……………………….…..(3.1)
where a gives the y-intercept and b represents the slope of
the line.
• In regression model, x is the independent variable and y
is the dependent variable. The simple linear regression
model for population is written as
…………………………..(3.2)
Equation (3.2) is called a deterministic model. It gives an
exact relationship between x and y.
Cont…
•
However, in many instances the relationship between the
variables is not exact. Therefore, the complete regression model
is then written as
………………………….(3.3)
where ∈ is called the random error term. This regression model
(Eq. 3.3) is called a probabilistic model (or a statistical
relationship). The random error term ∈ is included in the model
to take into consideration of the following two phenomena:
1. Missing or omitted variables: The random error term ∈
is included to capture the effect of all the missing or
omitted variables that were not included in the model.
2. Random variation: The random error term ∈ is included
to capture the random variation.
Cont…
• A
and B are the population parameters. The values of A
and B is the population regression line and is called the
true values of the y-intercept and slope.
• However, most often the population data is difficult to
obtain. As a consequence, we almost always use the
sample data and use the model given by Eq. (3.3). The
values of the y-intercept and slope calculated from sample
data on x and y are called the estimated values of A and B
and are denoted by a and b.
• The estimated regression model is then written as
…………………………………………...(3.4)
Where is the estimated or predicted value of y for a given
value of x.
Cont…
• A plot of paired observation is called a scatter diagram
as shown in Fig. 3.3.
Fig. 3.3: Scatter diagram
Cont…
• To
find the line that best fits the scatter of points, we
minimise the error sum of squares, denoted by SSE,
which is given by
…………..…………(3.4)
where
The least squares method gives the values of a and b such
that the sum of squared errors (SSE) is minimum.
For the least squares regression line ˆy = a + bx, we have
Cont…
•Where
…………………(3.5)
/n
The least squares regression line ˆy = a + bx is also called the
regression of y on x.
Example 1
• Table 1 gives experimental data for force (N) and velocity
(m/s) for an object suspended in a wind tunnel.
Table E6.1
Velocity (m/s) 10 20 30 40 50 60 70 80
Force (N) 24 68 378 552 608 1218 831 1452
A. use the linear least-squares regression to determine the
coefficients a and b in the function ˆy = a + bx that best
fits the data
B. estimate the force when the velocity is 55 m/s.
Cont…
Solution:
Here n = 8
y
1
1 10
10 24
24 100
100 240
240
2
2 20
20 68
68 400
400 1360
1360
3 30 378 900 11340
3 30 378 900 11340
4 40 552 1600 22080
4
5 40
50 552
608 1600
2500 22080
30400
5
6 50
60 608
1218 2500
3600 30400
73080
6
7 60
70 1218
831 3600
4900 73080
58170
8
7 80
70 1452
831 6400
4900 116160
58170
∑
8 360
80 5131
1452 20400
6400 312830
116160
∑ 360 5131 20400 312830
Cont…
•
And,
Cont…
•
Therefore,
The estimated value of the force when the velocity is 55
m/s, is given by
Interpolation
• Means
finding approximate values of a function for an x
between different x values , , , ….., at which the values of
are given
(a) first-order (linear) connecting two points,
(b) second order (quadratic or parabolic) connecting three
points, and
(c) third-order (cubic) connecting four points.
Linear Interpolation
•The simplest form of interpolation is to connect two data
points with a straight line. This technique, called linear
interpolation
=
Which can be rearranged to yield
)
Lagrange Interpolation
• Let
be a function which takes the values , , …… , . Since
there are n+1 pairs of values of x and y, we can represent
f(x) by a polynomial in x of degree n. Let this polynomial
be of the form.
…..
+ ….. +……
+ ….. ……..(1)
Where, ……………. are constants to be found
Putting and y in (1), we get
…..
Cont…
•
Similarly, Putting and y in (1), we get
Proceeding in the same manner, we can find ….
Now substituting …. in (1) we get
+ +…..
+ ……(2)
This is known as Lagrange’s interpolation formula for unequal
intervals and it gives y= ……. when x= , …. respectively.
Working rules for solving problems
•1. Denote the given function as
2. From the given data or table, identify the values …….
and corresponding values …….
3. Substitute the values of x at which f(x) is to be
evaluated and values identified in step 2 in Lagrange’s
Formula
+ +…..
+
to get the values of f(x) at the specified point
Cont…
•Example:-From
the following table estimate f(3.2) using
only five of the given values
x 0 1 2 3 4 5 6
F(x) 2 4 10 16 20 24 38
Solution
Taking the following five values from the table
, , , and ,
4, 10, 16, 20, and
Substituting the values to Lagrange’s Interpolation Formula
Cont…
•
+ + 16 + +
Linear Regression