HW9Solutions - MR—Qfi‘ue—af WE—Pf o __ gum...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MR—Qfi‘ue—af WE—Pf o __ gum WBfifiifigfi503%) 0 am; 363-32er 3203—4? .576 “.3307 o - 3&307 .79/6 iW/J o 1, (DC/L; «9W D, XY\€W:Xoki_ or )(Wew: Kold ‘ __ O‘Olgg new l. I; \I \I {/U W ‘ \‘ \E D. 699.7 — 0' 33417! O Q j: «o. 3374 0.758? 0.3745 0 ‘0.3745 0.0.;07 :7 41m AY: 0.0735 :> .0094 ‘ 1+€m+§04 3; 31er W‘Aefi: +AX 0-083 4. “0.0333 3 0. 00133 9.5%7 W333 000% %= 0.0% ’0. 0053 Mmlfiffly by /00 I +0 36+ perm/3+ ><=[l.794/L/ LEM mom] Show? 0.75:)! flaw; 7[2 6.136112% I>AXt \ggcoE-“i O @310; 0.776! $69397 HIE—4 MQWQV ’00 “50 391+ Peak/ff 11/7/08 10:02 AM C:\Documents and Settings\gtj223\Desktop...\nonlinearSolutions.m 1 of 1 function [x,error,dotF,iter] = nonlinearSolutions(fun,x0) tol = 50*eps, %Sma11 tolerance for convergence zeta = l; %Initializing error greater than tolerance iter = 0; while zeta > tol [f,J] = feva1(fun,x0); %Calcu1ating Jacobian and f deltaX = J\(—f)'; %Solving J*de1taX = f xnew ='x0 + deltaX'; %New x vector ' %Finds error ! for i = 1:1ength(x0) é error(i) = abs((xneW(i)—x0(i))/x0(i)); end 5 zeta = max(error); ' %The highest error iter = iter + 1; E x0 = xnew; end x=x0; dotF = f*f'; %Dot product 11/7/08 10:03 AM C:\Documents and Settings\gtj223\Desktop\Grad\Fall...\Jacobian.m function [f,J] = Jacobian(xguess) %Matlab can't create analytical solutions so this function will have to %change every time the set of nonlinear equations Changes. xguess(1); x2 = xguess(2); x3 X1 ll f(1) = f(2) = f(3) = 2*(x1-2)‘3 + 3*(x1—x2)‘3; 3*(x2-x1)*3 + (x2—x3)‘3; (x3—x2)‘3+4*(x3-1)*3; J = zeros(3,3); J(1,1) J(1,2) J(2,1) J(2,2) J(2,3) J(3,2) J(3,3) 6*(x1—2)“2 + 9*(x1—x2)‘2; -9*(x1—x2)‘2; -9*(x2—x1)*2; 9*(x2-x1)*2 + 3*(x2-x3)*2; —3*(x2—x3)‘2; -3*(x3—x2)*2; 3*(x3—x2)‘2 + 12*(x3-1)*2; xguess(3); 1 of 1 11/7/08 10:02 AM MATLAB Command Window 1 of 1 W >> x0 = [1.76 1.6 1.12]; >> [x,error,dotF,iter] = nonlinearSolutions('Jacobian',xO) x = 1.7454 1.5229 1.2021 error = O 0 0 dotF = 1. 6996e—032 iter >> 3. \/:a\2><}"l ><:[;2,5 5.5 5 e 7.5 /o /;\.5 15 /7.5 M y: [7 5.5 3315.6 3/ 2.2 9.6 :24 2.3 2.33] O i (W \AyFMQQ'M (7) +/n(35)1n(55> +/4(5)‘//)(3.9>+. . 9 :073115’ /0 zwzgmmg gap/L75 l /O 3r ’ :1 ypm f Yi) “k0” firearm > 02X 52 :(Q,Z8357)1+(5.l7-S.551 00‘ 3(01155 —- fJQDBS ., SM, n'El r: /O?}nx My “ W‘Xé: W) /O ‘ 02$ Z~[1A\‘Z (Ont—{OAK / I W0 x] /O/Z(l y) (28/) ’0 z . ‘ ‘ ‘ w e e + ' zwa’H-.+»e5 cafe. \‘KWO V\ XC P :7 WW...— r— 9 L ) :1‘176 /O{‘%X.L{S)-;ofl7fi52 ' //0(15.5cz)— M952 '61: 11/7/08 10:46 AM C:\Documents and Settings\gtj223\Desktop\Grad\Fall 08...\Power.m %Problem 3 Curve Analysis xdat = [2.5 3.5 5 6 7.5 10 12.5 15 17.5 20]; ydat = [7 5.5 3.9 3.6 3.1 2.8 2.6 2.4 2.3 2.3]; %Linear version for i = 1:1ength(xdat) xLNdat(i) = log(xdat(i)); yLNdat(i) = log(ydat(i)); end y_predict1 = —.5304.*xLNdat+ 2.3077; %Power version y_predict2 = 10.051*xdat.*(—.53o4); subplot(2,1,1), plot(xLNdat,y_predict1,'bo',xLNdat,yLNdat,‘r*') legend('Predicted Values','Actual Values',1) tit1e('Power Law Linearized’) x1abe1('ln(x)') ylabel('1n(y)’) subplot(2,1,2), plot(xdat,y_predict2,'bo',xdat,ydat,'r*') 1egend('Predicted Values','Actua1 Values',1) title(’Power Law') xlabe1('X data') ylabe1('Y data') 1 of 1 WY) Power Law Linearized ln(X) Power Law X data 0 ale Predicted Values I Actual Values Xi'LOf/ 0.2 1.; I,é 9.0 3.3] y: [750 mm Moi? 30w 37m 375g q; y:ab Rewri‘mi My}: Mia») + wa) y:mx+b r.) mlfnéb}:°\. ‘ bilmm): o O\\m‘ flZXZ “ZXZX‘ QEXMW)‘§X%M€W Q \' ‘ 2* 2__j 2. "‘ W A X ééxz‘ (2)92 2%: 8.3 L, 2 My): LIL/.503 :7 m: “$37560” 33 1503:. 0 END: Wk) .,#"~————*-iZQ;Efi:Wnb\ r: fl ny " :XZ \MZXZ ‘1fo hiya—(2y); 6 6 C» é E136; ‘K: Xi ‘ G : M<yjl—<: him/92 : 6(6 3.75%) ‘(5 W4. 503) (awowaaW : O‘HXX’ 11/7/08 11:27 AM C:\Documents and Settings\gtj223\Desktop\Grad\F...\Exponentia1.m 1 of 1 > W %Problem 4 Curve Analysis xdat = [0.4 0.8 1.2 1.6 2.0 2.3]; ydat = [750 1000 1400 2000 2700 3750]; %Linear version for i = 1:1ength(xdat) yLNdat(i) = log(ydat(i)); end y_predict1 = .8417.*xdat+ 6.2529; %Power version y_predict2 = 519.5*2.32.‘xdat; subplot(2,l,1), plot(xdat,y_predict1,'bo',xdat,yLNdat,‘r*') legend('Predicted Values','Actual Values',2) title('Exponential Linearized') xlabel('X Values') ylabel(‘ln(y)') subplot(2,1,2), plot(xdat,y_predict2,'bo',xdat,ydat,'r*') legend('Predicted Values',‘Actual Values',2) title(’Exponential') x1abel('X data‘) ylabel(‘Y data') Y data 0 Predicted Values ale Actual Values 'o.4 0.6 0.8 * I 0 Predicted Values ale Actual Values 0.4 0.6 0.8 Exponential Linearized 1.2 1.2 1 .4 X Values Exponential 1 .4 X data 1.6 1.6 1.8 1.8 2.2 2.2 2.4 2.4 ...
View Full Document

Page1 / 13

HW9Solutions - MR—Qfi‘ue—af WE—Pf o __ gum...

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

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