Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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

The letters remind us of lower and upper. Throughout this chapter, we require ones on the diagonal of LL.

If A=LUA=LU, then Ax⃗=b⃗A\vec x=\vec b becomes L(Ux⃗)=b⃗L(U\vec x)=\vec b. Give the intermediate vector a name: y⃗=Ux⃗\vec y=U\vec x. Now we can work backward from b⃗\vec b:

x⃗→ U y⃗→ L b⃗.\vec x\xrightarrow{\ U\ }\vec y\xrightarrow{\ L\ }\vec b.

Although UU acts first on x⃗\vec x, we solve the LL-system first. We know b⃗\vec 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−12].A=\begin{bmatrix}3&-1\\-1&2\end{bmatrix}.

Start with the required shapes and multiply:

[10ℓ1][pq0r]=[pqℓ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}.

Match this product to AA, one row and column at a time.

First, find the first row of UU. Matching the top row gives p=3p=3 and q=−1q=-1.

Next, find the first column of LL. Matching the bottom-left entry gives 3ℓ=−13\ell=-1, so ℓ=−13\ell=-\frac13.

Finally, find the second row of UU. Matching the bottom-right entry gives

(−13)(−1)+r=2⟹r=53.\left(-\frac13\right)(-1)+r=2\quad\Longrightarrow\quad r=\frac53.

Therefore,

A=[10−131]⏟L[3−1053]⏟U.\boxed{A=\underbrace{\begin{bmatrix}1&0\\-\frac13&1\end{bmatrix}}_L \underbrace{\begin{bmatrix}3&-1\\0&\frac53\end{bmatrix}}_U.}

Integer entries in AA can produce fractions in LL and UU. That’s fine! Multiplying the factors gives

LU=[3−1−113+53]=[3−1−12]=A.LU=\begin{bmatrix}3&-1\\-1&\frac13+\frac53\end{bmatrix} =\begin{bmatrix}3&-1\\-1&2\end{bmatrix}=A.

Solving the circuit

Our original system was AV⃗=b⃗A\vec V=\vec b, where b⃗=[150]\vec b=\begin{bmatrix}15\\0\end{bmatrix}.

First solve Ly⃗=b⃗L\vec y=\vec b:

[10−131][y1y2]=[150].\begin{bmatrix}1&0\\-\frac13&1\end{bmatrix}\begin{bmatrix}y_1\\y_2\end{bmatrix} =\begin{bmatrix}15\\0\end{bmatrix}.

The first equation gives y1=15y_1=15. The second gives −13(15)+y2=0-\frac13(15)+y_2=0, so y2=5y_2=5.

Next solve UV⃗=y⃗U\vec V=\vec y:

[3−1053][V1V2]=[155].\begin{bmatrix}3&-1\\0&\frac53\end{bmatrix}\begin{bmatrix}V_1\\V_2\end{bmatrix} =\begin{bmatrix}15\\5\end{bmatrix}.

Start at the bottom: 53V2=5\frac53V_2=5, so V2=3V_2=3. Then 3V1−3=153V_1-3=15, so V1=6V_1=6.

V⃗=[63] volts.\boxed{\vec V=\begin{bmatrix}6\\3\end{bmatrix}\text{ volts}.}

Does this agree with the physical model? The supply sends (10−6)/2=2(10-6)/2=2 amperes into the first junction. Of these, 6/6=16/6=1 ampere goes directly to ground and (6−3)/3=1(6-3)/3=1 ampere goes to the second junction. From there, 3/3=13/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, AA, LL, and UU stay the same. Only b⃗\vec b changes. For a supply voltage ss, the circuit equations become

AV⃗=[3s/20].A\vec V=\begin{bmatrix}3s/2\\0\end{bmatrix}.

Doubling the supply from 10 to 20 volts doubles b⃗\vec b. The two triangular solves then give V⃗=[126]\vec V=\begin{bmatrix}12\\6\end{bmatrix}, 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−22220−481].A=\begin{bmatrix}4&-2&2\\2&2&0\\-4&8&1\end{bmatrix}.

Write the required shapes:

L=[100ℓ2110ℓ31ℓ321],U=[u11u12u130u22u2300u33].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}.

Step 1: First row of UU. The first row of LULU equals the first row of UU, so

u11=4,u12=−2,u13=2.u_{11}=4,\qquad u_{12}=-2,\qquad u_{13}=2.

Step 2: First column of LL. Matching entries (2,1)(2,1) and (3,1)(3,1) gives

4ℓ21=2,4ℓ31=−4,⟹ℓ21=12,ℓ31=−1.4\ell_{21}=2,\qquad4\ell_{31}=-4, \quad\Longrightarrow\quad\ell_{21}=\frac12,\quad\ell_{31}=-1.

Step 3: Second row of UU. Matching entries (2,2)(2,2) and (2,3)(2,3) gives

12(−2)+u22=2,12(2)+u23=0,⟹u22=3,u23=−1.\frac12(-2)+u_{22}=2,\qquad\frac12(2)+u_{23}=0, \quad\Longrightarrow\quad u_{22}=3,\quad u_{23}=-1.

Step 4: Second column of LL. Matching entry (3,2)(3,2) gives

(−1)(−2)+3ℓ32=8⟹ℓ32=2.(-1)(-2)+3\ell_{32}=8\quad\Longrightarrow\quad\ell_{32}=2.

Step 5: Final entry of UU. Matching entry (3,3)(3,3) gives

(−1)(2)+2(−1)+u33=1⟹u33=5.(-1)(2)+2(-1)+u_{33}=1\quad\Longrightarrow\quad u_{33}=5.

Thus,

L=[1001210−121],U=[4−2203−1005].\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}.}

Always check the product:

LU=[4−222−1+31−1−42+6−2−2+5]=[4−22220−481]=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.

The diagonal entries of UU are called pivots in this factorization procedure. To find entries of LL below a pivot, we divide by that pivot. In the next chapter, we’ll see what can happen when a pivot is zero.