1

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
David McHarg
  • 1,643
  • 1
  • 15
  • 28

2 Answers2

2

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}} *)
Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199
1

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)

C. E.
  • 70,533
  • 6
  • 140
  • 264
  • 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