# Convert a n by n matrix to upper triangular

How can we mathematically and algorithmic-ally convert a $n\times n$ matrix to a upper triangular matrix

-
You'll have to give more information about what sort of "conversion" you want. It's possible to just change everything below the diagonal to zero, but that's probably not what you're looking for. –  Jonathan Christensen Nov 8 '12 at 2:23
By "convert", I take it you mean "find an upper triangular matrix similar to a given matrix"? –  Gerry Myerson Nov 8 '12 at 2:23
Or perhaps you mean Gaussian - Elimination? –  EuYu Nov 8 '12 at 2:25
...because, as mentioned, your question is exceedingly vague as it stands. Gaussian elimination will decompose your matrix as the product of an upper and lower triangular matrix, while Jordan decomposition will yield a (special) triangular matrix whose eigenvalues are the same as the eigenvalues of your original matrix. Can you be clearer? –  J. M. is back. Nov 8 '12 at 2:26
@EuYu, actually, LU decomposition and Gaussian elimination (and for that matter, row reduction) are equivalent... LU is just a "decompositional" way to look at the process of Gaussian elimination, nothing more or fancier. –  J. M. is back. Nov 8 '12 at 2:56

It appears from the comments that what OP wants to do is to calculate the determinant of a square matrix by using elementary row operations to bring the matrix to upper triangular form, then multiplying all the diagonal entries.

One needs to know that if you get from matrix $A$ to matrix $B$ by

(1) subtracting any multiple of any row of $A$ from any other row of $A$ then $\det B=\det A$;

(2) by exchanging two rows of $A$ then $\det B=-\det A$.

Now, look for a nonzero entry in the first column of your matrix. If there aren't any, stop: the determinant is zero.

If you do locate a nonzero entry in the first column, swap the row containing that entry with the first row [see (2), above], if necessary, then subtract multiples of the first row from each other row in turn [see (1), above] in such a way as to bring all the other entries in the first column to zero.

Now forget about the first row and column of the matrix, and apply the procedure to the rest of the matrix. Keep doing this until an all-zero column halts the computation or until you run out of matrix. If you run out of matrix, you have created an upper triangular matrix, and you know what to do.

This works better in theory than in practice. In theory, it doesn't matter which choices you make along the way; in practice, it can make a great deal of difference. But, then, if you're really looking for a practical way to calculate a determinant, you just use a program someone else has already written that does it for you.

-