logo

LU Decomposition of Invertible Matrices 📂Matrix Algebra

LU Decomposition of Invertible Matrices

Buildup

When the matrix Matrix ARm×mA \in \mathbb{R}^{m \times m} is multiplied on the left side such that the component (i,j)(i, j) becomes 00, the matrix EijE_{ij} is defined as the AA Elimination Operator for ijij.

Specifically, for the square matrix Square Matrix (aij)Rm×m(a_{ij}) \in \mathbb{R}^{m \times m}, EijE_{ij} has the diagonal components as 11, the (i,j)(i,j) component as mij=aijajj\displaystyle -m_{ij} = -{{a_{ij}} \over {a_{jj}}}, and the remaining components as 00. This represents the operation of eliminating the same variables to match the coefficients in the solution of simultaneous equations in matrix form. Such elimination is meaningful only when there exists only one solution to the simultaneous equations, so the AA we deal with is assumed to be an Invertible Matrix.

Example

For a simple example, B:=[210121012] B := \begin{bmatrix} 2 & 1 & 0 \\ 1 & 2 & 1 \\ 0 & 1 & 2 \end{bmatrix} then we get E21B=[210021012]E_{21} B = \begin{bmatrix} 2 & 1 & 0 \\ 0 & 2 & 1 \\ 0 & 1 & 2 \end{bmatrix}. And since B=[210121012]B = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 2 & 1 \\ 0 & 1 & 2 \end{bmatrix}, the (2,1)(2,1) elimination operator for BB can be calculated as E21=[100mij10001]=[1001210001] E_{21} = \begin{bmatrix} 1 & 0 & 0 \\ -m_{ij} & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ -{{1} \over {2}} & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} Meanwhile, repeated operations of this type on UB:=E32E31E21B=[210021002] U_{B} : = E_{32} E_{31} E_{21} B = \begin{bmatrix} 2 & 1 & 0 \\ 0 & 2 & 1 \\ 0 & 0 & 2 \end{bmatrix} results in an Upper Triangular Matrix, and all E21,E31,E32E_{21} , E_{31} , E_{32} are Lower Triangular Matrices. Since the product of lower triangular matrices is a lower triangular matrix, LB:=E21E31E32L_{B} : = E_{21} E_{31} E_{32} is also a lower triangular matrix and can be represented as L1B=UL^{-1} B = U. Rearranging for BB yields B=LBUBB = L_{B} U_{B}, decomposing into the product of a lower and upper triangular matrix.

This decomposition method can be generalized without issue even for the case of ARn×nA \in \mathbb{R}^{n \times n} due to its simplicity. Thinking about the solution method for the simultaneous equations Ax=bA \mathbf{x} = \mathbf{b}, since AA can be decomposed into A=LUA = LU, LUx=by:=Ux \begin{align*} LU \mathbf{x} =& \mathbf{b} \\ \mathbf{y} :=& U \mathbf{x} \end{align*} can be stated. Here, since UU is an upper triangular matrix, y\mathbf{y} can be easily found using back substitution, and L(Ux)=Ly=b \begin{align*} L (U \mathbf{x} ) =& L \\ \mathbf{y} =& \mathbf{b} \end{align*} since LL is a lower triangular matrix, b\mathbf{b} can be easily found using forward substitution. Therefore, being able to actually calculate LU decomposition means that a wide variety of problems can be solved quite easily and quickly.

Derivation

Now, to directly find LL and UU, let’s define the lower triangular matrix LL that satisfies A:=LUA := L U and the Upper Triangular Matrix UU as follows. L:=[1000l21100l31l3210ln1ln2ln31]U:=[u11u12u13u1n0u22u23u2n00u33u3n000unn] \begin{align*} L : =& \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ l_{21} & 1 & 0 & \cdots & 0 \\ l_{31} & l_{32} & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ l_{n1} & l_{n2} & l_{n3} & \cdots & 1 \end{bmatrix} \\ U : =& \begin{bmatrix} u_{11} & u_{12} & u_{13} & \cdots & u_{1n} \\ 0 & u_{22} & u_{23} & \cdots & u_{2n} \\ 0 & 0 & u_{33} & \cdots & u_{3n} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & u_{nn} \end{bmatrix}\end{align*} Here, it can easily be verified that all the diagonal components of LL are 11. According to the above definition, calculating the component aija_{ij} of A=(aij)A = (a_{ij}) yields aij=s=1nlisusj=s=1min(i,j)lisusj a_{ij} = \sum_{s = 1}^{n} l_{is} u_{sj} = \sum_{s = 1}^{min(i , j)} l_{is} u_{sj} Now, let’s consider aija_{ij} depending on whether it is on the diagonal, above the diagonal, or below the diagonal.

