See Topics in FCLA, Section TD for related material.
{{{ entries = [[-6, -10, 0, 10, 14], [2, 3, 0, -4, -3], [0, -2, -3, 1, 8], [5, 6, -3, -7, -3], [-1, 1, 6, -1, -8]] A = matrix(QQ, entries) A }}}Elementary matrices to “do” row operations in first column.
{{{ actionA = elementary_matrix(QQ, 5, row1=1, row2=0, scale=-2)*elementary_matrix(QQ, 5, row1=3, row2=0, scale=-5)*elementary_matrix(QQ, 5, row1=4, row2=0, scale=1)*elementary_matrix(QQ, 5, row1=0, scale=-1/6) B = actionA*A B }}}Now in second column, moving to “row-echelon form” (i.e. not “reduced”).
{{{ actionB = elementary_matrix(QQ, 5, row1=2, row2=1, scale=2)*elementary_matrix(QQ, 5, row1=3, row2=1, scale=7/3)*elementary_matrix(QQ, 5, row1=4, row2=1, scale=-8/3)*elementary_matrix(QQ, 5, row1=1, scale=-3) C = actionB*B C }}} {{{ actionC = elementary_matrix(QQ, 5, row1=3, row2=2, scale=3)*elementary_matrix(QQ, 5, row1=4, row2=2, scale=-6)*elementary_matrix(QQ, 5, row1=2, scale=-1/3) D = actionC*C D }}}And now the penultimate column.
{{{ actionD = elementary_matrix(QQ, 5, row1=4, row2=3, scale=-2)*elementary_matrix(QQ, 5, row1=3, scale=1) E = actionD*D E }}}And done.
{{{ actionE = elementary_matrix(QQ, 5, row1=4, scale=1) F = actionE*E F }}}Clearly, $F$ has determinant 1. We should have $\mathop{ det}(A) = \left ( {1\over −1∕6}\right )\left ( {1\over −3}\right )\left ( {1\over −1∕3}\right )\left ({1\over 1}\right )\left ({1\over 1}\right )\mathop{ det}(F) = −6$.
{{{ A.determinant() }}}But it gets better. $F$ is the product of the “action” matrices on the left of $A$.
{{{ total_action = prod([actionE, actionD, actionC, actionB, actionA]) }}} {{{ F == total_action * A }}}The elementary matrices are all lower triangular (because we just created zeros below the diagonal), and so their product is lower triangular.
{{{ total_action }}}The “total action” matrix is a product of elementary matrices, which are individually nonsingular. So the product is nonsingular. Futhermore, the inverse is again lower triangular.
{{{ ta_inv = total_action.inverse() }}}Rearranging the equality above,
{{{ A == ta_inv * F }}}So we have decomposed the original matrix ($A$) into the product of a lower triangular matrix (inverse of the total action matrix) and an upper triangular matrix with all ones on the diagonal ($F$, the row-echelon matrix).
This decomposition (an “LU decomposition”) can be useful for solving systems quickly. You “back solve” with one matrix, then “forward solve” with the other.
{{{ }}}