LU (short for lower-upper) decomposition is a form of matrix factorization that decomposes a matrix into a product of lower and upper triangular matrices. This matrix factorization approach was introduced by the Polish astronomer Tadeusz Banachiewicz in 1938. In a way, LU decomposition can be seen as a Gaussian elimination (row reduction) method executed in matrix form. The LU decomposition is one of the most widely used matrix factorization methods for solving a system of linear equations (realize that such problems arise in many different fields including engineering, physics, economics, computer science, and applied mathematics), especially when such a system results in an equation where
is square and known,
is given, and
is the variable to be solved.
In this article, we will discuss the steps to execute an LU decomposition algorithm on a square matrix such that it can be written as
for a lower triangular matrix
and an upper triangular matrix
. However, note that, when
has at least a zero on the main diagonal, then one needs to interchange either some of its row or column, and this will involve a row permutation matrix
or a column permutation matrix
that are not equal to the identity matrix. However, for the sake of simplicity, let us assume for now that the main diagonal of
has no zero entries.
The Wikipedia page on LU decomposition is an excellent starting point for understanding the mechanics of this factorization method. Following some of the notations, let us assume that we have a square matrix having no zero on the diagonal. As such, denote
as the
th version of
where all of the elements below its main diagonal have been eliminated to zero through the row reduction method for the first
th columns. Then, at step
, we have
where
is an identity matrix with the exception that its entries below the diagonal at the i-$th column are (most likely) nonzero. Starting from
, then we carried out the following steps until
:
which suggest that and
To illustrate how the above makes sense in the LU decomposition algorithm, let us consider a simple example where is given as:
Firstly, we do the row reduction on the first column. This is performed as follows:
which is equal to:
Thanks to the lower triangular structure of , then it is easy to verify that its inverse,
, is equal to:
Secondly, we repeat the same step but on the second column. This results in:
which is equal to:
Again, it is straightforward to verify that is simply equal to:
That’s it! Now we are ready to compute the LU decomposition. The matrix is equal to:
whereas is nothing but:
At last, we finally have:
Pretty easy, right? Now I want to mention that the process above, which is called the pure LU decomposition, will only work when there is no zero on the main diagonal, or in more technical terms, all its leading principal minors are nonzero. A generalization of LU decomposition is the LUP decomposition, where the letter P here denotes the row permutation matrix. LUP is simply an LU decomposition but with partial pivoting (row). That is, LU decomposition is equal to LUP decomposition in which the permutation matrix is equal to the identity matrix. The aforementioned Wikipedia page on the LU decomposition neatly covers an example of how the LUP decomposition is performed.
Hopefully, this short article can help you in understanding the LU decomposition. For the next articles, I am planning on explaining how the QR decomposition works and comparing the performance between LU and QR decomposition to solve some systems of linear equations on an embedded system. Stay tuned!