{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

m304hw2sol - MAT/UM Ffimzzw ’7 ’7 2 Gr 22 M jog/L G M...

Info iconThis preview shows pages 1–14. 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 Document Right 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 Document Right 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 Document Right 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 Document Right 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 Document Right 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 Document Right 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 Document Right Arrow Icon
Background image of page 14
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MAT/UM Ffimzzw ’7 ’7 2 Gr: .. 22 _ M jog/L G _ M , _/. Q 2 , E 00!]. .200! W: 0110 _.0/0/._ _ , 0’ Zfl a ,0 0 0/. _ 0 m I“ 1/ g m , 9.4 3; of, L x._ 92.,wa 2 //,_ (0,, . .Qi {do [/lp ‘—? Q::/2+2,7 > ’3’1'97‘22 Z 3 0 l0 0 0 9- 3 ~2. I 0‘ 0 0 2 0 ~21 I 0 0 2 3 0 Al: —1 I 0 0 2. 3‘, 0.-2 I 0 0 2 WW L; UL /.[/9) jo/vz fl/legl I I) POM/A RD m &E I. 9:19 / I ['“IFIIOI II0>’<;==4 I/I>’<‘3 6. ,4/2/2 {y/flj 7/0/war/ faéJ/I'I’a/rm j?! a 0/ 2?; 24' / % =1 0 -2 I x3 F’E’W WWW WM BM WWW MA le‘f/ 22“): Q =2 X3=// erzz—g/ X/gl ”7-7[f/e /o/ affa) ' lu_factor.m 3/18/10 4:35 PM function [L,U] = 1u-factor(A) [n,n1] = sizeCA); if n ~= n1 errorC'A must be square'); end L = eyeCn); U = zeroan,n); for k = 1:n-1 if ACk,k) == errorC'kth principal submatrix is singular'); end for j = k+1:n m = ACj.k)/A(k,k); ACj,k+1:n) = ACj,k+1:n) - m*A(k,k+1:n); ACj.k) = 0; LCj,k) = m; end end U = A, return; @ Page 1 of 1 ?—_—_ m~7fije for 95/5) _ ,linear_sys_solv_er.m 31811043513511! chunctibn ‘x = linedr_sys__sower(A,b) [L,U] = 1u_factor(A); I ‘ xhat = ForwardsubstituteCL,b); x = backsubstituteCU,xhat); return; @ Page 1 of ‘ Mall/HA gal/fan! 01/ 05/6) Exera’re /,2,/7 ~Wa/é/‘nj Page //2 >>A=[3-10-100000; -14-10-10000; 0-1300-1000; -1004-10-100; 0-10-14-10-10; 00-10-1400-1; 000-1003-10; 00.00-10-14-1; 00000-10-13] >>A= 3 -1 0 -1 0 0 0 O 0 -1 4 -1 0 -1 0 0 0 0 O -1 3 0 0 -1— O 0 O -1 O 0 4 -1 O -1 O O o ,-1 o -1 4 -1 o -1 0 0 O -1 0 -1 4 O O -1 O 0 0 -1 O 0 3 -1 0 O 0 O 0 -1 O -1 4 -1 0 O O 0 0 -1 0 -1 3 >>b=[000000009]' b: (OOOOOOOOO >> xm = linear_sys_solver(A,b) xm = 3.0000000000000006-01 4.500000000000001 e-01 6.0000000000000026-01 4.500000000000001 e-O1 9.000000000000002e-01 /\//a ll/flé flA/flfu/ "0/ Qf/t/ ( Exam/re L2. /7 .— Mar/Am; . I flq/e 2[2 ' 1 .3500000000000006+00 ‘ 6.000000000000001 e-01 1 .3500000000000006+00 3.9000000000000009+00 >>x=A\b X: 3.000000000000002e—01 4.500000000000001 e-01 6.000000000000000e-01 4.5000000000000026-01 9.0000000000000026-01 ' 1.3500000000000006+00 6.000000000000001 6-01 1 .3500000000000009+00 3.900000000000000’e+00 ' >> norm(x—xm) ans = 3.554447978966673e-16 >> norm(b - A*xm) ans = 9.5019785199122418-16 (05 {z} —w%b%4m1 //3 J , >> C = zeros(20,1); >> C(1) 2; 2; >> R = zeros(1,20); >> R(1,1) >> A = toeplitz(C,R) >> C(2) = -1; >> R(1,2) = -1; A: 00000000000000000042 00000000000000000424 00000000000000004240 00000000000000042400 00000000000000424000 00000000000004240000 00000000000042400000 00000000000424000000 00000000004240000000 00000000042400000000 00000000424000000000 00000004240000000000 00000042400000000000 00000424000000000000 00004240000000000000 00042400000000000000 00424000000000000000 04240000000000000000 42400000000000000000 2400,0000000000000000 M O m.‘ S o r e Z = b > > >> b(5) = 1; >> b(16) = -1; >> xm = Iinear_sys_solver(A,b) xm= 1000000 0000000 . ++++++ 9869993 8826047 3479246 2050616 5988776 9123456 0642086 8715926 3479146 2050616 5988776 9123456 0642086 8715926 3479146 2050616 5.112221 Ma MM flmfiomé far Q50) EXWc/jre /,2,2U ~ Zfla/ém; Paje .2/3 1 .190476190476191e+00 7.1428571428571463-01 2.380952380952384e-01 -2.380952380952377e-01 -7.142857142857139e-01 -1 .1904761904761909+00 -1 .666666666666666e+00 -2.142857142857142e+00 -2.619047619047619e+00 -2.095238095238095e+00 -1.571428571428571e+00 -1 .047619047619047e+00 -5.238095238095236e-01 >>x=A\b X: 5.238095238095234e-01 1 .04761 9047619047e+00 1 .571428571428570e+00 2.095238095238094e+00 2.619047619047617e+00 2.142857142857141e+00 1 .666666666666666e+00 1 .1904761904761909+00 7.142857142857140e-O1 2.380952380952376e-01 -2.380952380952389e-01 -7.142857142857153e—01 -1 .1 904761 904761 92e+00 -1 .666666666666669e+00 -2.142857142857145e+00 -2.619047619047621e+00 -2.095238095238097e+00 -1 .571428571428573e+00 -1 .047619047619049e+00 -5.238095238095242e-01 >> norm(x - xm) ans = 7.716698955156931e-15 >> norm(b - A*xm) F—fl ”7471/45 flmlw‘ fl/ df/(j tag/(me //2 .20 »M,%W Pie 3/3 ~ , ans = 6.042816540784768e-1‘6 Mt/fjé 7/0” Qf/Jj matinverse. m Function X = matinverseCA) % Call : X = matinverseCA) % Task : Computes the inverse of the matrix A [n,n1] = sizeCA); if n ~= n1 errorC'A must be square'); end [L,U] = 1u_Factor(A);‘ for j = 1:n % computing X_j; the jth column of the inverse % (0) Form e_j b = zeroan,1); ij) = 1; % (1) Solve L*xhat = b xhat = forwardsubstituteCL,b); % (2) Solve U*x = xhat; Note that X_j = x X(:,j) = backsubstituteCU,xhat); end return; ananosnOPMi @ Page 1 of 1 M4 1M m/m /“ 425/5) >>A1=[120;212;021] A1: 1 2 0 N—‘N 0 2 1 >> X1, = matinverse(A1) X1 = 0.42857 0.28571 -0.57143 0.28571 -0.14286 0.28571 -0.57143 0.28571 0.42857 >> norm(A1*X1 - eye(3)) ans = 0 >>A2=[113;220;301] A2: (1010-L DNA 3 0 1 >> X2 = matinverse(A2) X2 = -0.1 1 11 1 0.05556 0.33333 0.11111 0.44444 -0.33333 0.33333 -0.16667 0.00000 >> norm(A2*X2 - eye(3)) ans = 2.7756e-17 @ ...
View Full Document

{[ snackBarMessage ]}