MATLAB Functions Help Desk

lu

Purpose

LU matrix factorization

Syntax

Description

The lu function expresses any square matrix X as the product of two essentially triangular matrices, one of them a permutation of a lower triangular matrix and the other an upper triangular matrix. The factorization is often called the LU, or sometimes the LR, factorization.

[L,U] = lu(X) returns an upper triangular matrix in U and a psychologically lower triangular matrix (i.e., a product of lower triangular and permutation matrices) in L, so that X = L*U.

[L,U,P] = lu(X) returns an upper triangular matrix in U, a lower triangular matrix in L, and a permutation matrix in P, so that L*U = P*X.

lu(X) returns the output from the LINPACK routine ZGEFA.

Remarks

Most of the algorithms for computing LU factorization are variants of Gaussian elimination. The factorization is a key step in obtaining the inverse with inv and the determinant with det. It is also the basis for the linear equation solution or matrix division obtained with \ and /.

Arguments

L

A factor of X. Depending on the form of the function, L is either lower triangular, or else the product of a lower triangular matrix with a permutation matrix P.

U

An upper triangular matrix that is a factor of X.

P

The permutation matrix satisfying the equation L*U = P*X.

Examples

Start with

To see the LU factorization, call lu with two output arguments:

Notice that L is a permutation of a lower triangular matrix that has 1's on the permuted diagonal, and that U is upper triangular. To check that the factorization does its job, compute the product:

which returns the original A. Using three arguments on the left-hand side to get the permutation matrix as well

returns the same value of U, but L is reordered:

To verify that L*U is a permuted version of A, compute L*U and subtract it from P*A:

The inverse of the example matrix, X = inv(A), is actually computed from the inverses of the triangular factors:

The determinant of the example matrix is

which gives

It is computed from the determinants of the triangular factors:

The solution to Ax = b is obtained with matrix division:

The solution is actually computed by solving two triangular systems:

Algorithm

lu uses the subroutines ZGEDI and ZGEFA from LINPACK. For more information, see the LINPACK Users' Guide.

See Also

\       Matrix left division (backslash)

/           Matrix right division (slash)

cond        Condition number with respect to inversion

det         Matrix determinant

inv         Matrix inverse

qr          Orthogonal-triangular decomposition

rref        Reduced row echelon form

References

[1] Dongarra, J.J., J.R. Bunch, C.B. Moler, and G.W. Stewart, LINPACK
Users' Guide, SIAM, Philadelphia, 1979.



[ Previous | Help Desk | Next ]