Lecture22 - function x % Function % L -> % U -> % B...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
» 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 » 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 Example: Matrix Inverse MATLAB function
Background image of page 2
Error Analysis and System Condition The matrix inverse provides a means to discern whether a system is ill- conditioned 1. Normalize rows of matrix [ A ] to 1. If the elements of [ A ] - 1 are >> 1, the matrix is likely ill-conditioned 2. If [ A ] 1 [ A ] is not close to [ I ], the matrix is probably ill-conditioned 3. If ([ A ] 1 ) 1 is not close to [ A ], the
Background image of page 3

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

View Full DocumentRight Arrow Icon
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)     = = = n 1 i 2 i e n 3 2 1 x X x x x x X     2 2 2 e c b a F c b a F + + = =
Background image of page 4
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 ∑∑ = = = n 1 i n 1 j 2 ij e a A p 1 n 1 i p i p x X / = = p = 2 : Euclidean norm
Background image of page 5

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

View Full DocumentRight Arrow Icon
Vector and Matrix Norms
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

Lecture22 - function x % Function % L -> % U -> % B...

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

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