lu - Maple Help

Matlab

 lu
 compute the LU decomposition of a MapleMatrix or MatlabMatrix in MATLAB(R), where P*X = L*U

 Calling Sequence lu(X, output=L) lu(X, output=LU) lu(X, output=LUP)

Parameters

 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

Description

 • The lu command computes the LU decomposition of a MapleMatrix or MatlabMatrix in MATLAB®, where $PX=LU$, when output=LUP, and $X=LU$, 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 $\mathrm{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.

Examples

Define the Maple matrix

 > $\mathrm{with}\left(\mathrm{Matlab}\right):$
 > $\mathrm{maplematrix_a}≔\mathrm{Matrix}\left(\left[\left[3,1,3,5\right],\left[1,6,4,2\right],\left[6,7,8,1\right],\left[3,3,7,3\right]\right]\right)$
 ${\mathrm{maplematrix_a}}{≔}\left[\begin{array}{cccc}{3}& {1}& {3}& {5}\\ {1}& {6}& {4}& {2}\\ {6}& {7}& {8}& {1}\\ {3}& {3}& {7}& {3}\end{array}\right]$ (1)

The LU decomposition of this MapleMatrix returning L and U is computed as

 > $L,U≔{\mathrm{Matlab}}_{\mathrm{lu}}\left(\mathrm{maplematrix_a}\right)$

 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.

 > ${\mathrm{Matlab}}_{\mathrm{lu}}\left(\mathrm{maplematrix_a},\mathrm{output}='L'\right)$

 [         6. ,                   7. ,                    8. ,                   1.        ] [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≔{\mathrm{Matlab}}_{\mathrm{lu}}\left(\mathrm{maplematrix_a},\mathrm{output}=\mathrm{LUP}\right):$

Verify correctness using MATLAB®.

 > ${\mathrm{Matlab}}_{\mathrm{setvar}}\left("a",\mathrm{maplematrix_a}\right)$
 > ${\mathrm{Matlab}}_{\mathrm{setvar}}\left("l",L\right)$
 > ${\mathrm{Matlab}}_{\mathrm{setvar}}\left("u",U\right)$
 > ${\mathrm{Matlab}}_{\mathrm{setvar}}\left("p",P\right)$
 > ${\mathrm{Matlab}}_{\mathrm{evalM}}\left("result = isequal\left(l*u, p*a\right)"\right)$
 > $\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Matlab}}_{\mathrm{getvar}}\left("result"\right)=1.0\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{true}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{else}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{false}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end if}$

 true