If i=j=ki = j = k,

akk=s=1min(i,j)lksusk=s=1klksusk=s=1k1lksusk+lkkukk=s=1k1lksusk+ukk \begin{align*} a_{kk} =& \sum_{s = 1}^{\min(i, j)} l_{ks} u_{sk} \\ =& \sum_{s = 1}^{k} l_{ks} u_{sk} \\ =& \sum_{s = 1}^{k-1} l_{ks} u_{sk} + l_{kk} u_{kk} \\ =& \sum_{s = 1}^{k-1} l_{ks} u_{sk} + u_{kk} \end{align*}

Arranging this for ukku_{kk},

ukk=akks=1k1lksusk u_{kk} = a_{kk} - \sum_{s = 1}^{k-1} l_{ks} u_{sk}

can be obtained. Similarly, if k<jk < j, akj=s=1k1lksusj+ukj a_{kj} = \sum_{s = 1}^{k-1} l_{ks} u_{sj} + u_{kj} and if k<ik < i, aik=s=1k1lisusk+likukk a_{ik} = \sum_{s = 1}^{k-1} l_{is} u_{sk} + l_{ik} u_{kk} can be obtained. Arranging these for ukju_{kj} and likl_{ik} respectively yields: ukj=akjs=1k1lksusjlik=1ukk{aiks=1k1lisusk} \begin{align*} u_{kj} =& a_{kj} - \sum_{s = 1}^{k-1} l_{ks} u_{sj} \\ l_{ik} =& {{ 1 } \over {u_{kk} }} \left\{ a_{ik} - \sum_{s = 1}^{k-1} l_{is} u_{sk} \right\} \end{align*}

Algorithm

Assuming (aij)Rn×n(a_{ij}) \in \mathbb{R}^{n \times n} is an invertible matrix.

Step 1. k=1k = 1

Substitute u1j=a1ju_{1j} = a_{1j} and calculate li1=1u11ai1\displaystyle l_{i1} = {{1} \over {u_{11}}} a_{i1}.


Step 2. k=2,3,,n1k = 2, 3, \cdots , n-1

  • Step 2-1. Calculate the following. ukk=akks=1k1lksusk u_{kk} = a_{kk} - \sum_{s = 1}^{k-1} l_{ks} u_{sk}
  • Step 2-2. For j=k+1,k+2,,n1j = k+1 , k+2 , \cdots , n-1, calculate the following: ukj=akjs=1k1lksusj u_{kj} = a_{kj} - \sum_{s = 1}^{k-1} l_{ks} u_{sj}
  • Step 2-3. For i=k+1,k+2,,n1i = k+1 , k+2 , \cdots , n-1, calculate the following: lik=1ukk{aiks=1k1lisusk} l_{ik} = {{ 1 } \over {u_{kk} }} \left\{ a_{ik} - \sum_{s = 1}^{k-1} l_{is} u_{sk} \right\}

Step 3. For k=nk = n, calculate the following: unn=anns=1n1lnsusn u_{nn} = a_{nn} - \sum_{s = 1}^{n-1} l_{ns} u_{sn}


  • Careful examination of the algorithm reveals that as kk increases, LL is calculated from left to right and UU from top to bottom. The necessary values at each step are ensured to have been calculated in the previous steps, making the calculation unit at each step either one row or one column.

Code

Let’s actually decompose the matrix BB used in the example above.

20171126\_225019.png

Below is the actual implementation of the above algorithm in R.

B <- matrix(c(2,1,0,1,2,1,0,1,2), ncol= 3); B
 
LU<-function(A)
{
  n=length(A[,1])
  L<-diag(1,n)
  U<-diag(0,n)
 
  k=1
  j=1
  i=1
  U[1,]<-A[1,]
  L[,1]<-A[,1]/A[1,1]
  
  for(k in 2:(n-1))
  {
    U[k,k] = A[k,k] - sum(L[k,1:(k-1)]*U[1:(k-1),k])
    for(j in (k+1):n)
    {
      U[k,j] = A[k,j] - sum(L[k,1:(k-1)]*U[1:(k-1),j])
    }
    for(i in (k+1):n)
    {
      L[i,k] = ( A[i,k] - sum(L[i,1:(k-1)]*U[1:(k-1),k]) ) / U[k,k]
    }
  }
  
  U[n,n] = A[n,n] - sum(L[n,1:(n-1)]*U[1:(n-1),n])
  
  return(list(L=L,U=U))
}
 
LU(B)
require(Matrix)
expand(lu(B))

The result is as follows.

20171126\_225002.png

It can be confirmed that the LU decomposition implemented in R itself matches exactly.

See also