ࡱ> -/,M bjbj== "FWWl0DT0 %xPPPPPPP$$$$$$$$& (L$PPPPP$"PP$"""PPP$"P$""V$V$Pl t00V$V$4$0 %V$C)"C)V$"00EGR 511 NUMERICAL METHODS _______________________ LAST NAME, FIRST Problem set #2 1. Use Newtons method with x(0) = 0 to compute x(2) for each of the following nonlinear systems: a. 4 EMBED Equation.3 - 20x1 +  EMBED Equation.3  EMBED Equation.3 + 8 = 0 b. sin(4(x1x2) 2x2 x1 = 0  EMBED Equation.3 x1 EMBED Equation.3  + 2x1 5x2 + 8 = 0  EMBED Equation.3 ( EMBED Equation.3 - e) + 4e EMBED Equation.3  - 2ex1 = 0 >> s2p1a x = 0.4958936 1.9834235 >> s2p1b x = -0.5131616 -0.0183762 2. Use the method of Steepest Descent with x(0) = 0 to approximate the solutions for 4 EMBED Equation.3 - 20x1 +  EMBED Equation.3  EMBED Equation.3 + 8 = 0  EMBED Equation.3 x1 EMBED Equation.3  + 2x1 5x2 + 8 = 0 Iterating until g =  EMBED Equation.3 < 0.05 % Steepest Descent Method % Set 2, problem 2 % f1='4*x(1)^2-20*x(1)+.25*x(2)^2+8'; f2='.5*x(1)*x(2)^2+2*x(1)-5*x(2)+8'; % Initial guess % x=[0 0]; f=[eval(f1) eval(f2)]; g1=f*f'; for i=1:50 Jt=[8*x(1)-20 .5*x(2) .5*x(2)^2+2 x(1)*x(2)-5]; % Gradient vector % delg=2*Jt*f'; zo=sqrt(delg'*delg); % Unit vector in the steepest descent % z=delg/zo; xs=x;a3=1;x=x-a3*z'; f=[eval(f1) eval(f2)]; g3=f*f'; while g3>g1 a3=a3/2; x=xs-a3*z'; f=[eval(f1) eval(f2)]; g3=f*f'; end a2=a3/2;x=xs-a2*z'; fsave3=f; f=[eval(f1) eval(f2)]; g2=f*f';h1=(g2-g1)/a2;h2=(g3-g2)/(a3-a2);h3=(h2-h1)/a3; % Choose a0 so that g will be minimum in z direction % a0=.5*(a2-h1/h3); x=xs-a0*z'; f=[eval(f1) eval(f2)]; g0=f*f';fsave0=f; if g0> s2p2 x = 0.398351 0.059753 , g = 72.674085 x = 0.688581 1.141483 , g = 29.558308 x = 0.423584 1.273358 , g = 8.398065 x = 0.490600 1.353318 , g = 7.249389 x = 0.409879 1.479892 , g = 4.538019 x = 0.459636 1.495889 , g = 3.863304 x = 0.545482 1.830068 , g = 1.507642 x = 0.481841 1.859146 , g = 0.275003 x = 0.490227 1.865165 , g = 0.258094 x = 0.487611 1.973402 , g = 0.033052 2.b Use the method of Steepest Descent with x(0) = 0 to approximate the solutions for sin(4(x1x2) 2x2 x1 = 0  EMBED Equation.3 ( EMBED Equation.3 - e) + 4e EMBED Equation.3  - 2ex1 = 0 Iterating until g =  EMBED Equation.3 < 0.05 % Steepest Descent Method % Set 2, problem 2b % f1='sin(4*pi*x(1)*x(2))-2*x(2)-x(1)'; f2='(1-.25/pi)*(exp(2*x(1))-e)+4*e*x(2)^2-2*e*x(1)'; e=exp(1); % Initial guess % x=[0 0]; f=[eval(f1) eval(f2)]; g1=f*f'; for i=1:50 con=4*pi*cos(4*pi*x(1)*x(2)); Jt=[x(2)*con-1 x(1)*con-2 (2-.5/pi)*exp(2*x(1))-2*e 8*e*x(2)]'; % Gradient vector % delg=2*Jt*f'; zo=sqrt(delg'*delg); % Unit vector in the steepest descent % z=delg/zo; xs=x;a3=1;x=x-a3*z'; f=[eval(f1) eval(f2)]; g3=f*f'; while g3>g1 a3=a3/2; x=xs-a3*z'; f=[eval(f1) eval(f2)]; g3=f*f'; end a2=a3/2;x=xs-a2*z'; fsave3=f; f=[eval(f1) eval(f2)]; g2=f*f';h1=(g2-g1)/a2;h2=(g3-g2)/(a3-a2);h3=(h2-h1)/a3; % Choose a0 so that g will be minimum in z direction % a0=.5*(a2-h1/h3); x=xs-a0*z'; f=[eval(f1) eval(f2)]; g0=f*f';fsave0=f; if g0> s2p2b x = -0.357926 0.000000 , g = 0.139390 x = -0.361009 0.057884 , g = 0.003316 3. Find the directional derivative of f(x, y) = 2x2 + y2 at x = 2 and y = 2 in the direction of h = 3i + 2j. Ans: 8.875 4. Find the gradient vector and Hessian matrix for each of the following functions: a) f(x, y) = 2xy2 + 3exy b) f(x, y, z) = x2 + y2 + 2z2 c) f(x, y) = ln(x2 + 2xy + 3y2) Ans: (a) (f =  EMBED Equation.3 , H =  EMBED Equation.3  (b) (f =  EMBED Equation.3 , H =  EMBED Equation.3  (c) (f =  EMBED Equation.3  EMBED Equation.3 , H =  EMBED Equation.3  EMBED Equation.3  5. a) Find the first two iterations of the Gauss-Seidel method for the following linear system using x(0) = 0; i) 3x1 - x2 + x3 = 1, ii) 10x1 - x2 = 9, 3x1 + 6x2 + 2x3 = 0, - x1 + 10x2 - 2x3 = 7, 3x1 + 3x2 + 7x3 = 4. - 2x2 + 10x3 = 6. b) Repeat Exercise (a) using the SOR method with relaxation factor = 1.1. Gauss Seidel 0.1111111 -0.2222222 0.6190476 Gauss Seidel 0.9790000 0.9495000 0.7899000 SOR method 0.0541008 -0.2115435 0.6477159 SOR method 0.9876790 0.9784934 0.7899328 6. Solve the system x2 + y2 + z2 = 9, xyz = 1, x + y - z2 = 0 by Newton's method to obtain the solution near (2.5, 0.2, 1.6). % Newton Method % f1='x(1)^2+x(2)^2+x(3)^2-9'; f2='x(1)*x(2)*x(3)-1'; f3='x(1)+x(2)-x(3)^2'; % Initial guess % x=[2.5 0.2 1.6]; for i=1:20 f=[eval(f1) eval(f2) eval(f3)]; Ja=[2*x(1) 2*x(2) 2*x(3) x(2)*x(3) x(1)*x(3) x(1)*x(2) 1 1 -2*x(3)]; % dx=Ja\f'; x=x-dx'; if max(abs(dx))<.00001, break, end end fprintf('Number of iteration = %g\n',i) fprintf('x = '); fprintf(' %10.7f %10.7f %10.7f\n',x(1),x(2),x(3)) Number of iteration = 3 x = 2.4913757 0.2427459 1.6535179 7. (P. 14.3 Chapra) Given: f(x, y) = 2xy + 1.5y 1.25x2 2y2 Construct and solve a system of linear algebraic equations that maximizes f(x, y). Note that this is done be setting the partial derivatives of f with respect to both x and y to zero. Ans: x = 0.5, y = 0.625 8. (P. 14.4 Chapra) (a) Start with an initial guess of x = 1 and y = 1 and apply two applications of the steepest ascent method to the following function f(x, y) = 2xy + 1.5y 1.25x2 2y2 (b) Construct a plot from the results of (a) showing the path of the search. Ans: x(2) = 0.543, y(2) = 0.657 9. (P. 14.7 Chapra) Perform one iteration of the optimal gradient steepest descent method to locate the minimum of f(x, y) = 7x + 1.25x2 + 11y + 2y2 2xy using initial guesses x = 0 and y = 0. Ans: x(1) = 1.3013, y(1) = ( 2.0448 O67JKLMRSVWjkln jNEHU jwEHUj+< CJUVmHnHu jp jEHUj+< CJUVmHnHu jEHUj+< CJUVmHnHuH* jEHUj+< CJUVmHnHu jUH*5OJQJ6O2LMVrs|G9IK hH!@dh P!dh$a$|d]|   )*=>?@FGM %&')<=>x jEHU jEHUj+< CJUVmHnHu jEHUj+< CJUVmHnHuH*5\ j EHUj+< CJUVmHnHu j" EHUjW,< CJUVmHnHu j EHUj7,< CJUVmHnHu jUH*/>?HI\]^_`abuvwx}~   # $ N O P Q R S Y Z ^ _ f g z { | } ~  jW,< CJUVmHnHu j EHUj7,< CJUVmHnHu jpH*5 jEHUj/< CJUVmHnHu j(EHUj+< CJUVmHnHuH* jQEHUj+< CJUVmHnHu jU3KTkt  $ 9 P Y e p ~  H J \ \ h  % @ F J K L M U ~ " K t  G H d e #%K>PR`u hH!@dh +-]^bc  $%)*/0CDOPSW]^_bcvwxy{| 56\] j!EHUjAA CJUVaJ6] j5\H*5 jEHUj/< CJUVmHnHuH* jEHUj+< CJUVmHnHu jU jEHU<&*>H_7<UYg*+1RSY hP!@@0]0 hP!@@ hp P!@@ hH!@dh   ()*,?y jI0EHUjA CJUVaJ j-EHUjA CJUVaJ j+EHUjRA CJUVaJ jp)EHUjlA CJUVaJ 56\] j('EHUjA CJUVaJ6] j jS$EHUjA CJUVaJ jU,?@ABCE*+12NOQghlmrs  fghOJQJ6]CJOJPJQJ^JPJCJH*H*5 jU j2EHUj_A CJUVaJN9:MNcez  h8$ P!@@dh hp P!@@ ) hp xHd4!@@@@^ ) p \ xHd4!@@@h^h "9IK\g hH!@dh  hp P!@@  h8$ P!@@  h8$ P!@@dh'+Sd$ hH!@dha$  hH!@ hH!@dh hH!@dhhiklm&'01 #H*5\PJ6CJOJPJQJ]^JCJOJPJQJ^J5CJOJPJQJ\^J6OJQJ]OJQJ6]K 4 hp P!@@^ hH!@dh hH!@dhCJOJPJQJ^J j-H*6] 1h/ =!"#$%Dd@B  S A? 2:ແ1:(Dy`!ແ1:(t hxP AQ=3(%6ւxEy ;{dS|r[̜{tf`a_R"öJXHbc"m(ar,r|bpQf**BAT24~qr- :xFp&u(Wa>݆ %i]G5l`Su2`"~43/pۜt+ !+;9,y T&WCfWbn]axx8/Dd@B  S A? 2:+vOwiCFNiy`!+vOwiCFNit hxP a=bL(Ev6^ļ,X n£x{eWs: sDM1S"'I>u2`"^WB X.ʹ*VZiSM+]&]俹9^$j>=P NWzbESBo6訂VTu2`"=?@ABCEDFGHJIKMLabOPQRSTUVWXYZ[\]^_`cefghijklmnopqrstuvwxRoot EntryP FbI00Data $5WordDocumentO"FObjectPoolRݬ0bI0_1017064324F E0 E0Ole CompObjfObjInfo "%(+,/234569<?BEHKNQTUX[\]^_abcdefhijkm FMicrosoft Equation 3.0 DS Equation Equation.39q kIvI x 12 FMicrosoft Equation 3.0 DS Equation Equation.39qEquation Native <_1017064351 F5P05P0Ole CompObj fObjInfo Equation Native  8_1017064358 Fp0p0Ole  ԠIPmI 14 FMicrosoft Equation 3.0 DS Equation Equation.39q I8I x 22CompObj fObjInfo Equation Native <_1017064442F2d02d0Ole CompObjfObjInfoEquation Native 8 FMicrosoft Equation 3.0 DS Equation Equation.39qkIvI 12I FMicrosoft Equation 3.0 DS Equation Equation.39q_1017064503FP#~0P#~0Ole CompObjfObjInfoEquation Native H_10170645351Fш0ш0Ole CompObj f,ԠIPmI 4"14 FMicrosoft Equation 3.0 DS Equation Equation.39q,|II e 2x 1ObjInfo!Equation Native H_1017130776$FЧ0Ч0Ole   FMicrosoft Equation 3.0 DS Equation Equation.39q7@kIvI f i2i=1n " FMicrosoft Equation 3.0 DS EqCompObj#%!fObjInfo&#Equation Native $\_1104331841",)FP¢0P¢0Ole &CompObj(*'fObjInfo+)Equation Native *uation Equation.39q 2y 2 +3ye xy 4xy+3xe xy [] FMicrosoft Equation 3.0 DS Equation Equation.39q_1104331908.Fp0p0Ole -CompObj-/.fObjInfo009( 3y 2 e xy 4y+3y 2 e xy +3e xy 4y+3y 2 e xy +3e xy 4x+3x 2 e xy []Equation Native 1U_1104332033'@3F00Ole 7CompObj248f FMicrosoft Equation 3.0 DS Equation Equation.39q? 3 2x2y4z[] FMicrosoft Equation 3.0 DS Equation Equation.39qObjInfo5:Equation Native ;[_11051692608Fƭ0ƭ0Ole =CompObj79>fObjInfo:@Equation Native As_1104332114=F4040WȨ, 200020004[] FMicrosoft Equation 3.0 DS Equation Equation.39qQhl 1x 2 Ole CCompObj<>DfObjInfo?FEquation Native Gm+2xy+3y 2 FMicrosoft Equation 3.0 DS Equation Equation.39qM( 2x+2y2x+6y[]_1104332194;JBF`\0`\0Ole ICompObjACJfObjInfoDLEquation Native Mi_1104332291GF 0 0Ole OCompObjFHPf FMicrosoft Equation 3.0 DS Equation Equation.39qnhl 1x 2 +2xy+3y 2 () 2 FMicrosoft Equation 3.0 DS EqObjInfoIREquation Native S_1104332383E6LF?0`0Ole VCompObjKMWfObjInfoNYEquation Native Za1TabledC)uation Equation.39qE "2x 2 +2y 2 "4xy"2x 2 "6y 2 "12xy"2x 2 "6y 2 "12xy2x 2 "18y 2 "12xy[]̜{tf`a_R"öJXHbc"m(ar,r|bpQf**BAT24~qr- :xFp&u(Wa>݆ %i]G5l`Su2`"~43/pۜt+ !+;9,y T&WCfWbn]axx8/Dd@B   S A?  2:+vOwiCFNily`!+vOwiCFNit hxP a=bL(Ev6^ļ,X n£x{eWs: sDM1S"'I>u2`"F0# ~[3d++&1]1jIypCA|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zj4hIK=~ESummaryInformation(Q`DocumentSummaryInformation8g$CompObjljOh+'0  4 @ L Xdlt|2ss tknguyen kngkng Normal.dot tknguyent4ngMicrosoft Word 9.0@Pw=@UuO@tN@B60{՜.+,0 hp  Cal Poly Pomona* b 2 Title  FMicrosoft Word Document MSWordDocWord.Document.89q i8@8 NormalCJ_HaJmH sH tH <A@< Default Paragraph Font4O4 time$dha$ OJQJaJ<Z@< Plain TextCJOJQJ^JaJFO2LMVrs|G9IKTkt$9PYep~HJ\h %@FJKLMU~"KtG H d e  # % K  > P R ` u   & * > H _    7 < U Y g *+1RSY9:MNcez "9IK\g'+Sd 400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000@0@0@0@0@00000000000000000000000000000000000000000000000@0@0@0@000@0@0@0@0000@0@0@0@0@0@0@0@000@0@0000> ?h "K\ !6JLVjlm )=?%'(<>H\^auwf z | ~ bvx  (*+?A::::::::::::::::::::::::::PQW[`dxy"$&<@EIkotx  R V Y [ ` b c g h l n r    K O T X $ > B [ b g n ?ASV`ajnsw|+2MQSZdk,2PUVWv{|}_aKLTUkmtw$&9:PRY^girsJL\]hi %'@BFIPTUV~"#KLtu  I L % ' K M ! % R V ` b     & ) * , > D H I _ a     $ 7 ; > B U X Y Z g n QS56^_'fh  "$KL\_gh'*+2SZdkfh<I3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333tknguyenPC:\Documents and Settings\tknguyen\Desktop\swim2001\egr511\homework\set2-s03.doctknguyendC:\Documents and Settings\tknguyen\Application Data\Microsoft\Word\AutoRecovery save of set2-s03.asd @[@UnknownG: Times New Roman5Symbol3& : Arial3TimesG MS Mincho-3 fgY New YorkTimes New Roman?5 z Courier New"qhbqq&hq{ *!20b2Q2tknguyentknguyen