260 likes | 874 Views
Chapter 11. Matrix Inverse and Condition. Matrix Inverse. How do we get inverse [ A ] 1 ? One way is through LU decomposition and back-substitution Solve [ A ]{ x i } = { b i } with Put together x’s to get [A] -1 ={x 1, x 2 ,x 3 ,x 4 }. Sequentially!. Matrix Inverse.
E N D
Chapter 11 Matrix Inverse and Condition
Matrix Inverse • How do we get inverse [A]1? • One way is through LU decomposition and back-substitution • Solve [A]{xi} = {bi} with • Put together x’s to get [A]-1 ={x1,x2,x3,x4} Sequentially!
Matrix Inverse • [A] [A]1= [ I ] • Use LU factorization to find [X] = [A]1 • LU decomposition: [A] = [L][U] • Forward substitution: [L][Y] = [ I ] • Back substitution: [U][X] = [Y]
Matrix Inverse • Forward Substitution [L][Y] = [ I ]
Matrix Inverse • back Substitution [U][X] = [ Y ]
function x = LU_Solve_Gen(L, U, B) % Function to solve the equation L U x = B % L --> Lower triangular matrix (1's on diagonal) % U --> Upper triangular matrix % B --> Right-hand-side matrix [n n2] = size(L); [m1 m] = size(B); % Solve L d = B using forward substitution for j = 1 : m d(1,j) = B(1,j); for i = 2 : n d(i,j) = B(i,j) - L(i, 1:i-1) * d(1:i-1,j); end end % SOlve U x = d using back substitution for j = 1 : m x(n,j) = d(n,j) / U(n,n); for i = n-1 : -1 : 1 x(i,j) = (d(i,j) - U(i,i+1:n) * x(i+1:n,j)) / U(i,i); end end
Example: Matrix Inverse » A=[-19 20 -6;-12 13 -3;30 -30 12] A = -19 20 -6 -12 13 -3 30 -30 12 » [L,U]=LU_factor(A); L = 1.0000 0 0 0.6316 1.0000 0 -1.5789 4.2857 1.0000 U = -19.0000 20.0000 -6.0000 0 0.3684 0.7895 0 0.0000 -0.8571 » B=eye(3) B = 1 0 0 0 1 0 0 0 1 » x=LU_solve_gen(L,U,B) x = 11.0000 -10.0000 3.0000 9.0000 -8.0000 2.5000 -5.0000 5.0000 -1.1667 » inv(A) ans = 11.0000 -10.0000 3.0000 9.0000 -8.0000 2.5000 -5.0000 5.0000 -1.1667 MATLAB function
Error Analysis and System Condition • The matrix inverse provides a means to discern whether a system is ill-conditioned • Normalize rows of matrix [A] to 1. If the elements of [A]1 are >> 1, the matrix is likely ill-conditioned • If [A]1[A]is not close to [ I ], the matrix is probably ill-conditioned • If ([A]1)1 is not close to [A], the matrix is ill-conditioned
Vector and Matrix Norms • Norm: provide a measure of the size or “length” of multi-component mathematical entities such as vectors and matrices Euclidean norm of a vector (3D space)
Matrix Norm • For n n matrix, the Frobenius norm • Frobenius norm provides a single value to quantify the size of matrix [A] • Other alternatives – p norms for vectors p = 2 : Euclidean norm
Vector and Matrix Norms • Vector norms ( p-norms) • Matrix norms Sum of absolute values Maximum-magnitude or uniform-vector norm Column-sum norm Row-sum norm
Matrix Condition Number • Condition number defined in terms of matrix norms • Cond[A] is great than or equal to 1 • Matrix A is ill-conditioned if Cond[A] >> 1 • If [A] has 107 rounding error and Cond[A] = 105, then the solution [X] may be valid to only 102 Relative error of the norm
Matrix Condition Evaluation • Hilbert matrix – notoriously ill-conditioned • Row-sum norm (last row has the largest sum) Normalization
Matrix Condition Evaluation • 5 5 Hilbert matrix • Condition number
MATLAB Norms and Condition Numbers >> A=[1 1/2 1/3 1/4 1/5; 1 2/3 2/4 2/5 2/6; 1 3/4 3/5 3/6 3/7; 1 4/5 4/6 4/7 4/8; 1 5/6 5/7 5/8 5/9]; >> Ainv = inv(A) Ainv = 25 -150 350 -350 126 -300 2400 -6300 6720 -2520 1050 -9450 26460 -29400 11340 -1400 13440 -39200 44800 -17640 630 -6300 18900 -22050 8820 >> norm(A,inf) ans = 3.7282 >> norm(Ainv,inf) ans = 1.1648e+005 >> cond(A,inf) ans = 4.3426e+005 >> cond(A,'fro') ans = 2.7944e+005 >> cond(A) ans = 2.7746e+005 >> norm(X,p) >> cond(X,p) >> Cond(A,’fro’) >> cond(A) p-norm Frobenius norm Spectral norm
CVEN 302-501Homework No. 7 • Chapter 10 • Prob. 10.4(20), 10.5(20) both using LU decomposition (hand calculation only, hand partial pivoting if necessary), Prob. 10.8 a)&b) (20). • Chapter 11 • Prob. 11.2 (15), 11.3 a) & b) (20) (Hand Calculations) • Prob. 11.6 (25) (Hand Calculations; Check your solutions using MATLAB) • Due Monday 10/13/08 at the beginning of the period