LUDecomposition

LUDecomposition[m]

generates a representation of the LU decomposition of a square matrix m.

Details and Options

  • LUDecomposition returns a list of three elements. The first element is a combination of upper and lowertriangular matrices, the second element is a vector specifying rows used for pivoting, and for approximate numerical matrices m the third element is an estimate of the L condition number of m.

Examples

open allclose all

Basic Examples  (1)

Compute the LU decomposition of a matrix:

l is in the strictly lowertriangular part of lu with ones assumed along the diagonal:

u is in the uppertriangular part of lu:

l.u reconstructs the original matrix:

Scope  (3)

m is a 3×3 matrix:

Compute using exact arithmetic:

Compute using machine arithmetic:

Compute using 20digit precision arithmetic:

LU decomposition for a complex matrix:

Compute a symbolic LU decomposition:

Applications  (3)

The LU decomposition of a matrix decomposes a matrix into lower triangular () and upper triangular () parts that satisfy , where is a column permutation of :

Extract the lower and upper parts of the decomposition:

Verify the decomposition l.uap:

Illustrate the structure by using MatrixPlot:

LU decompositions are mainly used to solve linear systems. Here is a 5×5 random matrix:

LinearSolve[m] sets up an LU decomposition in a functional form convenient for solving:

This solves the system m.x=b for x:

Verify that x is indeed the solution:

This can be done manually with the output of LUDecomposition as well:

l is in the strictly lowertriangular part of lu with ones assumed along the diagonal:

u is in the uppertriangular part of lu:

Solve the system with two backsolves:

m is a random 100×100 matrix:

Compute the LU decomposition of m:

The determinant of m is given by the product of the diagonal elements of l:

Properties & Relations  (1)

m is a 6×6 random matrix:

Compute the LU decomposition of m:

l is in the strictly lowertriangular part of lu with ones assumed along the diagonal:

u is in the uppertriangular part of lu:

l.u is equal to a permutation of the rows of m:

Introduced in 1996
 (3.0)