Contents
Contents
Contents
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
AMATH 581 ( c○J. N. Kutz) 44MATLAB: A \ bGiven the alternatives for solving the linear system Ax = b, itisimportanttoknow how the MATLAB command structure for A \ b works. The following isan outline of the algorithm performed.1. It first checks to see if A is triangular, or some permutation thereof. If itis, then all that is needed is a simple O(N 2 )substitutionroutine.2. It then checks if A is symmetric, i.e. Hermitian or Self-Adjoint. If so, aCholesky factorization is attempted. If A is positive definite, the Choleskyalgorithm is always succesful and takes half the run time of LU factorization.3. It then checks if A is Hessenberg. If so, it can be written as an uppertriangular matrix and solved by a substitution routine.4. If all the above methods fail, then LU factorization is used andtheforwardand backward substitution routines generate a solution.5. If A is not square, a QR (Householder) routine is used to solve the system.6. If A is not square and sparse, a least squares solution using QR factorizationis performed.Note that solving by b = A −1 x is the slowest of all methods, taking 2.5 timeslonger or more than A \ b. It is not recommended. However, just like LUfactorization, once the inverse is known it need not be calculated again. Caremust also be taken when the det A ≈ 0, i.e. the matrix is ill-conditioned.MATLAB commandsThe commands for executing the linear system solve are as follows• A \ b: Solve the system in the order above.• [L, U] =lu(A): Generate the L and U matrices.• [L, U, P ]=lu(A): Generate the L and U factorization matrices along withthe permutation matrix P .2.3 Iterative solution methods for Ax=bIn addition to the standard techniques of Gaussian elimination or LU decompositionfor solving Ax = b, awiderangeofiterativetechniquesareavailable.These iterative techniques can often go under the name of Krylov space methods[6]. The idea is to start with an initial guess for the solution and developan iterative procedure that will converge to the solution. The simplest example