How do I track which rows were swapped in the Gaussian elimination using RowReduce?

I am doing metabolic control analysis on a mathematical of the energy metabolism I have in Mathematica.

I need to do several matrix operations including a Gaussian elimination. For my control analysis I need to know which rows were swapped and where they are after the elimination.

Is there a way to let Mathematica also give me the final position of the original rows after the elimination?

Thank you very much,


  • $\begingroup$ It's not clear what "original rows" would mean. Gaussian elimination adds linear combinations of rows so a given final row can have parts of multiple original rows. $\endgroup$ – Daniel Lichtblau Jul 7 '14 at 14:09

I don't think you can "follow" the steps taken, but you surely can see how the resulting matrix is formed by "augmenting" your matrix with the identity. Following the last example on the docs about RowReduce[]:

m = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
a = Transpose[Join[Transpose[m], IdentityMatrix[Length[m]]]];
MatrixForm[r = RowReduce[a]]

Mathematica graphics

So for example the first row of the result is obtained by the lc:

-7/2 m[[3]] + 5/2 m[[4]]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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