Practice Problems For Curve Fitting - Solution
Practice Problems For Curve Fitting - Solution
Practice Problems For Curve Fitting - Solution
Kaiwen Xia
Engineering Mathematics
November 04, 2010
0
5
2
6
4
7
6
6
9
9
11
8
kmax c 2
cs + c 2
where cs and kmax are parameters. Use a transformation to linearize this
equation. Then use linear regression to estimate cs and kmax and predict
the growth rate at c=2 mg/L.
k=
Table 2
C
K
0.5
1.1
0.8
2.4
1.5
5.3
2.5
7.6
4
8.9
a0 a1
. The
+
x x2
1
3
2
0.9
3
0.6
4
0.4
CME261
Engineering Mathematics
November 04, 2010
Kaiwen Xia
C. Polynomial Interpolation
Assume that the tabulated data in Table 3 are precise; apply the 3rd order Lagrange
Polynomial to approximate f (2.5) with precision to five decimal spaces.
D. Spline interpolation
Fit the data in Table 4 with a quadratic with natural end conditions.
Table 4
x
y
1
55
1.5
22
2
13
2.5
10
CME261
Kaiwen Xia
Engineering Mathematics
November 04, 2010
A. Linear Regression
1. Use least squares regression to fit a straight line to the data given in Table
1. Along with the slope and intercept, compute the standard error of the
estimate and the coefficient of determinant.
Table 3
0
5
x
y
2
6
4
7
6
6
9
9
11
8
Solution:
The straight line that results in the least sum of squares of the residuals
between the measured y and the calculated y will be:
y = a1 x + a0
n xi yi xi yi
where a1 =
n xi2 ( xi )
and a0 = y a1 x
= 32 ,
x y
= 41 ,
= 245 ,
2
i
6 245 32 41
= 0.30152 and a0 = 6.83 0.30152 5.33 = 5.2258
6 258 322
S r = ei2 = ( yi a0 a1 xi )
n
i =1
i =1
CME261
Kaiwen Xia
Engineering Mathematics
November 04, 2010
In this case, Sr is computed to be S r = 2.8931 .
St S r
St
where St is the total sum of squares around the mean for y:
r2 =
St = ( yi y )
i =1
St = 10.833 and r 2 =
10.833 2.893
= 0.7329
10.833
Table 4
C
K
0.5
1.1
0.8
2.4
1.5
5.3
2.5
7.6
4
8.9
Solution:
The given equation for the growth rate of bacteria can be linearized in the
following way:
kmax c 2
c
1
1
1
= s 2+
2
cs + c
k kmax c kmax
which is of the form y = a1 x + a0
k=
with y = 1/ k , x = 1
c2
, a0 = 1
kmax
and a1 =
cs
kmax
CME261
Kaiwen Xia
Engineering Mathematics
November 04, 2010
c2
1
k
1.563
0.444
0.160
0.063
0.909
0.417
0.189
0.132
0.112
= 6.299 ,
x = 2.076 , y = 0.586 .
= 1.758 ,
x y
i
= 4.399 ,
2
i
= 18.668 ,
a1 =
a0 = 1
a1 =
cs
kmax
kmax
kmax = 1
a0
=1
0.099
= 10.1 d-1
k=
10.1 c 2
2.04 + c 2
c = 2 mg / L
k = 6.689 d 1
a0 a1
. The
+
x x2
1
3
2
0.9
3
0.6
4
0.4
CME261
Kaiwen Xia
Engineering Mathematics
November 04, 2010
S r = ( yi
a0 a1 2
)
xi xi2
1
1
a0 a1
a0 a1
S r
a = 2( yi x x 2 )( x ) = 0
( yi x x 2 )( x ) = 0
0
i
i
i
i
i
i
S
a0 a1
a0 a1
1
1
r
= 2( yi 2 )( 2 ) = 0
( yi x x 2 )( x 2 ) = 0
a1
xi xi
xi
i
i
i
1
1
1 a0 a1
yi
( yi x x 2 x 3 ) = 0
a0 x 2 +a1 x 3 = x
i
i
i
i
i
i
1
1
yi
1 a0 a1
( yi 2 3 4 ) = 0
a0 3 +a1 4 = 2
xi xi xi
xi
xi
xi
i
xi
yi
1
2
3
4
1
2
3
4
3
0.9
0.6
0.4
1 / xi2
1.0000
0.2500
0.1111
0.0625
1.4236
1 / xi3
1.0000
0.1250
0.0370
0.0156
1.1777
1 / xi4
1.0000
0.0625
0.0123
0.0039
1.0788
yi / xi
3.0000
0.4500
0.2000
0.1000
3.7500
yi / xi2
3.0000
0.2250
0.0667
0.0250
3.3167
a1 = 2.0714
1.1777 a0 + 1.0778a1 = 3.3167
C. Polynomial Interpolation
Assume that the tabulated data in Table 3 are precise; apply the 3rd order Lagrange
Polynomial to approximate f (2.5) with precision to five decimal spaces.
Solution:
The third order Lagrange polynomial for the four data points given in table 3 will be:
4
x xj
i =1
j =1
j i
xi x j
y = yi Li ( x) , Li ( x) =
where:
for i=1
CME261
L1 ( x) =
( x x2 )( x x3 )( x x4 )
( x 2)( x 3)( x 4)
=
( x1 x2 )( x1 x3 )( x1 x4 )
6
( x x1 )( x x3 )( x x4 )
( x 1)( x 3)( x 4)
=
( x2 x1 )( x2 x3 )( x2 x4 )
2
for i=3
L3 ( x) =
Kaiwen Xia
for i=2
L2 ( x) =
Engineering Mathematics
November 04, 2010
( x x1 )( x x2 )( x x4 )
( x 1)( x 2)( x 4)
=
( x3 x1 )( x3 x2 )( x3 x4 )
2
L4 ( x) =
( x x1 )( x x2 )( x x3 )
( x 1)( x 2)( x 3)
=
( x4 x1 )( x4 x2 )( x4 x3 )
6
Changing the notation of the data points to make it easier to substitute, gives:
Substituting gives:
f3 ( x) =
2
6
( x 1)( x 2 )( x 4 ) 0.6 + ( x 1)( x 2 )( x 3) 0.4
+
6
2
f 3 ( x) = 0.5 ( 2.5 2 )( 2.5 3)( 2.5 4 ) + 0.45 ( 2.5 1)( 2.5 3)( 2.5 4 )
0.3 ( 2.5 1)( 2.5 2 )( 2.5 4 ) + 0.067 ( 2.5 1)( 2.5 2 )( 2.5 3) = 0.63125
CME261
Engineering Mathematics
November 04, 2010
Kaiwen Xia
D. Spline interpolation
Fit the data in Table 4 with a quadratic with natural end conditions.
Table 4
x
y
1
55
1.5
22
2
13
2.5
10
Solution:
For quadratic splines, we want to derive a second order polynomial for each interval
which will fit the data in the interval. The polynomial is of the following form:
f i ( x) = ai + bi ( x xi ) + ci ( x xi ) 2
Natural condition implies c1 = 0, b1 = ( y2 y1 ) /( x2 x1 ) .
Use the formula:
ai +1 = yi +1
a1 = 55 a2 = 22 a3 = 13
b1 = 66; b2 = 66; b3 = 30
bi +1 = bi + 2ci ( xi +1 xi )
c = 0 c = 96 c = 72
yi + 2 yi +1
bi +1
3
2
1
ci +1 = ( x x ) 2 ( x x )
i+2
i +1
i+2
i +1
40
30
20
10
0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6