Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Which Matrix Decomposition Should I Use?

Start with the task: solving a square system, fitting an overdetermined one, or understanding what the matrix does. Then let the shape and symmetry of the matrix choose among LU, Cholesky, QR, the spectral decomposition and the SVD.

When to use this

A matrix problem that a factorization would make easier, and a choice among the five decompositions. Look at two things: what you must compute, and whether the matrix is square, symmetric or positive definite.

Decision tree

solve a square systemyesnoleast squares, tall Aeigen-structure, symmetric Arank, norm, approximationWhat do you need?Is A symmetric positive definite?Cholesky →LU, with pivoting ifneeded →QR →Spectral decomposition →SVD →

The same tree, written out

  1. 1You must solve a square system Ax=bA\mathbf{x} = \mathbf{b}, often for many right-hand sides, and AA is symmetric positive definite. Use the Cholesky decomposition A=LLTA = LL^T: about half the work of LU and no pivoting needed.
  2. 2You must solve a square system and AA is not symmetric positive definite. Use the LU decomposition, with row swaps PA=LUPA = LU when a pivot is zero.
  3. 3You have more equations than unknowns and want the least-squares solution. Use the QR decomposition and solve Rx^=QTbR\hat{\mathbf{x}} = Q^T\mathbf{b}; by hand, the normal equations work too.
  4. 4The matrix is symmetric and you need its eigenvalues, its principal axes, a quadratic form or a function of the matrix. Use the spectral decomposition A=QDQTA = QDQ^T. For a square matrix that is not symmetric, use diagonalization instead.
  5. 5The matrix has any shape and you need its rank, its 2-norm, a pseudoinverse or the best low-rank approximation. Use the SVD A=UΣVTA = U\Sigma V^T; it exists for every matrix.