least squares examples
TRANSCRIPT
-
8/2/2019 Least Squares Examples
1/10
E x c e r c i s e s i n L e a s t S q u a r e s S e p t e m b e r 1 3 , 2 0 0 6
F a l l 2 0 0 6
1 .
D e n e c o n s t a n t s
aa n d
bs u c h t h a t t h e l i n e
y = ax + bi n t e r p o l a t e s t h e d a t a
p o i n t s ( 0 , 2 . 1 ) , ( 1 , 1 . 9 2 ) , ( 2 , 1 . 8 4 ) , ( 3 , 1 . 7 1 ) j a ( 4 , 1 . 6 4 ) i n a l e a s t s q u a r e s s e n s e .
V a s t a u s :
a = 0.113b = 2.068
R a t k a i s u :
S =5
i=1
(yi axi b)2
S a t t a i n s i t s s m a l l e s t v a l u e a t t h e c r i t i c a l p o i n t .
0 =S
a= 2
5i=1
xi(yi axi b)
0 =S
b= 2
5i=1
yi axi b
0 = 2
0 (2.1 a 0 b) + 1 (1.92 a 1 b) + 2(1.84 a 2 b) + 3(1.71 a 3 b)+4(1.64 a 4 b)
0 = 2
2.1 a 0 b + 1.92 a b + 1.84 2a b + 1.71 3a b + 1.64 4a b
60a + 20b = 34.5820a + 10b = 18.42
a = 0.113b = 2.068
2 .
a ) D e n e t h e c o n s t a n t
as o t h a t t h e f u n c t i o n
y = ax2i s t h e b e s t t i n t h e
s e n s e o f l e a s t s q u a r e s t o t h e d a t a p o i n t s (xi, yi), i = 1, . . . , n. W h a t v a l u e s h o u l d t h e c o n s t a n t a a t t a i n i f t h e f u n c t i o n i s y = aex?
b ) D e n e c o n s t a n t s
aa n d
b, t h a t m a k e t h e f u n c t i o n
g(x) = ax2 + bxt o a t t a i n
-
8/2/2019 Least Squares Examples
2/10
t h e b e s t t t o t h e f u n c t i o n f(x) = sin x o v e r t h e i n t e r v a l [0, ], i n t h e s e n s e t h a t t h e s q u a r e d i n t e g r a l
I =0
[f(x) g(x)]2 dx
i s m i n i m i z e d .
V a s t a u s :
a )
a =
n
i=1yie
xi
ni=1
e2xi
b ) a =20
5(2 16), b =
12
4(20 2)
R a t k a i s u :
a ) W e s e e k t h e s m a l l e s t v a l u e o f t h e f u n c t i o n
S(a) =
ni=1
(yi ax2
i )2
S(a) = 2
ni=1
x2i (yi ax2
i ) = 0
a =
ni=1
x2i yi
ni=1
x4i
y = aex
S(a) =
n
i=1
(yi aexi
)2
S(a) = 2
ni=1
exi(yi aexi) = 0
-
8/2/2019 Least Squares Examples
3/10
a =
n
i=1 yiexi
ni=1
e2xi
b ) W e s e e k t o m i n i m i z e I =
0
(sin x ax2 bx)2 dx
Ia = 2
0
x2(sin x ax2 bx) dx = 0
Ib = 2
0
x(sin x ax2 bx) dx = 0
0
(x2 sin x ax4 bx3) dx = 00
(x sin x ax3 bx2) dx = 0
0
2cos x + 2 sin x x2 cos x
ax5
5
bx4
4
= 2 4
a5
5
b4
4= 0
0
sin x x cos x
ax4
4
bx3
3
=
a4
4
b3
3= 0
a =20
5(2 16), b =
12
4(20 2)
3 .
A p p r o x i m a t e t h e f u n c t i o n
f(x)d e n e d o n t h e i n t e r v a l
[0, 1]w i t h a l i n e a r f u n c -
t i o n g(x) = px + q u s i n g t h e l e a s t s q u a r e s m e t h o d .
V a s t a u s :
p =
1
0
(12x 6)f(x) dx
q =
1
0
(4 6x)f(x) dx
R a t k a i s u :
I(p,q) =
1
0
f(x)px q
2dx
-
8/2/2019 Least Squares Examples
4/10
0 =
I
p
= 21
0
xf(x)px qdx = 00 =
I
q= 2
10
f(x)px q
dx = 0
1
0
xf(x) dx =
10
px3
3+
qx2
2
=
p
3+
q
21
0
f(x) dx =
10
px2
2+ qx
=
p
2+ q
p =
1
0
(12x 6)f(x) dx
q = 1
0(4 6x)f(x) dx.
4 .
L e t u s u s e t h e l e a s t s q u a r e s m e t h o d t o t a l i n e t o t h e r e s u l t s o f a l a b o r a t o r y
e x p e r i m e n t . I n a n e x p e r i m e n t w e h a v e o x i d a t e d b u t a n o l i n t o b u t y r i c a c i d . W e
s h a l l a s s u m e t h a t r e a c t i o n k i n e t i c s a r e o f r s t o r d e r a n d t h a t t h e r e a r e n o s i d e
r e a c t i o n s .
T h e r e a c t i o n t o b e s t u d i e d i s
B u t a n o l B u t y r i c a c i d
I n t h e b e g i n n i n g , w e h a v e i n s e r t e d b u t a n o l i n t o t h e v e s s e l t o r e a c h t h e d e n s i t y
o f
53 mmoldm3
. W h e n b u t a n o l w a s o x i d i z e d i n t h e p r e s e n c e o f a c a t a l y s t a t
80 C ,
t h e f o l l o w i n g m e a s u r e m e n t s w e r e m a d e .
T i m e , m i n P e r c e n t a g e o f B u t a n o l o x i d i z e d
36.0 19 %65.7 30 %120 41 %180 48 %330 62 %
T a u l u k k o 1 : T h e p e r c e n t a g e o f b u t a n o l o x i d i z e d a s a f u n c t i o n o f t i m e .
V a s t a u s :
T h e r a t e a t w h i c h B u t a n o l i s o x i d i z e d i n t o b u t y r i c a c i d i s 2.47 103mmolmin
.
-
8/2/2019 Least Squares Examples
5/10
R a t k a i s u : T h e s p e e d o f t h e r e a c t i o n i s g i v e n b y t h e e q u a t i o n
dc b u t y r i c a c i d dt
= dcb u t a n o l
dt= kc
b u t a n o l
I n o t h e r w o r d s , b u t a n o l i s d i s a p p e a r i n g a t t h e s a m e r a t e t h a t b u t y r i c a c i d
e m e r g e s i n t o t h e v e s s e l . T h e r e a c t i o n r a t e c o n s t a n t
ki s t o b e d e t e r m i n e d b y
t h e l e a s t s q u a r e s m e t h o d .
I n t e g r a t i n g t h e e q u a t i o n a b o v e , w e g e t dc
b u t a n o l
cb u t a n o l
= k
dt.
I n t h e b e g i n n i n g , t h e c o n c e n t r a t i o n o f b u t a n o l i s g i v e n a t 53 mmoldm3
, a n d w e g e t
ln cb u t a n o l
= kt.
L e t u s r s t c o n v e r t t h e m e a s u r e m e n t s i n t o t h e f o l l o w i n g c o n v e n i e n t f o r m :
T i m e , m i n b u t a n o l ( % )
cb u t y r i c a c i d
, mmoldm3
cb u t a n o l
, mmoldm3
ln c yi36 19 % 10.07 42.93 3.76
65.7 30 % 15.9 37.10 3.61120 41 % 21.73 31.27 3.44180 48 % 25.44 27.56 3.32330 62 % 32.86 20.14 3.00
T a u l u k k o 2 : M e a s u r e m e n t s m a d e
W e s h a l l n o w t a l i n e o f t h e f o r m y = mx + b i n t o t h e m e a s u r e m e n t t a b l e . U s i n g m a t r i c e s , w e c a n n o w c o m p u t e t h e d e t e r m i n a n t , a n g l e o f i n c i d e n c e a n d
t h e p o i n t a t w h i c h t h e l i n e i n t e r s e c t s t h e y a x i s ( i n t h i s c a s e t h e s y m b o l md e n o t e s t h e r e a c t i o n r a t e c o n s t a n t ) .
b =
(x2i )
(xi yi)xi
yi
D
.
D =
(x2i ) xixi i
m =
(xi yi)
xiyi i
D
-
8/2/2019 Least Squares Examples
6/10
I n s e r t i n g t h e v a l u e s m e a s u r e d f r o m t h e t a b l e a b o v e , w e o b t a i n t h e f o l l o w i n g
e x p r e s s i o n f o r t h e d e t e r m i n a n t :
D =
161312 731.7731.7 5
= 271177
F r o m t h i s , t h e a n g l e o f i n c i d e n c e o f t h e t t e d l i n e e m e r g e s a s :
m =
2373.72 731.717.135 5
D
m = 2.47 103.
T h e a b o v e r e s u l t i n d i c a t e s t h a t b u t a n o l i s o x i d i z e d i n t o b u t y r i c a c i d a t t h e r a t e
o f 2.47 103mmolmin
, w h e n t h e i n i t i a l c o n c e n t r a t i o n o f b u t a n o l w a s 53 mmoldm3
.
P l e a s e c a r r y o u t t h e s a m e c o m p u t a t i o n s u s i n g M a t l a b a n d v e r i f y t h e s e r e s u l t s .
5 .
A r r h e n i u s ' L a w f o r t h e t e m p e r a t u r e d e p e n d e n c e o f a r e a c t i o n c a n b e s t a t e d a s
k = AeEa
RuT ,
w h e r e
Ru
= 8.3145 JmolK
i s t h e u n i v e r s a l g a s c o n s t a n t .
W h e n m e a s u r i n g t h e t h e r e a c t i o n r a t e c o n s t a n t
ka t d i e r e n t t e m p e r a t u r e s
Tf o r
a r e a c t i o n b e t w e e n b e n z e n e a n d o x y g e n , w e o b t a i n t h e f o l l o w i n g m e a s u r e m e n t s
T k[K] [dm3/mol s]
300.3 1.44 107
341.2 3.03 107
391.2 6.90 107
D e t e r m i n e t h e a c t i v a t i o n e n e r g y Ea a n d t h e A r r h e n i u s c o n s t a n t A f o r t h e r e - a c t i o n u s i n g t h e l e a s t s q u a r e s m e t h o d . P l e a s e a l s o c o n s i d e r h o w y o u w o u l d f o r -
m u l a t e t h e l e a s t s q u a r e s p r o b l e m u s i n g m a t r i x a l g e b r a ( i n t h i s c a s e t h e l e a s t
s q u a r e s p r o b l e m a t t a i n s t h e f o r m
Y = XC) .
L S M = L e a s t S q u a r e s M e t h o d .
W e m u s t t a l i n e o f t h e f o r m y = a + bx t o t h e m e a s u r e m e n t s , w h e r e
a =
y b
x
Nb =
x
y N
xyx2N
x2
-
8/2/2019 Least Squares Examples
7/10
V a s t a u s :
A = 1.28 1010dm3
mol sj a
Ea = 17.0kJ
mol
R a t k a i s u : T h e A r r h e n i u s e q u a t i o n r e a d s
k = AeEa
RuT
W e s h a l l t a k e t h e l o g a r i t h m o f b o t h s i d e s
ln k = ln A + ln eEa
RuT
a n d t h e n t r a n s f o r m t h i s i n t o a n e q u a t i o n f o r a l i n e
ln ky
= ln Aa
+ Ea
Ru
b
1Tx
t h a t i s
y = ln kx = 1
T
a = ln Ab = Ea
Ru
N o w w e s h a l l r e w r i t e t h e m e a s u r e m e n t s a s :
T k x y[K] [dm3/mol s] = 1/T = ln(k)
300.3 1.44 107 0.003330 16.483341.2 3.03 107 0.002931 17.227391.2 6.90 107 0.002550 18.050
T h e g r a p h o f t h e l e a s t s q u a r e s s o l u t i o n l o o k s a s f o l l o w s
F r o m t h e e q u a t i o n f o r t h e l i n e , w e o b t a i n i t s c o n s t a n t c o e c i e n t s .
T h e c o n s t a n t
ay i e l d s t h e A r r h e n i u s c o n s t a n t
ln A = 23.147 A = 1.12 1010dm3
mol s
w h i l e t h e c o n s t a n t b g i v e s u s t h e a c t i v a t i o n e n e r g y
Ea = Rub = 8.3145J
mol K 2006.9 K = 16.69
kJ
mol
T h e l e a s t s q u a r e s m e t h o d r e a d s
b =
x
y N
xyx2N
x2
-
8/2/2019 Least Squares Examples
8/10
a =
y b
x
N
I n s e r t i n g o u r n u m e r i c a l v a l u e s , w e g e t
N = 3x = 0.008811y = 51.760
x2 = 26.18 106xy = 0.1514b =
0.008811 51.760 3 0.1540
0.0088112 3 26.18 106= 2049
a =51.760 + 2049 0.008811
3= 23.271
T h e a c t i v a t i o n e n e r g y o b t a i n s
Ea = Ru b = 8.3145J
mol K 2049 K = 17.0
kJ
mol
a n d t h e A r r h e n i u s c o n s t a n t ( i n t h e s a m e u n i t s a s t h e r e a c t i o n r a t e c o e c i e n t k )
A = ea = e23.271 = 1.28 1010dm3
mol s
W e n o w w r i t e t h e l e a s t s q u a r e s m e t h o d i n m a t r i x f o r m
Y = XC
-
8/2/2019 Least Squares Examples
9/10
w h e r e
Y = ln k1ln k2
ln k3
X = 11
T11 1T2
1 1T3
C = ab
T h e s u b s c r i p t s r e f e r t o m e a s u r e m e n t p o i n t s , o f w h i c h w e c o u l d h a v e m o r e , b u t
i n t h e i n t e r e s t o f s i m p l i c i t y i n m a n u a l c a l c u l a t i o n w e s h a l l b e c o n t e n t w i t h t h r e e
m e a s u r e m e n t p o i n t s o n l y . W e t h e r e f o r e h a v e t w o u n k n o w n s i n t h e c o e c i e n t
m a t r i x
C, t h a t w e s h a l l s o l v e f o r .
Xi s n o t a s q u a r e m a t r i x , s o w e s h a l l m u l t i p l y
i t w i t h i t s t r a n s p o s e t o o b t a i n t h e n o r m a l e q u a t i o n s
XTY = XTXC
T h i s l o o k s b e t t e r , s o l e t ' s n o w m u l t i p l y t h e e q u a t i o n w i t h t h e i n v e r s e o f (XTX)f r o m t h e l e f t o n b o t h s i d e s
(XTX)1XTY = (XTX)1XTXC
A m a t r i x m u l t i p l i e d b y i t s i n v e r s e y i e l d s t h e i d e n t i t y m a t r i x
I, a n d w e t h u s
o b t a i n
(XTX)1XTY = IC
L e t u s n a l l y s w a p t h e l e f t h a n d s i d e a n d t h e r i g h t h a n d s i d e w i t h o n e a n o t h e r
C = (XTX)1XTY
a n d w e t h u s g e t t h e c o e c i e n t s r e q u i r e d b y t h e A r r h e n i u s ' l a w a s t o n i s h i n g l y
f a s t . . . i f w e c a n g e t i t d o n e c o r r e c t l y .
L e t u s c h e c k t h a t t h e m a t r i c e s m u l t i p l y c o r r e c t l y
Ci s o f s i z e
2 1XT
i s o f s i z e
2 3X i s o f s i z e 3 2Y
i s o f s i z e
3 1
[2 1] =
[2 3][3 2]1
[2 3][3 1] [2 1] = [2 2]1[2 1]
[2 1] = [2 2][2 1] [2 1] = [2 1]
a n d w e ' r e d o n e .
6 .
B y w r i t i n g a r e a c t i o n e q u a t i o n i n m a t r i x f o r m , w e c a n e a s i l y b a l a n c e a n e q u a t i o n ,
i . e . n d t h e s t o i c h i o m e t r i c c o e c i e n t s f o r t h e r e a c t i o n e q u a t i o n
L e t u s n d t h e s t o i c h i o m e t r i c c o e c i e n t s f o r t h e r e a c t i o n e q u a t i o n
M gO + F e F e2O3 + Mg
-
8/2/2019 Least Squares Examples
10/10
V a s t a u s :
a = 3, b = 2, c = 1j a
d = 3
3M gO + 2F e F e2O3 + 3M g
R a t k a i s u : W e s h a l l r e w r i t e t h e e q u a t i o n i n t h e f o r m
aMgO + bF e = cF e2O3 + dMg.
M a g n e s i u m : a +0b +0c = 1dI r o n
: 0a +1b 2c = 0dO x y g e n
: 1a +0b 3c = 0d
W e o b t a i n t h e m a t r i x
A =
1 0 00 1 2
1 0 3
I t ' s d e t e r m i n a n t i s d e t A = 3
B =
10
0
.
W e n o w c o n s t r u c t t h e i n v e r s e m a t r i x
A1 = 1 0 02
31 2
3
1
30 1
3
.
F r o m t h i s , w e c a n s o l v e f o r t h e s t o i c h i o m e t r i c c o e c i e n t s
[A]1 [B]d e t [A] =
321
A n d t h u s
a = 3, b = 2, c = 1j a
d = 3
a n d t h i s y i e l d s
3M gO + 2F e F e2O3 + 3M g