4.3: LU factorization for square matrices
Triangular systems are easy to solve. Can we use them to solve a system whose coefficient matrix isn’t triangular?
The key idea is to write one matrix as a product of two triangular matrices . Then one system becomes two systems that we can solve by substitution.
One system becomes two ¶ An LU factorization of a square matrix A A A is an expression
where L L L is lower triangular with every diagonal entry equal to 1, and U U U is upper triangular.
The letters remind us of lower and upper . Throughout this chapter, we require ones on the diagonal of L L L .
If A = L U A=LU A = LU , then A x ⃗ = b ⃗ A\vec x=\vec b A x = b becomes L ( U x ⃗ ) = b ⃗ L(U\vec x)=\vec b L ( U x ) = b . Give the intermediate vector a name: y ⃗ = U x ⃗ \vec y=U\vec x y = U x . Now we can work backward from b ⃗ \vec b b :
x ⃗ → U y ⃗ → L b ⃗ . \vec x\xrightarrow{\ U\ }\vec y\xrightarrow{\ L\ }\vec b. x U y L b . Although U U U acts first on x ⃗ \vec x x , we solve the L L L -system first. We know b ⃗ \vec b b and are recovering the vectors that led to it.
Finding the factors for the circuit ¶ Return to the coefficient matrix from Chapter 4.1:
A = [ 3 − 1 − 1 2 ] . A=\begin{bmatrix}3&-1\\-1&2\end{bmatrix}. A = [ 3 − 1 − 1 2 ] . Start with the required shapes and multiply:
[ 1 0 ℓ 1 ] [ p q 0 r ] = [ p q ℓ p ℓ q + r ] . \begin{bmatrix}1&0\\\ell&1\end{bmatrix}
\begin{bmatrix}p&q\\0&r\end{bmatrix}
=\begin{bmatrix}p&q\\\ell p&\ell q+r\end{bmatrix}. [ 1 ℓ 0 1 ] [ p 0 q r ] = [ p ℓ p q ℓ q + r ] . Match this product to A A A , one row and column at a time.
First, find the first row of U U U . Matching the top row gives p = 3 p=3 p = 3 and q = − 1 q=-1 q = − 1 .
Next, find the first column of L L L . Matching the bottom-left entry gives 3 ℓ = − 1 3\ell=-1 3 ℓ = − 1 , so ℓ = − 1 3 \ell=-\frac13 ℓ = − 3 1 .
Finally, find the second row of U U U . Matching the bottom-right entry gives
( − 1 3 ) ( − 1 ) + r = 2 ⟹ r = 5 3 . \left(-\frac13\right)(-1)+r=2\quad\Longrightarrow\quad r=\frac53. ( − 3 1 ) ( − 1 ) + r = 2 ⟹ r = 3 5 . Therefore,
A = [ 1 0 − 1 3 1 ] ⏟ L [ 3 − 1 0 5 3 ] ⏟ U . \boxed{A=\underbrace{\begin{bmatrix}1&0\\-\frac13&1\end{bmatrix}}_L
\underbrace{\begin{bmatrix}3&-1\\0&\frac53\end{bmatrix}}_U.} A = L [ 1 − 3 1 0 1 ] U [ 3 0 − 1 3 5 ] . Integer entries in A A A can produce fractions in L L L and U U U . That’s fine! Multiplying the factors gives
L U = [ 3 − 1 − 1 1 3 + 5 3 ] = [ 3 − 1 − 1 2 ] = A . LU=\begin{bmatrix}3&-1\\-1&\frac13+\frac53\end{bmatrix}
=\begin{bmatrix}3&-1\\-1&2\end{bmatrix}=A. LU = [ 3 − 1 − 1 3 1 + 3 5 ] = [ 3 − 1 − 1 2 ] = A . Solving the circuit ¶ Our original system was A V ⃗ = b ⃗ A\vec V=\vec b A V = b , where b ⃗ = [ 15 0 ] \vec b=\begin{bmatrix}15\\0\end{bmatrix} b = [ 15 0 ] .
First solve L y ⃗ = b ⃗ L\vec y=\vec b L y = b :
[ 1 0 − 1 3 1 ] [ y 1 y 2 ] = [ 15 0 ] . \begin{bmatrix}1&0\\-\frac13&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\end{bmatrix}
=\begin{bmatrix}15\\0\end{bmatrix}. [ 1 − 3 1 0 1 ] [ y 1 y 2 ] = [ 15 0 ] . The first equation gives y 1 = 15 y_1=15 y 1 = 15 . The second gives − 1 3 ( 15 ) + y 2 = 0 -\frac13(15)+y_2=0 − 3 1 ( 15 ) + y 2 = 0 , so y 2 = 5 y_2=5 y 2 = 5 .
Next solve U V ⃗ = y ⃗ U\vec V=\vec y U V = y :
[ 3 − 1 0 5 3 ] [ V 1 V 2 ] = [ 15 5 ] . \begin{bmatrix}3&-1\\0&\frac53\end{bmatrix}\begin{bmatrix}V_1\\V_2\end{bmatrix}
=\begin{bmatrix}15\\5\end{bmatrix}. [ 3 0 − 1 3 5 ] [ V 1 V 2 ] = [ 15 5 ] . Start at the bottom: 5 3 V 2 = 5 \frac53V_2=5 3 5 V 2 = 5 , so V 2 = 3 V_2=3 V 2 = 3 . Then 3 V 1 − 3 = 15 3V_1-3=15 3 V 1 − 3 = 15 , so V 1 = 6 V_1=6 V 1 = 6 .
V ⃗ = [ 6 3 ] volts . \boxed{\vec V=\begin{bmatrix}6\\3\end{bmatrix}\text{ volts}.} V = [ 6 3 ] volts . Does this agree with the physical model? The supply sends ( 10 − 6 ) / 2 = 2 (10-6)/2=2 ( 10 − 6 ) /2 = 2 amperes into the first junction. Of these, 6 / 6 = 1 6/6=1 6/6 = 1 ampere goes directly to ground and ( 6 − 3 ) / 3 = 1 (6-3)/3=1 ( 6 − 3 ) /3 = 1 ampere goes to the second junction. From there, 3 / 3 = 1 3/3=1 3/3 = 1 ampere flows to ground. Both junctions balance.
Reusing the same factors ¶ For one small system, factoring may feel like extra work. Its value becomes clearer when we solve several systems with the same coefficient matrix .
If we change the supply voltage but keep the resistors, A A A , L L L , and U U U stay the same. Only b ⃗ \vec b b changes. For a supply voltage s s s , the circuit equations become
A V ⃗ = [ 3 s / 2 0 ] . A\vec V=\begin{bmatrix}3s/2\\0\end{bmatrix}. A V = [ 3 s /2 0 ] . Doubling the supply from 10 to 20 volts doubles b ⃗ \vec b b . The two triangular solves then give V ⃗ = [ 12 6 ] \vec V=\begin{bmatrix}12\\6\end{bmatrix} V = [ 12 6 ] , without finding the factors again.
For large systems, finding the factors is usually the expensive part. Once we have them, each new right-hand side requires only two triangular solves.
A three-by-three example ¶ The same approach works for larger matrices. Let’s factor
A = [ 4 − 2 2 2 2 0 − 4 8 1 ] . A=\begin{bmatrix}4&-2&2\\2&2&0\\-4&8&1\end{bmatrix}. A = ⎣ ⎡ 4 2 − 4 − 2 2 8 2 0 1 ⎦ ⎤ . Write the required shapes:
L = [ 1 0 0 ℓ 21 1 0 ℓ 31 ℓ 32 1 ] , U = [ u 11 u 12 u 13 0 u 22 u 23 0 0 u 33 ] . L=\begin{bmatrix}1&0&0\\\ell_{21}&1&0\\\ell_{31}&\ell_{32}&1\end{bmatrix},\qquad
U=\begin{bmatrix}u_{11}&u_{12}&u_{13}\\0&u_{22}&u_{23}\\0&0&u_{33}\end{bmatrix}. L = ⎣ ⎡ 1 ℓ 21 ℓ 31 0 1 ℓ 32 0 0 1 ⎦ ⎤ , U = ⎣ ⎡ u 11 0 0 u 12 u 22 0 u 13 u 23 u 33 ⎦ ⎤ . Step 1: First row of U U U . The first row of L U LU LU equals the first row of U U U , so
u 11 = 4 , u 12 = − 2 , u 13 = 2. u_{11}=4,\qquad u_{12}=-2,\qquad u_{13}=2. u 11 = 4 , u 12 = − 2 , u 13 = 2. Step 2: First column of L L L . Matching entries ( 2 , 1 ) (2,1) ( 2 , 1 ) and ( 3 , 1 ) (3,1) ( 3 , 1 ) gives
4 ℓ 21 = 2 , 4 ℓ 31 = − 4 , ⟹ ℓ 21 = 1 2 , ℓ 31 = − 1. 4\ell_{21}=2,\qquad4\ell_{31}=-4,
\quad\Longrightarrow\quad\ell_{21}=\frac12,\quad\ell_{31}=-1. 4 ℓ 21 = 2 , 4 ℓ 31 = − 4 , ⟹ ℓ 21 = 2 1 , ℓ 31 = − 1. Step 3: Second row of U U U . Matching entries ( 2 , 2 ) (2,2) ( 2 , 2 ) and ( 2 , 3 ) (2,3) ( 2 , 3 ) gives
1 2 ( − 2 ) + u 22 = 2 , 1 2 ( 2 ) + u 23 = 0 , ⟹ u 22 = 3 , u 23 = − 1. \frac12(-2)+u_{22}=2,\qquad\frac12(2)+u_{23}=0,
\quad\Longrightarrow\quad u_{22}=3,\quad u_{23}=-1. 2 1 ( − 2 ) + u 22 = 2 , 2 1 ( 2 ) + u 23 = 0 , ⟹ u 22 = 3 , u 23 = − 1. Step 4: Second column of L L L . Matching entry ( 3 , 2 ) (3,2) ( 3 , 2 ) gives
( − 1 ) ( − 2 ) + 3 ℓ 32 = 8 ⟹ ℓ 32 = 2. (-1)(-2)+3\ell_{32}=8\quad\Longrightarrow\quad\ell_{32}=2. ( − 1 ) ( − 2 ) + 3 ℓ 32 = 8 ⟹ ℓ 32 = 2. Step 5: Final entry of U U U . Matching entry ( 3 , 3 ) (3,3) ( 3 , 3 ) gives
( − 1 ) ( 2 ) + 2 ( − 1 ) + u 33 = 1 ⟹ u 33 = 5. (-1)(2)+2(-1)+u_{33}=1\quad\Longrightarrow\quad u_{33}=5. ( − 1 ) ( 2 ) + 2 ( − 1 ) + u 33 = 1 ⟹ u 33 = 5. Thus,
L = [ 1 0 0 1 2 1 0 − 1 2 1 ] , U = [ 4 − 2 2 0 3 − 1 0 0 5 ] . \boxed{L=\begin{bmatrix}1&0&0\\\frac12&1&0\\-1&2&1\end{bmatrix},\qquad
U=\begin{bmatrix}4&-2&2\\0&3&-1\\0&0&5\end{bmatrix}.} L = ⎣ ⎡ 1 2 1 − 1 0 1 2 0 0 1 ⎦ ⎤ , U = ⎣ ⎡ 4 0 0 − 2 3 0 2 − 1 5 ⎦ ⎤ . Always check the product:
L U = [ 4 − 2 2 2 − 1 + 3 1 − 1 − 4 2 + 6 − 2 − 2 + 5 ] = [ 4 − 2 2 2 2 0 − 4 8 1 ] = A . LU=\begin{bmatrix}4&-2&2\\2&-1+3&1-1\\-4&2+6&-2-2+5\end{bmatrix}
=\begin{bmatrix}4&-2&2\\2&2&0\\-4&8&1\end{bmatrix}=A. LU = ⎣ ⎡ 4 2 − 4 − 2 − 1 + 3 2 + 6 2 1 − 1 − 2 − 2 + 5 ⎦ ⎤ = ⎣ ⎡ 4 2 − 4 − 2 2 8 2 0 1 ⎦ ⎤ = A . Find row 1 of U U U , column 1 of L L L , row 2 of U U U , column 2 of L L L , and so on. Compute only entries that aren’t already fixed by the triangular shapes or the ones on the diagonal of L L L .
The diagonal entries of U U U are called pivots in this factorization procedure. To find entries of L L L below a pivot, we divide by that pivot. In the next chapter, we’ll see what can happen when a pivot is zero.
Find an LU factorization of [ 3 6 − 3 − 4 − 5 10 5 8 − 4 ] \begin{bmatrix}3&6&-3\\-4&-5&10\\5&8&-4\end{bmatrix} ⎣ ⎡ 3 − 4 5 6 − 5 8 − 3 10 − 4 ⎦ ⎤ without reordering its rows. Check your product.
Use the worked example’s factors for A = [ 4 − 2 2 2 2 0 − 4 8 1 ] A=\begin{bmatrix}4&-2&2\\2&2&0\\-4&8&1\end{bmatrix} A = ⎣ ⎡ 4 2 − 4 − 2 2 8 2 0 1 ⎦ ⎤ to solve A x ⃗ = [ 6 6 15 ] A\vec x=\begin{bmatrix}6\\6\\15\end{bmatrix} A x = ⎣ ⎡ 6 6 15 ⎦ ⎤ .
Explain why the intermediate vector y ⃗ \vec y y is generally different from the solution x ⃗ \vec x x .
1. For A = [ 3 6 − 3 − 4 − 5 10 5 8 − 4 ] A=\begin{bmatrix}3&6&-3\\-4&-5&10\\5&8&-4\end{bmatrix} A = ⎣ ⎡ 3 − 4 5 6 − 5 8 − 3 10 − 4 ⎦ ⎤ , the first row of U U U is [ 3 6 − 3 ] \begin{bmatrix}3&6&-3\end{bmatrix} [ 3 6 − 3 ] . Matching the first column gives ℓ 21 = − 4 3 \ell_{21}=-\frac43 ℓ 21 = − 3 4 and ℓ 31 = 5 3 \ell_{31}=\frac53 ℓ 31 = 3 5 .
Next, ( − 4 3 ) 6 + u 22 = − 5 (-\frac43)6+u_{22}=-5 ( − 3 4 ) 6 + u 22 = − 5 gives u 22 = 3 u_{22}=3 u 22 = 3 , and ( − 4 3 ) ( − 3 ) + u 23 = 10 (-\frac43)(-3)+u_{23}=10 ( − 3 4 ) ( − 3 ) + u 23 = 10 gives u 23 = 6 u_{23}=6 u 23 = 6 . Then ( 5 3 ) 6 + 3 ℓ 32 = 8 (\frac53)6+3\ell_{32}=8 ( 3 5 ) 6 + 3 ℓ 32 = 8 gives ℓ 32 = − 2 3 \ell_{32}=-\frac23 ℓ 32 = − 3 2 . Finally, ( 5 3 ) ( − 3 ) + ( − 2 3 ) 6 + u 33 = − 4 (\frac53)(-3)+(-\frac23)6+u_{33}=-4 ( 3 5 ) ( − 3 ) + ( − 3 2 ) 6 + u 33 = − 4 gives u 33 = 5 u_{33}=5 u 33 = 5 .
Thus
L = [ 1 0 0 − 4 3 1 0 5 3 − 2 3 1 ] , U = [ 3 6 − 3 0 3 6 0 0 5 ] . L=\begin{bmatrix}1&0&0\\-\frac43&1&0\\\frac53&-\frac23&1\end{bmatrix},\qquad U=\begin{bmatrix}3&6&-3\\0&3&6\\0&0&5\end{bmatrix}. L = ⎣ ⎡ 1 − 3 4 3 5 0 1 − 3 2 0 0 1 ⎦ ⎤ , U = ⎣ ⎡ 3 0 0 6 3 0 − 3 6 5 ⎦ ⎤ . The product checks:
L U = [ 3 6 − 3 − 4 − 8 + 3 4 + 6 5 10 − 2 − 5 − 4 + 5 ] = A . LU=\begin{bmatrix}3&6&-3\\-4&-8+3&4+6\\5&10-2&-5-4+5\end{bmatrix}=A. LU = ⎣ ⎡ 3 − 4 5 6 − 8 + 3 10 − 2 − 3 4 + 6 − 5 − 4 + 5 ⎦ ⎤ = A . 2. For the different matrix A = [ 4 − 2 2 2 2 0 − 4 8 1 ] A=\begin{bmatrix}4&-2&2\\2&2&0\\-4&8&1\end{bmatrix} A = ⎣ ⎡ 4 2 − 4 − 2 2 8 2 0 1 ⎦ ⎤ , the factors are
L = [ 1 0 0 1 2 1 0 − 1 2 1 ] , U = [ 4 − 2 2 0 3 − 1 0 0 5 ] . L=\begin{bmatrix}1&0&0\\\frac12&1&0\\-1&2&1\end{bmatrix},\qquad U=\begin{bmatrix}4&-2&2\\0&3&-1\\0&0&5\end{bmatrix}. L = ⎣ ⎡ 1 2 1 − 1 0 1 2 0 0 1 ⎦ ⎤ , U = ⎣ ⎡ 4 0 0 − 2 3 0 2 − 1 5 ⎦ ⎤ . Solve L y ⃗ = [ 6 6 15 ] L\vec y=\begin{bmatrix}6\\6\\15\end{bmatrix} L y = ⎣ ⎡ 6 6 15 ⎦ ⎤ : y 1 = 6 y_1=6 y 1 = 6 , 1 2 ( 6 ) + y 2 = 6 \frac12(6)+y_2=6 2 1 ( 6 ) + y 2 = 6 gives y 2 = 3 y_2=3 y 2 = 3 , and − 6 + 2 ( 3 ) + y 3 = 15 -6+2(3)+y_3=15 − 6 + 2 ( 3 ) + y 3 = 15 gives y 3 = 15 y_3=15 y 3 = 15 .
Then U x ⃗ = [ 6 3 15 ] U\vec x=\begin{bmatrix}6\\3\\15\end{bmatrix} U x = ⎣ ⎡ 6 3 15 ⎦ ⎤ gives x 3 = 3 x_3=3 x 3 = 3 , 3 x 2 − 3 = 3 3x_2-3=3 3 x 2 − 3 = 3 gives x 2 = 2 x_2=2 x 2 = 2 , and 4 x 1 − 4 + 6 = 6 4x_1-4+6=6 4 x 1 − 4 + 6 = 6 gives x 1 = 1 x_1=1 x 1 = 1 .
x ⃗ = [ 1 2 3 ] . \boxed{\vec x=\begin{bmatrix}1\\2\\3\end{bmatrix}.} x = ⎣ ⎡ 1 2 3 ⎦ ⎤ . Indeed, A x ⃗ = [ 4 − 4 + 6 2 + 4 − 4 + 16 + 3 ] = [ 6 6 15 ] A\vec x=\begin{bmatrix}4-4+6\\2+4\\-4+16+3\end{bmatrix}=\begin{bmatrix}6\\6\\15\end{bmatrix} A x = ⎣ ⎡ 4 − 4 + 6 2 + 4 − 4 + 16 + 3 ⎦ ⎤ = ⎣ ⎡ 6 6 15 ⎦ ⎤ .
3. The intermediate vector satisfies y ⃗ = U x ⃗ \vec y=U\vec x y = U x , so it is the result of applying U U U to the solution. It need not equal x ⃗ \vec x x . Here y ⃗ = [ 6 3 15 ] \vec y=\begin{bmatrix}6\\3\\15\end{bmatrix} y = ⎣ ⎡ 6 3 15 ⎦ ⎤ while x ⃗ = [ 1 2 3 ] \vec x=\begin{bmatrix}1\\2\\3\end{bmatrix} x = ⎣ ⎡ 1 2 3 ⎦ ⎤ .