Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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}} *)
share|improve this answer
1  
UpperTriangularize[] would be a more readable way to grab the upper-triangular factor, tho. –  J. M. Apr 22 '13 at 23:14
    
@J. M. I'd have used it too, had I but known about it. –  Daniel Lichtblau Apr 22 '13 at 23:28
add comment

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)

share|improve this answer
    
Thanks. Will checkout HermiteDecomposition[]. –  David McHarg Apr 22 '13 at 22:56
2  
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. –  Daniel Lichtblau Apr 22 '13 at 23:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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