| MATLAB Function Reference | Search  Help Desk |
| lu | Examples See Also |
[L,U]The=lu(X) [L,U,P] = lu(X) lu(X)
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.
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 /.
ATo see the LU factorization, call=123456780
lu with two output arguments:
[L,U]Notice that=lu(A) L=0.14291.000000.57140.50001.00001.000000 U=7.00008.00000.000000.85713.0000004.5000
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:
L*Uwhich returns the original
A. Using three arguments on the left-hand side to get the permutation matrix as well
[L,U,P] = lu(A)returns the same value of
U, but L is reordered:
LTo verify that=1.0000000.14291.000000.57140.50001.0000 U=7.00008.0000000.85713.0000004.5000 P=001100010
L*U is a permuted version of A, compute L*U and subtract it from P*A:
P*A - L*UThe inverse of the example matrix,
X = inv(A), is actually computed from the inverses of the triangular factors:
X = inv(U)*inv(L)The determinant of the example matrix is
d = det(A)which gives
dIt is computed from the determinants of the triangular factors:=27
d = det(L)*det(U)The solution to Ax
= b is obtained with matrix division:
x = A\bThe solution is actually computed by solving two triangular systems:
y = L\b, x = U\y
lu uses the subroutines ZGEDI and ZGEFA from LINPACK. For more information, see the LINPACK Users' Guide.
\ 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