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.2: Triangular systems

Some systems can be solved one variable at a time, with almost no rearranging. The useful feature is a pattern of zeros in their coefficient matrices.


Upper triangular systems

Consider

3x−2y=8,2y=4.\begin{aligned}3x-2y&=8,\\2y&=4.\end{aligned}

The second equation gives y=2y=2. Substitute into the first: 3x−4=83x-4=8, so x=4x=4. In matrix form,

[3−202][xy]=[84].\begin{bmatrix}3&-2\\0&2\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} =\begin{bmatrix}8\\4\end{bmatrix}.

The zero in the bottom-left position is doing useful work: the last equation contains only the last variable.

For example,

U=[2−1403500−2],L=[200−13031−2]U=\begin{bmatrix}2&-1&4\\0&3&5\\0&0&-2\end{bmatrix},\qquad L=\begin{bmatrix}2&0&0\\-1&3&0\\3&1&-2\end{bmatrix}

are upper and lower triangular, respectively. Entries on the other side of the diagonal are allowed to be zero too. A diagonal matrix is both upper and lower triangular.


Back substitution

For an upper triangular system with nonzero diagonal entries, we start at the bottom and work upward. This is called back substitution.

Let’s solve

[4−2203−1005][x1x2x3]=[6315].\begin{bmatrix}4&-2&2\\0&3&-1\\0&0&5\end{bmatrix}\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} =\begin{bmatrix}6\\3\\15\end{bmatrix}.

Writing out the equations makes the order clear:

4x1−2x2+2x3=6,3x2−x3=3,5x3=15.\begin{aligned}4x_1-2x_2+2x_3&=6,\\3x_2-x_3&=3,\\5x_3&=15.\end{aligned}

The last equation gives x3=3x_3=3. The second then gives 3x2−3=33x_2-3=3, so x2=2x_2=2. Finally,

4x1−2(2)+2(3)=6⟹x1=1.4x_1-2(2)+2(3)=6\quad\Longrightarrow\quad x_1=1.

Thus x⃗=[123]\vec x=\begin{bmatrix}1\\2\\3\end{bmatrix}. Check it by multiplying the original matrix by this vector.


Forward substitution

For a lower triangular system, the direction reverses. Consider

[200−13031−2][xyz]=[471].\begin{bmatrix}2&0&0\\-1&3&0\\3&1&-2\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix} =\begin{bmatrix}4\\7\\1\end{bmatrix}.

This time the first equation contains only one variable:

2x=4⟹x=2,−x+3y=7⟹−2+3y=7⟹y=3,3x+y−2z=1⟹6+3−2z=1⟹z=4.\begin{aligned}2x=4&\quad\Longrightarrow\quad x=2,\\ -x+3y=7&\quad\Longrightarrow\quad -2+3y=7\quad\Longrightarrow\quad y=3,\\ 3x+y-2z=1&\quad\Longrightarrow\quad6+3-2z=1\quad\Longrightarrow\quad z=4. \end{aligned}

The solution is [xyz]=[234]\begin{bmatrix}x\\y\\z\end{bmatrix}=\begin{bmatrix}2\\3\\4\end{bmatrix}.


Why the diagonal matters

At each step, we divide by a diagonal entry. The diagonal entries don’t need to be 1, but they do need to be nonzero for this procedure to determine one new variable at every step.

For instance,

[2100][xy]=[73]\begin{bmatrix}2&1\\0&0\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} =\begin{bmatrix}7\\3\end{bmatrix}

has a last equation 0=30=3, so it has no solution. Replacing the right-hand side by [70]\begin{bmatrix}7\\0\end{bmatrix} gives 0=00=0 instead. Then yy is unrestricted, and x=(7−y)/2x=(7-y)/2 gives infinitely many solutions.

We’ll study these possibilities in Chapter 4.5. For now, our triangular solves will have nonzero diagonal entries.