HW 8 solutions - EGM3344 HW8 Solution Problem 14.3 y = a +...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EGM3344 HW8 Solution Problem 14.3 y = a + a 1 x + a 2 x 2 + a 3 x 3 (1) y 1 y 2 . . . y 8 = 1 x 1 x 2 1 x 3 1 1 x 2 x 2 2 x 3 2 . . . 1 x 8 x 2 8 x 3 8 a a 1 a 2 a 3 (2) a = ( A T A )- 1 A T y (3) >> x=[3 4 5 7 8 9 11 12]'; >> y=[1.6 3.6 4.4 3.4 2.2 2.8 3.8 4.6]'; >> A=[ones(length(x),1) x x.2 x.3]; >> A \ y ans =- 11.4887 7.1438- 1.0412 0.0467 >> r2 = (norm(y- mean(y))2- norm(y- ya)2)/norm(y- mean(y))2 r2 = 0.8290 thus a =- 11 . 4887, a 1 = 7 . 1438, a 2 =- 1 . 0412, and a 3 = 0 . 0467. y =- 11 . 4887 + 7 . 1438 x- 1 . 0412 x 2 + 0 . 0467 x 3 (4) this provides the approximate values of y . Let y and y a be the mean value and the approximate values of y . y a = Aa (5) then r 2 = k y- y k 2- k y- y a k 2 k y- y k 2 (6) 1 >> r2 = (norm(y- mean(y))2- norm(y- ya)2)/norm(y- mean(y))2 r2 = 0.8290 Thus, r 2 = 0 . 829 . Problem 14.6 Let 1 n R n 1 be a column vector with all ones (i.e., 1 3 = [1 , 1 , 1] T ), c 1 = 0, c 2 = 10, c 3 = 20, and T = 0 5 10 15 20 25 30 T (7) o 1 = a 1 7 + a 1 T + a 2 c 1 1 7 = 14 . 6 12 . 8 11 . 3 10 . 1 9 . 09 8 . 26 7 . 56 T (8) o 2 = a 1 7 + a 1 T + a 2 c 2 1 7 = 12 . 9 11 . 3 10 . 1 9 . 03 8 . 17 7 . 46 6 . 85 T (9) o 3 = a 1 7 + a 1 T + a 2 c 3 1 7 = 11 . 4 10 . 3 8 . 96 8 . 08 7 . 35 6 . 73 6 . 20 T (10) then the dissolved oxygen concentration can be expressed as a linear system of the form y = Ax : o = o 1 o 2 o 3 = a 1 21 + a 1 T T T + a 2 c 1 1 7 c 2 1 7 c 3 1 7 (11) = 1 7 T c 1 1 7 1 7 T c 2 1 7 1 7 T c 3 1 7 a a 1 a 2 (12) prob14 6.m % Problem 14.6 c1 = 0; c2 = 10; c3 = 20; T = [0 5 10 15 20 25 30]'; o1 = [14.6 12.8 11.3 10.1 9.09 8.26 7.56]'; o2 = [12.9 11.3 10.1 9.03 8.17 7.46 6.85]'; o3 = [11.4 10.3 8.96 8.08 7.35 6.73 6.20]'; A = [ones(21,1) [T;T;T] [c1 * ones(7,1);c2 * ones(7,1);c3 * ones(7,1)]]; y = [o1;o2;o3]; x = A \ y % Test c=15, T=12 o = x(1) + x(2) * 12 + x(3) * 15 % relative error e = abs((o- 9.09)/(9.09)) * 100 output x = 13.5221 2- 0.2012- 0.1049 o = 9.5334 e = 4.8774 Thus o 13 . 5221- . 2012 T- . 1049 c ....
View Full Document

Page1 / 10

HW 8 solutions - EGM3344 HW8 Solution Problem 14.3 y = a +...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online