1
$\begingroup$

Is there a way to find the echelon form of a matrix in Mathematica? I see there is a function to find the reduced echelon form, RowReduce[], but I can't see anything for the echelon or upper triangular form?

Thanks David.

$\endgroup$

2 Answers 2

2
$\begingroup$

Possibly what you want is the "U" part of an LU factorization. I'll illustrate using the same example as in another response. The code is pretty much straight out of the documentation for LUDecomposition.

m = {{1, 2, 3, 1, 0, 0}, {4, 5, 6, 0, 1, 0}, {7, 8, 9, 0, 0, 1}};

{lu, perm, cond} = LUDecomposition[m]

(* Out[227]= {{{1, 2, 3, 1, 0, 0}, {4, -3, -6, -4, 1, 0}, {7, 2, 0, 
   1, -2, 1}}, {1, 2, 3}, 1} *)

uu = lu*SparseArray[{i_, j_} /; j >= i -> 1, Dimensions[lu]]

(* Out[230]= {{1, 2, 3, 1, 0, 0}, {0, -3, -6, -4, 1, 0},
  {0, 0, 0, 1, -2, 1}} *)
$\endgroup$
2
  • 2
    $\begingroup$ UpperTriangularize[] would be a more readable way to grab the upper-triangular factor, tho. $\endgroup$ Apr 22, 2013 at 23:14
  • $\begingroup$ @J. M. I'd have used it too, had I but known about it. $\endgroup$ Apr 22, 2013 at 23:28
1
$\begingroup$

I learned from this thread that you can use HermiteDecomposition. For example:

m = {{1, 2, 3, 1, 0, 0}, {4, 5, 6, 0, 1, 0}, {7, 8, 9, 0, 0, 1}};

{u,r}=HermiteDecomposition[m];
r//MatrixForm

MatrixForm/@{RowReduce[r],RowReduce[m]}

(Please see comments for more details about what r really is, turns out it's not necessarily the upper triangular)

$\endgroup$
2
  • $\begingroup$ Thanks. Will checkout HermiteDecomposition[]. $\endgroup$ Apr 22, 2013 at 22:56
  • 2
    $\begingroup$ HermiteDecomposition is really a "reduced" echelon form. It just happens that, because it works over a ring and not a field, it cannot fully reduce above the pivots. That said, it might still be what the poster wants. $\endgroup$ Apr 22, 2013 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.