# Row echelon form question

I am wondering if there is a Mathematica command that will put a matrix in row echelon form. That is, put

$$\begin{bmatrix} 1 & 2 & 3\\ 2 & 3 & 4\\ -1 & 0 & 2 \end{bmatrix}$$ in row echelon form: $$\begin{bmatrix} 1 & 2 & 3\\ 0 & 1 & 2\\ 0 & 0 & 1\end{bmatrix}$$ I am aware that I can do a sequence of elementary row operations. I am also aware of the RowReduce command which puts a matrix in reduced row echelon form. I even saw a Method->"OneStepRowReduction" used by the RowReduce command which I thought might be the choice.

Just wondering if there is a command for this that I cannot find.

• Your second matrix is not in row echelon form. – enzotib Mar 22 '15 at 13:21
• What @enzotib quite correctly observes leads me to wonder if perhaps you actually want the "echelon" form over the ring of integers. That would be found with HermiteDecomposition. – Daniel Lichtblau Mar 22 '15 at 13:27
• Fixed the row echelon error. Sorry about that. No, I just want the ordinary row echelon form students have to do when first introduced to Gaussian elimination. – David Mar 22 '15 at 15:12
• Note that there is nothing unique about a row echelon form, even such a form whose leading entries are all 1. So the question needs to be restated in a more precise manner. E.g., do you want a command that follows a particular algorithm for obtaining a row echelon form? As you noted, it's easy to do a sequence of elementary row operations, and to write little functions to do such operations, then to write a main function that calls those little functions to follow a particular reduction algorithm. But then how do you want to handle roundoff errors? (Or do you want exact rational arithmetic?) – murray Mar 22 '15 at 20:24

I think LUDecomposition should be able to do this. Using code from help in Mathematica docs:
a = {{1, 2, 3}, {2, 3, 4}, {-1, 0, 2}};

d = Position[Diagonal[u], -1]