NSM UNIT IV PPTs

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

Department of Mechanical Engineering

Third Year Mechanical Engineering


Semester-V , 2019 Pattern

Subject: 302041: Numerical and


Statistical Methods

By: Prof. Rahul Kulkarni,SCOE


Unit No-04 : CURVE FITTING &REGRESSION ANALYSIS
Syllabus:-
Curve Fitting:
Least square technique- Straight line, Power equation, Exponential equation and Quadratic equation.

Regression Analysis: Introduction to multi regression analysis, Lagrange’s Interpolation, Newton’s Forward interpolation,
Inverse interpolation (Lagrange’s method only)

Unit Objectives:
On completion the students will be able to :
1. To fit the given data in the form of equation.
2. To predict the desired values using interpolation and extrapolation techniques
3. To became familiar with processing/analyzing experimental data to obtain the desired responseand how it is
different from ODE.

Unit Outcomes:
1. Apply and analyze the data by performing curve fit to predict the behavior.
2. Predict the trend and forecast data from existing data.

Reference Books:
T1: Steven C Chapra, Raymond P Canale, Num. Methods for Engineers, 4/e Tata McGraw Hill Editions. [7th Edition]
R1: S. S. Sastry, Introductry Methods of Numerical Analysis Numerical Methods, PHI. [5th Edition]
Outline
• Curve Fitting
Least square technique-
1. Straight line,
2. Power equation
3. Exponential equation
4. Quadratic equation

• Regression Analysis
1. Introduction to multi regression analysis
2. Lagrange‘s Interpolation
3. Newton‘s Forward interpolation
4. inverse interpolation
Least square technique- Straight line

• It describes the technique to fit curve to discrete data


to obtain intermediate estimates.

• The simplest method for fitting a curve to data is to


plot the points & then sketch a line that visually
conforms to the data. But this approach results into
different results as shown in Fig.1.

• A technique is developed to derive a curve that


minimizes the discrepancy between the data points &
the curve .This technique is called as Least –Square
Regression.

Fig.1
Least square technique- Straight line

• Two general approaches:


– Data exhibit a significant degree of scatter Find a single curve
that represents the general trend of the data.

– Data is very precise. Pass a curve(s) exactly through each of


the points.

• Two common applications in engineering:

Trend analysis. Predicting values of dependent variable:


extrapolation beyond data points or interpolation between data
points.

Hypothesis testing. Comparing existing mathematical model with


measured data.
Mathematical Background

• In many Engg. applications, it is required to express the data, obtained from


various observations & experiments in the form of law.
E.g. if the temperature of the body increases, as the time increases , so for
various values of time, the different temperature is measured.

• To know the effect of time on temperature of body, we write the relation


between time (Independent variable) & temperature (dependent variable) which
is either linear or non-linear.

• The process of finding such a relationship in the form of mathematical equation


is called as regression analysis or curve fitting.
Least Square Criteria
Straight Line Fit
• Use least square regression to fit a straight line to the data given below.

X 1 2 3 4 5 6 7
Y 0.5 2.5 2.0 4.0 3.5 6.0 5.5
• The general equation of line is Y = aX+b
• Here, the values of a & b are to be calculated.
The desired equation of straight line are,
Least square technique- Straight line

X Y XY X^2
1 0.5 0.5 1
2 2.5 5 4
3 2 6 9
4 4 16 16
5 3.5 17.5 25
6 6 36 36
7 5.5 38.5 49
∑ 28 24 119.5 140

Solving the above two equations, we get


a=0.839286 b=0.0714285

Then the best fit curve(straight line) is given by the equation,


Y= 0.8392X + 0.07142
Least square technique – Power equation

• If the curve is given of the form

• Then the equation is converted into straight line equation by taking


from both sides,

Where,

Then, the problem can be solved similar to the straight line.


Power Equation

• If the curve is given of the form

then, the equation is converted into straight line equation by taking


from both sides,

Where,

Then, the problem can be solved similar to the straight line.


Exponential Equation
• If the exponential curve is given of the form

• Then the equation can be converted into straight line equation by taking from
both sides,

• Where,

Then, the problem can be solved similar to the straight line.


Example 1
The upward velocity of a rocket is given
as a function of time in Table 1.
Find the velocity at t=16 seconds using
the direct method for linear
Table 1 Velocity as a function of time interpolation.

t, (s) v(t),(m/s)
0 0
10 227.04

15 362.78

20 517.35

22.5 602.97

30 901.67
Figure 3 Velocity vs. time data for the rocket
example
Example 1

