Chapter 5 Curve Fitting PART 1
Chapter 5 Curve Fitting PART 1
Curve fitting
Chapter 5
Curve fitting
Lagrange Interpolation
Spline Interpolation
3
Curve fitting
4
Figure PT5.1, pg 439 shows sketches developed from same set of data by 3
engineers.
a) least-squares regression - did not
attempt to connect the point, but
characterized the general upward
trend of the data with a straight line
b) Linear interpolation - Used straight-
line segments or linear interpolation
to connect the points. Very common
practice in engineering. If the
values are close to being linear,
such approximation provides
estimates that are adequate for
many engineering calculations.
However, if the data is widely
spaced, significant errors can be
introduced by such linear
interpolation.
c) Curvilinear interpolation - Used
curves to try to capture suggested
bay the data.
Our goal here to develop
systematic and objective
method deriving such curves. Curve fitting
a) Least-square Regression : i) Linear Regression
• Is used to minimize the discrepancy/differences between the data
points and the curve plotted. Sometimes, polynomial interpolation is
inappropriate and may yield unsatisfactory results when used to
predict intermediate values (see Fig. 17.1, pg 455).
Curve fitting 5
6
y = a0+a1x+e Eq 17.1
where, a1- slope
a0 - intercept
e - error, or residual, between the model
and the observations
Rearranging the eq. above as:
e = y - a0 - a 1x
Curve fitting
7
e ( y a
i 1
i
i 1
i 0 a1 xi ) ----- Eq 17.2
n n n
S r e ( yi ,measured yi ,mod el ) ( yi a0 a1 xi ) 2
2
i
2
----- Eq 17.3
i 1 i 1 i 1
Curve fitting
8
n xi yi xi yi
a1
n xi2 xi
2 ----- Eq 17.6
----- Eq 17.7
a0 y a1 x
Curve fitting
EXAMPLE 1
x 1 2 3 4 5 6 7
Sr
Sy ---------- Eq. 17.9
x n2
Curve fitting
11
St
Sy -------- (PT5.2, pg 442 )
n 1
• Just as the case with the standard deviation, the standard error
of the estimate quantifies the spread of the data.
Curve fitting
12
S
Sy r
x n2 ----- Eq 17.9
Curve fitting
13
3. Determination coefficient
St S r
r2 ----- Eq 17.10
St
4. Correlation coefficient
St S r n xi yi ( xi )( yi )
r @r
St n xi2 ( xi ) 2 n yi2 ( yi ) 2 ----- Eq 17.11
Curve fitting
EXAMPLE 2
x 1 2 3 4 5 6 7
x 1 2 3 4 5 6 7 8 9
y 1 1.5 2 3 4 5 8 10 13
Curve fitting
19
Curve fitting
20
Curve fitting
21
y 1e x
1 ------ (17.12)
1 , 1 : constants, 1 0
Curve fitting
22
Example 2
Solution
• Linearized the model into;
ln y = ln a + bx
• Build the table for the parameters used in eqs 17.6 and 17.7,
as in example 17.1, pg 444.
Curve fitting
23
n6
n n
x
i 1
i 8.3 ln y
i 1
i 44.496496
n n
x
i 1
2
i
14.09 ( x )(ln y ) 63.753055
i 1
i i
8.3 44.496496
x 1.383333 ln y
Curve fitting
7.416083
6 6
24
a0 ln a ln y b x 7.416083 (0.843)(1.383333)
ln a 6.25
Straight-line:
ln y ln a bx
ln y 6.25 0.843x
Exponential: y a ebx
Curve fitting
26
Curve fitting
27
Power Equation
y 2 x 2
-------- (17.13)
log y log 2 2 log x -------- (17.16)
• A plot of log y versus log x will yield a straight line with slope
of 2 and an intercept of log 2.
Curve fitting
28
Power Equation
Example 4
x 1 2 3 4 5
Curve fitting
29
Solution:
1 0.5 0 -0.301 0 0
2 1.7 0.301 0.226 0.090601 0.068026
3 3.4 0.477 0.534 0.227529 0.254718
4 5.7 0.602 0.753 0.362404 0.453306
5 8.4 0.699 0.922 0.488601 0.644478
2.079 2.134 1.169135 1.420528
Curve fitting
30
n5
n n
log x
i 1
i 2.079 log y
i 1
i 2.134
n n
(log x )
i 1
i
2
1.169135 (log x )(log y ) 1.420528
i 1
i i
2.079 2.134
log x 0.4158 log y 0.4268
5 5
Curve fitting
31
Straight-line:
Power: y a xb
y a xb 0.5 x1.75
Curve fitting
32
Curve fitting
33
Curve fitting
34
1 3 1 1
------- (17.17)
y 3 x 3
• A plot of 1/y versus 1/x will yield a straight line with slope of
3/3 and an intercept of 1/3
• In their transformed forms, these models are fit using linear
regression in order to evaluate the constant coefficients.
• They could then be transformed back to their original state
and used for predictive purposes as discusses in
Curve fitting
35
Example 5
Curve fitting
36
Solution
n7
n n
1 1
i 1 xi
2.8926
i 1 yi
5.2094
2
n
1 n
1 1
2.3074
i 1 xi
2.8127
i 1 xi yi
1 2.8926 1 5.2094
0.4132 0.7442
x 7 y 7
Curve fitting
37
1 1 1 1
n
b
xi y i xi y i
2
a 1 1 2
n
(
)
i
x i
x
b (7)(2.8127) ( 2.8926)(5.2094)
0.5935
a (7)(2.3074) ( 2.8926) 2
Curve fitting
38
1 1 b1
0.7442 (0.5935)(0.4132)
a y a x
1
0.4990
a
1 1 b1
Straight-line:
y a ax
1 1
0.4990 0.5935
y x
x
Saturation-growth: y a b x
1
0.4990 a 2
a
b
0.5935 b (0.5935)(2) 1.187
a
x
y 2
1.187 x Curve fitting
39
Quiz 3
x 1 2 3 4 5 6 7
Curve fitting
40
Curve fitting
41
Curve fitting
42
Curve fitting
43
Sr
2 ( yi a0 a1 xi a2 xi2 )
a0
Sr
2 xi ( yi a0 a1 xi a2 xi2 )
a1
Sr
2 xi2 ( yi a0 a1 xi a2 xi2 )
a2
y a0 a1 x a2 x 2 ... am x m e
• Thus, standard error for mth-order polynomial :
Sr
Sy/ x ----- 17.20
n (m 1)
Curve fitting
45
Example 6
Fit a second order polynomial to the data in the first 2 columns
of table 17.4:
xi yi x i2 x i3 x i4 xi yi xi2 yi
0 2.1 0 0 0 0 0
1 7.7 1 1 1 7.7 7.7
2 13.6 4 8 16 27.2 54.4
3 27.2 9 27 81 81.6 244.8
4 40.9 16 64 256 163.6 654.4
5 61.1 25 125 625 305.5 1527.5
15 152.6 55 225 979 585.6 2488.8
6 15 55 ao 152.6
15 55 225 a 585.6
1
55 225 979
a 2
2488.8
• Solving these equations through a technique such as Gauss
elimination gives:
ao = 2.47857, a1 = 2.35929, and a2 = 1.86071
xi yi (yi- y )2 (yi-ao-a1xi-a2xi2)2
0 2.1 544.44 0.14332
1 7.7 314.47 1.00286
2 13.6 140.03 1.08158
3 27.2 3.12 0.80491
4 40.9 239.22 0.61951
5 61.1 1272.11 0.09439
Σ 152.6 2513.39 3.74657
St ( yi y ) 2513.39
S r ( yi a0 a1 xi a2 xi ) 2 3.74657
2
Sr 3.74657
Sy 1.12
x n (m 1) 6 (2 1)
Curve fitting
48
St S r
r2
St
St S r n xi yi ( xi )( yi )
r @r
St n xi2 ( xi ) 2 n yi2 ( yi ) 2
Curve fitting