hmwk_2_solutions

hmwk_2_solutions - UNIVERSITY OF NOTRE DAL/IE Department of...

Info iconThis preview shows pages 1–15. 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

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

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

Unformatted text preview: UNIVERSITY OF NOTRE DAL/IE Department of Civil Engineering and Geological Sciences CE 30125 J.J. Westerink September 9, 2007 Due: September 15, 2007 Homework Set #2 Backgound: Many computational codes solving problems in mechanics, optimization, and/or forecasting will result in very large systems of algebraic equations of the form AX 2 B that need to be solved. Direct methods are available that rely on systematically re-arranging the equations into much more convenient forms that allow for straight forward solutions. The cost of the solution is a vital factor, for example Gauss elimination it cost 0(N3) operations where N is the size of the fully populated matrix. The largest portion of the computa- tional cost lies in manipulating the matrix. However, for many cases of interest we must solve systems of the form AX = B,- where the matrix stays the same and many right hand side load vectors must be solved. In this case, a formal decomposition of the matrix into a product of lower and upper triangular matrices can be performed once without operating on the right hand side vector. This then allows for the forward and backward solution sweeps to be applied to many right hand sides at a cost of 0(N2) . This dramatically reduces the cost of the solution. Problem 1 Solve the following system of linear equations by hand using LL? decomposition: 25x+3y+53+2u z 2 3x+ l7y+7z+5n 53 ll 5x+7y+232+8o 3 2x+ Syl- 82+29zt = [29 a) Check for diagonal dominance and symmetry and re-arrange the system if necesary. 2_ b) Perform the LLT decomposition. Keep track of your operation count. if c) Perform the forward and back-substitution steps necesary to solve the system. Keep track of the number of operations. Backgound: We want to ensure that ill-conditioning will not be a source of errors in our solution. Diagonal dominance ensures that it will not be a problem. However, often we want to examine the normalized determi- nant to establish the conditioning. This involves computing the determinant. However this can be done very inexpensively by using the product of the diagonal terms of the lower and upper triangular matrices whose product form the system matrix. This is an 0(N) cost operation. Problem 2 Demonstrate for the matrix in problem 1 that the determinant of matrix A can be computed as: J O N IA! = HIE.- i=l where in are the diagonal values of the upper triangular matrix obtained in the LLT factorization. Hint: Simply apply the forimtla given, and then compare this solution to that obtained from the method of expansion of cofactors. Compare the costs of these two methods. Backgound: Direct methods are still quite expensive, even when we apply clever matrix decomposition methods for a recurring right hand side and apply banded storage and solution schemes. However many system are very sparse, with only very few non-zero matrix entries. In this case indirect or iterative methods may be beneficial. For very sparse systems, these methods are at a cost of OM). This means that if you double the number of algebraic equations, you only double the cost of the solution. This is a great cost function compared to all the other methods that We have looked at! Furthermore, we can enhance stability or improve iterative convergence by combinations of the present and previous solutions (point relaxation or SOR methods). Problem 3 a) Apply the Gauss-Seidel method to solve the system of equations. I suggest that you write a Matlab code to do this. Solve this system using an absolute convergence criterion of e = 0.001 . Keep track of 33 the number of operations. 5.1-] +22:2 = 80 El ._. m :2: 2x1 + 5.1:2 + 21‘} 2x; + 5x3 + 211; = 120 2x3 + 5x4 + .‘ZxS = 120 I! ._. M c: 22¢:4 + 5x5 + 2x6 2x5 + 5x6 = 80 b) Apply the Gauss-Seidel method to solve the system of equations. I suggest that you write a Matlab code to do this. Solve this system using an absolute convergence criterion of e = 0.00] . Keep track of S the number of operations. Comment on how the cost compares to the case you solved in part (a) ~ i.e. what is the effect of doubling the number of equations? 5.7:i +2x1 = 80 2x1+5x2+2x3 = 120 2x2 + 5x3 + 21:, ll ._. lo :3 2x3 + 5x4 4— 2x5 = 120 ll 2x4 + 5x5 + 2x5 120 2x5 + 5.1:6 + 21'? 120 2xfi+533-9234:a = 120 217+5x5+2x9 = 120 2x3+5x9+2xm = 120 2xg+5xm+2xn 3 120 2xm+ 5x“ + 2x]2 = 120 2x“ + 5x], = so Ix.) Problem 4 Apply the Gauss-Seidel method with SOR (over and under) to solve the system of equations. Find the optimal relaxation factor that givas the quickest (and of course stable) convergence. Solve this system using an absolute convergence criterion of e = 0.001 . 1 suggest that you write a Matiab code to do this. 140 Comment on the optimal relaxation factor that you have found. 5x1 +212 = 80 2x1 +5x2+2x3 = 120 I! ._. to o 2.171 + it} + 2x4 2x5‘ + in; + 2x5 = 120 II _. Is.) o 2.11 + 5x5 + 2x5 2x5 + 5x5 = 80 am. 35502 CE 30/25 Sow/770x125 '/u Al W? I. @0811 m “r1 '- _._50Lv5 THE _ FOLLWWG 95mm 0!; _ Lin/Eflfl_ _EFCSZLJAVQNS 13>“ _#A~D_ USN/6’ LL" DEccam P?.$’I7'7.O..Ma'.. . _.. i i .. .. .2 $3 I. 3 . 127.. U! N J: x H H. II J! a) (#5:; For: DIHGDNfi'r-L _Domgwaéugs AND swan-19771)! AND IEErARPANGJ-Z 511576»; {F Nagasaxfi : I 2 ‘ :_ 5.3 3 ._ liq. " A __Mrr.z'lf_...:s _ umwmur. pom-1w _..an __ ;/c?,;.-/.3. .2 /4,;;/ .m. my .12 __ _ if“: : I 10 ?7 ZS, _l.5 > 17 7‘ 7—0 >13 , - , _ . .- ‘15 7 ‘2'? I. DIAGomAr—LK .DOmuauT flaw-i: 331-545; 1: 3+7+S_ s: 5.+7+.3V '1'}... 7--+¥5+9 1! H 11 ll ‘ A I‘M-rm" .. Ia. _stmsTmc ...!F Br INSEEFT’QN. ,. .cn; .=.‘.C_t‘,': . .. Sr mm..£.rr?.ur; . . 1:) PERFOIQr'v... WE .44 Mam wees/72941-, _..?Mczg... or... “ems-Air flu. «01. .pw ' q“ I, " in, 4 173: 9'1": q?! 3 £35 fig 7 031 .q‘n. 3333 am £1} . ' r ' q.u.___g.;L-.;qq3 41.... 7. _ «gas View” . .1 £1! +- 1?. - ' £2113: flag}: I . .. ff £1: 31 .. .1. ‘ I. 2 . V .. - “£11.43!” fizz Q'IL _2‘51 49:” .‘f!32flr1...+g35zgif§n . nee: +flw. ‘33.: 002M701; . . I g; Q” =_ J3: 3st '=.S...._ . " 3/5 I-f" =1 £2177 = 611/111: 3/5 = z—Nééf .13; : Rel/9.1% 5/5. "= 1 3+lfi‘l ' 1H). fu11l.=.:aHI/fiuil= 2/5 Vs ll CE 30(25 #ww-“z gowr/mus 2/tl [jIZUBLE-M #1 (chfi) f ‘ ' :I I I 9’ ' 1 V. ( £2; "(0111- In 1 = 7+3I=ml __ Q is: a. (6132* LIED/fa; == (7—_(%’)(n))/{q.o?m) = I. 56393 raw—#3 ' .7) 2931' é..(9.qz_—fiu!«.)/flu ¥—~_(s'—(%X%))/(Wezz) =2. We 89 ms =13... .3) £335.... (nag—13,: .31)Eaéar(.03:.(1:56_&?3))%:¢ .‘HZOZS: 1 IV+S=ZS I . £13.? “(t-3“?;.£?-a.1'f.rif'.flfifflit)fl33F"6;.hxgé)m("$.éqjxr'Jigsawflfléofl)if; 7'30 5/? : ..:.. I...1 I .. ' ‘ . : g/l.. 13:47:50. 19 12” = (qw— 1%,. 4n —.£f;)"?=(zw—.(%)~(L1rgcan—.(:.2asn)1)._ =.._.5.-0176_39 “ . .7 '_'_= 75' 3'0 .. 0 H 7' " "W‘ff/VQ'art ifléfiaé "fl'céuééuzéb . goorzfmws" - 3/5 $077z2 c9. 0. 7791's!“ -, T. ' i 1 1.56393 9.92023 - o - ; 9.3. - __ __ 3/5 .L/Lm Mosh _ 5.07639 3 = $501.09 _ .- G) HIPS-IEFéR-W- I MD QACKI.'.5.U"~3-5I7"+Qfi9':‘4.I..§I7;EFS .' M51659“? 7r: Scat/E- we $YSTSm.... KEEP...7?€4<¢ .OF ..0FE@'.4.77"’V5r .. ' /_ _ gJ§=§ m w H_HH é r? 5 D Sou”: F03 ‘1 “Emma” ' . Ff) SOLVE F045 “szzwfiauv_ - x ' "3)" 9'" illquéfly- an". 23%.} % é/sn . ’92: Y; + A’qu :81 ‘5’- .YL =...(Baf‘£;-.Y,)/flzz 1.2.3333 . I Q a) 1239!. +J31Y1*155Y3=.B3 => Yg=.(?>3—15,‘f.Eggsz’gs 2(a?hi%)'693m=JflZ.-1=3))/fi92023 _ 5 = - _ _ :ffiiOQZSEHj _ '1') fl‘let‘JthL4 Rays *1?qu “‘3? w Y?" (grimy. "pvzh'flwYQ/qu . .7 It, «spam-mp5 - I . r ‘ =('2?-(3§I%)—(MLCE?MZ?33®'Q.3651’?%%UOE§6)%_07€8‘1 _ _ , -=.,.23:H5‘I , , g ,. ' _ IT). . 5) «out: qu Y9 XIII: Iu-j = BREW/5.07639 3 .iL/Irfii‘SS-Z. . . . H H . 6) 133x; +11.ng =y3- :?.X3'% 3': ?-=..G;—. my!” FEW-erase»(rsbsqélw-me/mézs. . $1):le ‘f 131 X5 "7. Pfizyti Y2. :(Yz '"igsi.).(5'-—flq13(q)fla; . . ' , . , . i . .j . . #flmzsa {Based—Laws)vQ,/csa®f%_€!53?34mn Em. 35502 CE 30/2 5 Ala/#1 50 a. arm/us % ERoISLEr-z 471 (Cam, -?)’er)6+!érxz+fl31)é*j‘H/V¥ =){ => XI: x-fibll "'IUXa "gJé‘flH’K’J/jw , .. 7. 7 7 7 j{$5rMUWs)—GK'z-z.¢¢1iflr@Xa-@s$§l/5 l6 apart/mow _. : .. .. _=..'O,{G_23_06 . .. . ' I = ——'o.i62306 - 7 . ‘ . .. 2.71275 ; {‘32 éFfi'MTW’US” Fem. Sussrrwow . 4.259% 7 . . . , ‘ ,, a. .. .. u 4. 615?; ..—+‘.‘.-30_ warwmrvs” FM Descamawnon/ ._ is: OFEMTWE’ , 727mg) . u n 11 TEEM. 35502 65 30/25 Hw $2 SOLUT/O/US Panama it 2 Dan anus-rp ATE Fdrl 174-5 . MATRIX nu PmafiLEfl‘l _ 1 71m?" 77!: DETERMIMAUT _ Df__ {4,4le A CAN GE Com Furs» AS I 1 IA! 2 N is? =f I ' f WHERE git-.1 fizz THE Iémpowr....VALUES..qF....TH€_....Ur?.EEK.. TRIANGUMK (“Imam . asmweo. w THE.LLTLFACT¢'R[2fiTIQML ' ' ' ' ' _ .I.. . .. ..n_.: f ‘1'. . ...m..mf. .. I. 5L ;. :‘. I .gL . I:i.g.f; .."..'” -H.:-.:”.. 50. (Al‘ fixf ..= (isx‘ifl'lwfiflflzoaaXSflTQ‘M) ==_ zoqqqg‘_ p.00? _ I=I_ . _; _ at $19,453 +‘3fiuLTIP‘Lf'CAsz-JS = 7._mpgmfia~5-I f—bo.’ I @ Mam roam lawman; ; __ _ M: ..'zsgmamamay—7L67xayswxs31+15mm—erocsj} 1 i " '3' {—7- [(sjci.§¥)g-=(é){i)fl +SB9® {129531 ijzé)}r®®]}... . i. i ' 3.:[F7X2'541SXQJ ~I7Esx?a)*axaj‘fiqsfisxs)(2)601} _ f " ' ' H 42 is flame-(613)]473%)[email protected] 459634110]; ' W: 20979? - ° ' ‘ ' may ME . Maw-ML! I 553? .Il/..:’V%$_PECTION../WE.‘lrfiéflégj;7”.0“? fits _.lbméwaguuvéuuég _ ‘ 5‘61 UAIEED 15. “towing/4AM . mass ../.~.V.a:_ve-_7).. Wm! WE ' fiEWD go}? .QUFACTDE .EK..PHNSIDA/. ' - = MSW!) 0F comma; apart/51.5w .: . .0 (It/)3 opera H—T’WUS: i - r 7 _~. C(69) ' = - ' L90 muurmucarran/s . ' 3 - _ 2% ADDITmMé/sv 5111:4070”; ' - _ - (,3 .OPEILAWOAJS - . ' OpfiafiTIUh-I_ _ ‘ _ i . = . . _ .12A1—@*:-_' f. @fim 35502 65 20/25 /-/!4/ #2 SOL 07702125 PrzosLEm 113 "3?) XML" THE GAVSS' gEIDEL NEWC’D TU SOLVE. 'T'r’iE S‘a’STEfl'} 0F gammy; Sow: ms. sfismm .m. ‘fl bm-rs 0.F....P£:.cr.sra~. k’m man ???we‘ mammals: 5'0 (2'? izo l 20 (20 8'0 575; "' 2752 . .Z'Jo. + 5762+ 19K? 1761* 5215+ 7.75., .17Cg~+_5 76;,4‘ 2%5...._. . I 11/41 ’1'. 5-295 + "27654-5745. _u n .n 'u'”n . if?“ 0F . ./7'EW/Ms x [Z _ .' :Ifi'ToF, éé'£¢#%:qka"pggké. Imp—Ariana" 7'3"; -1_ ' f 'éflMT/WSIT 93¢ 735502 ' 9/14/10 12:24 PM C:\Users\chluser\Desktop\Courses\CE30125 C...\HW2PSatest F10.m CE 30125 Computational Methods HW #2, Problem 3a By Corbitt Kerr % % Fall 2010 % clc; clear all; % Input A = [5,2,0,0,0,0; 2r5r21010r0; 0,2,5,2,D,0; D,0,2,5,2,0; O,U,0,2,5,2; 0,0,D,U,2,5}I B = [80,120,120,120,l20,BO]; cf = 0.001; % Convergence Factor n = size(A,l); % Matrix Dimensions % _ _ — — — — — — — — — — — — — w H _ w _ m _ u a u u _ h _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ — — — — — — _ _ _ _ _ _ _ _ _ _ _ _ _ _ — — — — — — — — — .—.—.. % GAUSS-SEIDEL METHOD 95 _ H m m n w w n m _ m _ _ u u u u u m _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ H m m _ ........ K = zeros(n,2); iter = O; Nops = D; % Guess Initial Values % Iteration Counter % Operation Counter maxdiff = of + l; % Assign an initial difference while maxdiff >= cf iter = iter + l; % Process until Convergence Factor met % Record Iterations n % Loop through Matrix Rows % % for i =‘1: SI = 0; Reset Xk sums 52 m 0; Reset Xk+l sums for j a 1:i~1 % Loop through st 81 = 51 + A(i,j)*K(j,iter+l); Nops = Nops + 2; end for j w i+l:n % Loop through Xk+ls S2 = S2 + A(i,j)*K(j,iter); Nope = Nops + 2; % Increase Operation Count end K(i,iter+l)={—Sl-SZ+E(i))/A{i,i); Nops = Nops + 3; end maxdiff = end % Increase Operation Count maxtabs{K(:,iter+1)—K(:,iter))); %Compute Max Difference disp('Number of Gauss Iterations:') disp(iter} disp('Number of Operations:') disptNops} disp(‘Solution for X:') disp(K(:,iter)) l of 1 6/" 0:: 30/2 5 6’ W f2. sown-am /9réoa:.5m 3* 3 (C007; b)" /4PP<V m: 4&05145505; Iva-734542. .39 MS. W. 5mm 0F ,MWWM. 5w: w ‘r’ 01w: 2 9.2.5.. flv€:€9/SIOM.U_/é’££r mm at? T? 93‘ Wamw». gunman/7'” PW WW 57315? é‘osrrccm'rr flees? .571; ms beg: 24w sow‘éfio. 24/ Prime:- g), WWW. «F 5595;?" 0F fougéxMGgJW£IV9¢15F¥ .w".zzfifi.{rraa47?un/JL ._ : 13%” hazy/w? =(Z - < a. .. _ n _ 7 _ #6"? .0 Pfimrrw__ (95.42.. rrfiwfiw =_ 3.00 360.0;_.TOTAL (ammwws’ $.61: friflflffl’flfi rs g/mrzm’ I45 msmccwfizesswa ,CR/rEfl/4 .pgmmses/ m 54% 0" ; fif€£47l¢fl§.. Mu, PRO—ma WE 5mg. FM. Two MAWKiS). .. .. . _ I'm/m :56»: 0F _ OFEKAT/UNS ,- WMEVEL; '51: i '1‘ . . “105.12.; aware/47.7041... 7145,; Mamm ....Wa’r7f . .."ls_ Wm; .45 leqgufl ‘ : - i i @935. 355132 9/14/10 2:18 PM C:\Users\chluser\Desktop\Courses\CE30125 Comp M...\HW2P3b F10.m % CE 30125 Computational Methods % Fall 2010 % HW #2, Problem 3b % By Corbitt Kerr clc; clear all; % Input A = zeros(12); for i = 2:11 A(i,i-1}e2; A(i,i):5; A(i,i+1):2; B(i)=120; end; A(1,1:2)=[5,2]; A(12,ll:12)={2,5]; B([1,12])=BG; of = 0.001; % Convergence Factor n = size(A,1); % Matrix Dimensions % ________________________________________________________________________ ._.._. % GAUSS-SEIDEL METHOD % ———————————————————————————————————————————————————————————————————————— m... K = zeros(n,2); % Guess Initial Values iter = 0; % Iteration Counter Nops = 0; % Operation Counter maxdiff = of + 1; % Assign an initial difference while maxdiff >= of % Process until Convergence Factor met iter = iter + 1; % Record Iterations for i = 1:n % Loop through Matrix Rows Sl — 0; % Reset Xk sums 82 — 0; % Reset Xk+l sums for j = lzi—l % Loop through st ' "31 + A(i,j)*K(j,iter+l); Nope = Nope + 2; end for j i+lzn % Loop through Xk+ls 52 = 32 + A(i,j}*K(j,iter); n Nope = Nope + 2; 5 Increase Operation Count end K(i,iter+l}=(HSI-SZ+E{i))/A(i,i); o Nops w Nops + 3; 6 Increase Operation Count to H II end maxdiff 2 max(abs(K(:,iter+l}—K(:,iter)));I%Compute Max Difference end disp{'Number of Gauss Iterationsz'} disp{iter} disp('Number of Operations:') disp(Nops) dispt'Solution for X:') disp(K{:,iter)) CE 30125 29W #5 SOKUWOIUS j’fi P80 him #‘I 249va THE Gmasvfiama. mama 'WITH 50}? w SDLVE m5 S‘fsrsm ar: Eaufl‘r'rdm'j‘ .Fmp WE. OPQML. .aétfixm‘rw FflCTOR 7W?- CrMs: W wemsflmcmwflm STAng) CONVERGENCE, @mrfltrv7'_ ON 7345. OFF/ML {egmxi-r/wu ‘FMTOQ _7ZI47' kw (Imus FOUND, ' ' ' _ 3.76. in 1.961 .. .. g. = '84? ..7—- 3.5. ‘1' 57511., ‘\’ = {10" (2.0.. .. no $0 2761+ 3 76+; 492755 , - ' ' .LWq 7* 335% + .2455 . 1155...??33‘a H H Upwmm ,1??- ALJ L21, L21 .;. 7&3 ;.OF llfifzflTv-‘Ufi’sr'é‘g : . ._€mmms ..iC’ws_s sampl“: i“";%é2“.fi~a4>s” "é‘ka'w—"I ' . €EL4MAT10~ .. Ham 0!: [.23 IS :Sfm’wflf" T9 -W-E " . . . .. G-AUS_§_._-€€ib£b. UAW-E4 WT ’5 9"" 7 “5 'O'VM’MWWW . SIDE, THEREIEME. . FF, 1.5 96 £815,491“ WNVEZQEW. .. .. .‘,.F99¢€$5.MH.W - ‘ ' - gym. 35502 9/14/10 2:27 PM C:\Users\chluser\Desktop\Courses\CE30125 Com...\HW2P4test F10.m l of 2 % CE 30125 Computational Methods % Fall 2010 % HW #2, Problem 4 % By Corbitt Kerr clc; clear all; % Input A = [ - I I I ‘. - ‘. F 0 0 2r 5 2 .. I‘- f I -. ODDNU’I OONU’IM ~ DNU‘INO .. u. I -. LTINCJOCI -. MDOOO flirt; 0,0:0rorzr51F B [80,120,l20,120,120,80]; Cf = 0.00l; n = size(A,l); H % _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ — _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ — _ — — — — _ _ _ w m m m u u u H fl _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __. %Convergenoe Factor % SUCCESSIVE UNDER/OVER RELATION METHOD 8- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ w m m m m m n m u fl H _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ opt = zeros{199,2); mr= 0; for lambda = 0.01:0.01:l.99 K = zeros(n,2); m = m + l; iter = 0; Nops = 0; maxdiff = of + 1; while maxdiff >= cf iter iter + l; for i lzn 51 = O; 52 = O; for j = l:i—l LmdePdedeOdePm’JdeO C’PD’P UV] Declare SOR Perforance Array Lambda Integer Count First:Step:Last Guess Initial Values Lambda Integer Count : Lambda * 100 AL 1f .11 1? of Iterations of Operations Assign an initial difference Process until Convergence Factor met Record-Iterations Loop through Matrix Rows Reset Xk sums Reset Xk+l sums Loop through st 31 = 31 + A{i,j)*K(j,iter-§-l); Nops = Nops + 2; end for j = i+l:n end % Loop through Xk+ls 32 = 32 + A(i,j)*K(j,iter); Nops = Nops + 2;% Increase Operation Count K(i,iter+l)w(-51«SZ+E(i))/A(i,i); Increase Operation Count K(i,iter+l)wlambda*K(i,iter+l)+(l—lambda)*K{i,iter); Nops = Nops + 3; end maxdiff = max(abs(K(:,iter+l)—K(:,iter})); end opt(m,:) = ilambda,iter]; end SOR = sortrows(opt,2); disp('0ptimum SOR Lambda:') disp(SOR(l.l)): % n ‘E %Compute Max Difference Record SOR Performance ll/l! 9/14/10 2:27 PM C:\Users\Chluser\Desktop\Courses\CE30125 Com...\HW2P4test F10.m 2 of 2 disp('Number of Iterations') disp{SOR{l,2}}; semilogy(opt(:,l),opt(:,2), 'LineWidth', 2) title{'The Effect of Relaxation Factor on No. of Iterations‘); xlabel('Relaxation Factor'); ylabelt'No. of Iterations‘); xlim([0 2]) grid on: No. of Iterations 10 10 ..L O 10 M 0.2 0.4 The Effect of Relaxation Factor on No. of Iterations 0.6 0.8 1 1.2 1.4 Relaxation Factor 1.6 1.8 ...
View Full Document

This note was uploaded on 03/02/2012 for the course CE 30125 taught by Professor Westerink,j during the Fall '08 term at Notre Dame.

Page1 / 15

hmwk_2_solutions - UNIVERSITY OF NOTRE DAL/IE Department of...

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

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