v(t ) = a0 + a1t y

v(15) = a0 + a1 (15) = 362.78 (x1 , y1 )

v(20) = a0 + a1 (20) = 517.35 (x0 , y0 )


f1 (x )

Solving the above two equations gives, x

a0 = −100.93 a1 = 30.914
Hence
v(t ) = −100.93 + 30.914t , 15  t  20.
v(16) = −100.93 + 30.914(16) = 393.7 m/s
Example 2
The upward velocity of a rocket is given
as a function of time in Table 1.
Find the velocity at t=16 seconds using
the direct method for quadratic
interpolation.
Table 1 Velocity as a function of time

t, (s) v(t),(m/s)
0 0
10 227.04

15 362.78

20 517.35

22.5 602.97

30 901.67

Figure 4 Velocity vs. time data for the rocket


example
Example 2

v(t ) = a0 + a1t + a2t 2 (x1 , y1 )


v(10) = a0 + a1 (10) + a2 (10) = 227.04
2 (x2 , y2 )

v(15) = a0 + a1 (15) + a2 (15) = 362.78


2

f 2 (x )
v(20) = a0 + a1 (20) + a2 (20) = 517.35
2
( x0 , y 0 )
x

Solving the above three equations gives

a0 = 12.05 a1 = 17.733 a2 = 0.3766


Example 2

550
517.35

500

450

v(t ) = 12.05 + 17.733t + 0.3766t 2 , 10  t  20 ys


400
f ( range)

( )
v(16) = 12.05 + 17.733(16) + 0.3766(16)
f x desired
2 350

300

= 392.19 m/s 250

227.04 200
10 12 14 16 18 20
10 x s  range x desired 20

The absolute relative approximate error a obtained between the


results from the first and second order polynomial is
392.19 − 393.70
a = 100
392.19
= 0.38410%
Comparison Table

• Table 2 Comparison of different orders of the polynomial

Order of Polynomial 1 2

v(t=16) m/s 393.7 392.19

Absolute Relative --------------- 0.38410 %


Approximate Error
Least square technique – Quadratic equation
Polynomial Regression

• If available data points are scattered as shown in Fig.2(a), then straight line
is not suitable.
• Fig 2(b) shows a parabola which is more suitable for the given set of data
points.

Fig.2(a) This method of fitting a parabola in short a polynomial Fig.2(b)


through the given set of data points is called as polynomial
regression
Quadratic Equation

• Use least square regression to fit the quadratic equation y = ax2 + bx + c


to the data given below.
X -3 -2 -1 0 1 2 3
Y 12 4 1 2 7 15 30
• Here, the values of a , b & c are to be calculated.
The desired equation of straight line are,

Solving these three equation, we get the values of a , b & c.


Lagrange's Interpolation and inverse interpolation

• Interpolation is defined as the technique of calculating the


value of a function for any intermediate value of independent
variable .
• If the various values of y=f(x) for a given set of value of x i.e.

x x0 x1 x2 -------- -------- -------- xn

y=f(x) y0 y1 y2 -------- -------- -------- yn

then the process of finding the value of y corresponding to any


value of x is called interpolation.
Lagrange's Interpolation and inverse interpolation

Given (x0,y0), (x1,y1), …… (xn,yn), find the value of ‘y’ at a value of ‘x’ that is
not given.

Figure 6- Interpolation of discrete


Methods of Interpolation
Lagrange's Interpolation and inverse interpolation
When the values of x are equi-spaced, i.e, when step size h is same for all the
values of x, then Newton’s forward difference & Newton’s backward difference
interpolation methods are used.

When the points are not equi-spaced, then Lagrange’s or Hermites interpolation
methods are used.
Lagrange's Interpolation and inverse interpolation

Lagrange’s interpolating polynomial is given by,

where ‘n’ in stands for the nth order polynomial that approximates the function
y=f(x) given at (n+1)data points
as (x0,y0), (x1,y1), …… (xn-1,yn-1), (xn,yn), and

is a weighting function that includes a product of (n-1)terms with terms


of j=i omitted.
Inverse Interpolation

• The Lagrange's formula is also applicable for calculating value of x at


given value of y. This is called ‘Inverse Interpolation’.
• The formula for the value of xg is obtained by replacing yg with xg & vice
versa.
Newton's Forward interpolation

When the values of x are equi-spaced, i.e, when step size h is same for all the values of
x, i.e. then Newton’s forward difference is used.

Newton’s forward difference formula is given by,

You might also like