Chaper Five: Curve Fitting
Chaper Five: Curve Fitting
CURVE FITTING
1
5.1 Introduction
2
5.2. Least-squares regression
Fit the general trend of the data without necessarily matching the individual points
Minimize the sum of the squares of the discrepancies between the fitted curve and each data point
Linear regression
Error or Residual
Discrepancy between the true value of y and the approximate value, ao + a1x
e = y – ao – a1x
3
The residual in linear regression represents the vertical distance between a data
point and the straight line. 4
5.2. Least-squares regression
Sum of the squares of the discrepancies is given by:
Sr = 2
=-2
= -
Where is the total sum of the squares around the mean for the dependent variable
Alternative formula
r=
A value r closer to one indicates a good fit.
6
5.2. Least-squares regression
7
8
5.2. Least-squares regression
Polynomial regression
9
5.2. Least-squares regression
10
5.2. Least-squares regression
•
11
5.2. Least-squares regression
Curve fit: Second order polynomial or quadratic (y = ao + a1x + a2x2 + e)
From = 0 (i = 0, 1, 2), we get equations:
nao + a1 + a2 =
ao + a1 + a2 =
ao + a1 + a2 =
12
Example
13
Example
1. Use the following least-square regressions to determine a best-fit
equation for this data.
a. Linear regression method
b. Quadratic regression method
c. Exponential equation
d. Power equation
2. From the above curve fits which one is the best fit for the given data? Why?
3. Determine the number of cycles needed to cause failure when the material is
applied to stress of 50 MPa? 14
Solution #1
a. Linear regression method
y = ao + a1x
Where =
= -
15
a. Linear regression method
Quantify the goodness of the fit.
16
b. Quadratic regression method
y = a o + a 1 x + a 2 x2
17
b. Quadratic regression method
18
b. Quadratic regression method
Quantify the goodness of the fit.
=
19
c. Exponential function
20
c. Exponential function
21
c. Exponential function
22
c. Exponential function
Test of goodness
23
d. Power function
24
d. Power function
25
d. Power function
26
d. Power function
Test of goodness
27
Solution #2
28
Solution #3
The number of cycles needed to cause failure when the material is applied
to stress of 50 Mpa is determined by using curve fit equation of power
function
29
5.3. Interpolation
Estimates intermediate values between precise data points
For n+1 data points, there is only one polynomial of order n that passes
through all the points
a. Linear interpolation
Connect two data points with straight line (SNS)
f1(x) = f(xo) +
30
Graphical depiction of linear interpolation. The shaded areas indicate the similar triangles used
to derive the linear-interpolation formula
31
5.3. Interpolation
b. Quadratic Interpolation
If three data points are available a second order polynomial
(quadratic polynomial or a parabola).
f2(x) = bo+ b1(x-xo) + b2(x-xo)(x-x1)
x = x1 b1=
x = x2 b2 =
32
5.3. Interpolation
c. General form of Newton’s interpolating polynomials
Fit an nth-order polynomial to n+1 data points ((x0, ), (x1 , ), ….., (xn , ))
fn(x) = bo + b1(x-xo) + …………+ bn(x-xo)(x-x1) …… (x-xn-1)
Evaluation of coefficients.
bo = f(xo)
b1= =
b2= =
.
.
.
bn = =
33
5.3. Interpolation
Lagrange interpolating polynomial
34
5.4. Spline interpolation (READING ASSIGNMENT)
High-order polynomial functions can lead to erroneous results due to round-off error and overshot
Apply lower – order polynomials to subsets of data points
a. Linear Splines
mo =
35
Example
Redo Example C#5
b. Quadratic interpolations
37
Solution #4
a. Linear interpolations
38
Solution #4
b. Quadratic interpolation
39
Solution #5
Fit all data points with polynomial
40
Solution #5
41
Solution #6
For the second order Lagrange interpolation the number of data
required = 3 Therefore choose only three data.
42
Solution #6
43
THE END!
44