% diary for Math 551 for 2/7/12 % see text page 40 format long A=[17 5;1.7 0.5] A = 17.000000000000000 5.000000000000000 1.700000000000000 0.500000000000000 b=[22;2.2] b = 22.000000000000000 2.200000000000000 x_exact=[1;1] x_exact = 1 1 A*x ans = 22.000000000000000 2.200000000000000 x=A\b Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.265362e-018. x = -1.058823529411765 8.000000000000000 svd(A) ans = 17.808424972467385 0 format long e mu=A(2,1)/A(1,1) mu = 9.999999999999999e-002 A(2,:)=A(2,:)-mu*A(1,:) A = 1.700000000000000e+001 5.000000000000000e+000 0 5.551115123125783e-017 b(2)=b(2)-mu*b(1) b = 2.200000000000000e+001 4.440892098500626e-016 2*eps ans = 4.440892098500626e-016 x(2)=b(2)/A(2,2) x = -1.058823529411765e+000 8.000000000000000e+000 x(1)=(b(1)-A(1,2)*x(2))/A(1,1) x = -1.058823529411765e+000 8.000000000000000e+000 A*x ans = 2.200000000000000e+001 4.440892098500626e-016 A_original=[17 5;1.7 0.5] A_original = 1.700000000000000e+001 5.000000000000000e+000 1.700000000000000e+000 5.000000000000000e-001 A_original*x ans = 2.200000000000000e+001 2.200000000000000e+000 A=[17.00001 5; 1.7 0.5] A = 1.700001000000000e+001 5.000000000000000e+000 1.700000000000000e+000 5.000000000000000e-001 svd(A) ans = 1.780843451851116e+001 2.807658357150557e-007 x_exact=[1;1] x_exact = 1 1 b=A*x_exact b = 2.200001000000000e+001 2.200000000000000e+000 x=A\b x = 9.999999996669331e-001 1.000000001132428e+000 A=[17.1 5; 1.7 0.5] A = 1.710000000000000e+001 5.000000000000000e+000 1.700000000000000e+000 5.000000000000000e-001 svd(A) ans = 1.790390996963804e+001 2.792686071634185e-003 x_exact=[1;1] x_exact = 1 1 b=A*x_exact b = 2.210000000000000e+001 2.200000000000000e+000 x=A\b x = 9.999999999999946e-001 1.000000000000019e+000 diary off