mase201sp09_Feb03_printable - Solving Systems of Linear...

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

View Full Document Right Arrow Icon
Solving Systems of Linear Equations using MATLAB (Review) MATLAB has built-in functions for solving systems of linear equations s These functions solve a system of linear equations without explicitly calculating a matrix inverse : • Gauss elimination method (with pivoting) • Gauss-Jordan method s We will: 2/03/2009 1 s Review how these methods and functions work s Apply them to engineering problems s Learn how they scale with problem size (i.e. the number of equations we want to solve) s Learn how to calculate a matrix inverse s Discuss limitations and caveats of the methods and functions MASE201 Spring 2009 Objective: “Look under the hood” and become intelligent users of MATLAB’s tools Why use matrix left divide rather than inverse of [A]? Given [A] [x] = [b], then [A] -1 [A] [x] = [A] -1 [b] Since [I]= [A] -1 [A] (def’n of a matrix inverse) then [I] [x] = [A] -1 [b] ince an entity matrix time an ector Since an R x R identity matrix time an R x 1 vector equals that R x 1 vector: then [x] = [A] -1 [b] MATLAB can compute a matrix inverse: a = [1 2; 3 4]; inv(a) % invert a inv(a)*a %result is a 2x2 identity matrix 2/03/2009 2 MASE201 Spring 2009 More computations are needed to invert a matrix • Computing an inverse takes more computational steps than using Gauss elimination – For small matrices, we won’t even notice the extra time – For a very large matrix or if the computation is repeated many times, the choice of method can make difference a difference 2/03/2009 MASE201 Spring 2009 3 500 1000 1500 2000 2500 0 10 20 30 square matrix size computation time (sec) a\b inv(a)*b Solving with Cramer’s rule • Cramer’s rule (2 x 2 matrix): = = = 12 11 2 12 1 11 2 12 11 22 2 12 1 1 2 1 2 1 22 21 12 11 et det t det : a a b a b a x a a a b a b x Find b b x x a a a a • Cramer’s rule (general form) where a j is the matrix formed by replacing the j th column of a with b 2/03/2009 4 22 21 22 21 det det a a a a ( ) ( ) a a det ' det j j x = MASE201 Spring 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
Calculating a determinant using MATLAB • If we want to use Cramer’s rule, then we need to calculate the determinant of a and every a j • How does MATLAB calculate a determinant? – It does NOT use cofactors and minors – It uses special properties of upper triangular and lower triangular matrices: • If [c] is an upper triangular matrix or a lower triangular matrix, det([c]) is equal to the product of the diagonal elements of [c] – The forward elimination step in the Gauss elimination
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

mase201sp09_Feb03_printable - Solving Systems of Linear...

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

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