# Is there a simple method to do LU decomposition by hand?

Today my professor in numerical analysis pointed out that in the exam we will probably have to do LU decomposition by hand.

I understand how the decomposition works theoretically, but when it comes actually getting my hands dirty, I'm never sure, if I'm writing the row operation at the right place in the L matrix.

Do you know a mnemonic, which allows one to efficiently compute the LU decomposition by hand?

Note that I didn't write this answer; taken from: LU Decomposition Steps

This is also useful: Upper and Lower Triangular Matrices

Let's go step by step. We want an equation of the following form: (An example is given below)

$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}\star&0&0&0\\\star&\star&0&0\\\star&\star&\star&0\\\star&\star&\star&\star\end{pmatrix}\begin{pmatrix}\star&\star&\star&\star\\0&\star&\star&\star\\0&0&\star&\star\\0&0&0&\star\end{pmatrix}$$

From the first column and first row of our known matrix, it's not too hard to see that we can start with this:

$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&\star&0&0\\1&\star&\star&0\\2&\star&\star&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&\star&\star&\star\\0&0&\star&\star\\0&0&0&\star\end{pmatrix}$$

Next, we can choose the diagonal elements of our upper triangular matrix to be $1$, and fill in the lower triangular matrix column by column:

$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&\star&0\\2&-3&\star&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&\star&\star\\0&0&1&\star\\0&0&0&1\end{pmatrix}$$

$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&5&0\\2&-3&1&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&2&\star\\0&0&1&\star\\0&0&0&1\end{pmatrix}$$

$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&5&0\\2&-3&1&2/5\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&2&3\\0&0&1&8/5\\0&0&0&1\end{pmatrix}$$

• how about non square matrices? Mar 29, 2018 at 6:45

If you remember how to do Gaussian elimination, you can just do that -- the $U$ matrix is precisely the upper triangular matrix you get from elimination, and each subdiagonal entry $L_{ij}$ of $L$ is the multiple of row $j$ you subtract from row $i$ to zero the element $A_{ij}$. The diagonal entries are just the scaling factors to give unit diagonal for $A$.

In fact, performing Gaussian elimination on the matrix in Sujaan Kunalan's example and comparing your steps with those in the example is probably a good way of getting a feel for the method (and more useful than memorizing indices).