Matlab
lu
compute the LU decomposition of a MapleMatrix or MatlabMatrix in MATLAB(R), where P*X = L*U
Calling Sequence
Parameters
Description
Examples
lu(X, output=L)
lu(X, output=LU)
lu(X, output=LUP)
X
-
MapleMatrix or MatlabMatrix
output
specify the form of the output (optional)
L
return combined upper and lower decomposed matrices
LU
return lower L and upper U decomposed matrices
LUP
return L, U, and permutation matrix P
The lu command computes the LU decomposition of a MapleMatrix or MatlabMatrix in MATLAB®, where P⁢X=L⁢U, when output=LUP, and X=L⁢U, when output=LU.
Matrix X is expressed as the product of two triangular matrices: L, a permutation of a lower triangular matrix, and U, a permutation of an upper triangular matrix.
The LU decomposition for a MatlabMatrix is executed as a string. The matrix must be defined in the MATLAB® session.
The output parameter L returns a combined lower and upper triangular matrix such that the diagonal and above are the entries of U, and the entries below the diagonal are the entries of L (with all diagonal entries for L implicitly having the value 1). As a matrix equation, this can be described as output=U+L−I.
Note that for MATLAB® version 5.2, the entries of L are stored with the opposite sign, so as a matrix equation this can be described as U−L+I.
The output parameter LU returns the lower and upper triangular matrices. This is the default if no output parameter is specified.
The output parameter LUP returns matrices L and U with a permutation matrix P.
Define the Maple matrix
with⁡Matlab:
maplematrix_a≔Matrix⁡3,1,3,5,1,6,4,2,6,7,8,1,3,3,7,3
maplematrix_a≔3135164267813373
The LU decomposition of this MapleMatrix returning L and U is computed as
L,U≔Matlablu⁡maplematrix_a
L, U :=
[0.500000000000000000 , -0.517241379310344750 , 0.115789473684210484 , 1. ]
[0.166666666666666657 , 1. , 0. , 0. ]
[ 1. , 0. , 0. , 0. ]
[0.500000000000000000 , -0.103448275862068950 , 1. , 0. ],
[ 6. , 7. , 8. , 1. ]
[ ]
[ 0. , 4.83333333333333392 , 2.66666666666666695 , 1.83333333333333326]
[ 0. , 0. , 3.27586206896551735 , 2.68965517241379314]
[ 0. , 0. , 0. , 5.13684210526315788]
The LU decomposition of this MapleMatrix returning both L and U combined is computed as follows. Since the variable L is defined, the L must have quotation marks around it in the procedure call.
Matlablu⁡maplematrix_a,output=L
[0.166666666666666657 , 4.83333333333333392 , 2.66666666666666695 , 1.83333333333333326]
[0.500000000000000000 , -0.103448275862068950 , 3.27586206896551735 , 2.68965517241379314]
[0.500000000000000000 , -0.517241379310344750 , 0.115789473684210484 , 5.13684210526315788]
The same decomposition including the permutation matrix P is
L,U,P≔Matlablu⁡maplematrix_a,output=LUP:
Verify correctness using MATLAB®.
Matlabsetvar⁡a,maplematrix_a
Matlabsetvar⁡l,L
Matlabsetvar⁡u,U
Matlabsetvar⁡p,P
MatlabevalM⁡result = isequal(l*u, p*a)
ifMatlabgetvar⁡result=1.0thentrueelsefalseendif
true
See Also
LinearAlgebra[LUDecomposition]
Matlab[det]
Matlab[evalM]
Matlab[inv]
Matlab[lu]
Matlab[qr]
MatlabMatrix
Download Help Document