% Matlab diary from cs110a class #8, Jan 21 2005. % % This is what I typed in class. % % Type it into Matlab yourself to % reproduce the output I showed. A = golub(7) x = ones(7,1) b = A*x xstar = A \ b e = x - xstar norm(e) r = b - A*xstar norm(r) help cond I = eye(5) cond(I) B = 3*I cond(B) B = [1 0 0 ; 0 2 0; 0 0 3] cond(B) B * [0;0;1] B*[1;0;0] A cond(A) norm(r) norm(e) y = rand(7,1) norm(y) A*y norm(A*y) norm(A*y) / norm(y) x b = A*x x = x+eps x-ones(7,1) x newx = x newb = A * newx b b - newb deltax = newx - x x x = ones(7,1) deltax = newx - x deltab = A*newx - A*x norm(deltax) / norm(x) norm(deltab) /norm(b) cond(A) norm(A) norm(inv(A)) norm(A) * norm(inv(A)) cond(A) cond(A) condest(A) A = rand(5) A = A + 5*eye(5) A = A + A' A - A' R = chol(A) U = R L = R' L*U ans - A (R') * R - A