Tutorials › Linear Algebra › Solving Permuted Systems From PA = LU

LU Factorization and Numerical Considerations · Tutorial 910 of 1000

Solving Permuted Systems From PA = LU

Use the permutation in a PA = LU factorization to transform the right-hand side, solve the triangular systems, and check the result in the original system.

Intermediate 9 min read

What You'll Learn

  • Explain why solving Ax = b from PA = LU requires permuting b.
  • Apply a permutation matrix to a right-hand side by reordering its entries.
  • Solve the lower-triangular system Ly = Pb by forward substitution.
  • Solve the upper-triangular system Ux = y by back substitution.
  • State when the factorization gives a unique solution for every right-hand side.
  • Check a computed solution by multiplying it by the original matrix A.

Why the Right-Hand Side Must Be Permuted

When elimination uses row exchanges, the factorization records those exchanges in a permutation matrix. The resulting identity is \( \mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), not simply \(\mathbf{A}=\mathbf{L}\mathbf{U}\). Consequently, solving \(\mathbf{A}\mathbf{x}=\mathbf{b}\) requires applying the same row permutation to \(\mathbf{b}\) before using the triangular factors. Forgetting this step, or applying the permutation in the wrong direction, can produce a vector that solves a different system.

Here \(\mathbf{A}\in\mathbb{R}^{n\times n}\), \(\mathbf{b},\mathbf{x}\in\mathbb{R}^n\), and \(\mathbf{P}\) is an \(n\times n\) permutation matrix: it is obtained by reordering the rows of the identity matrix. Multiplying a vector by \(\mathbf{P}\) reorders its entries in that same row order. The factors in a standard pivoted LU factorization are a unit lower-triangular matrix \(\mathbf{L}\), with diagonal entries all equal to \(1\), and an upper-triangular matrix \(\mathbf{U}\).

Key idea: If \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), then solve \(\mathbf{A}\mathbf{x}=\mathbf{b}\) by first solving \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\), then solving \(\mathbf{U}\mathbf{x}=\mathbf{y}\). The intermediate vector \(\mathbf{y}\) is the solution of the first triangular system; it is not the final solution \(\mathbf{x}\).

To see why the permutation acts on the right-hand side, multiply the original equation on the left by \(\mathbf{P}\). The result is \(\mathbf{P}\mathbf{A}\mathbf{x}=\mathbf{P}\mathbf{b}\). Replacing \(\mathbf{P}\mathbf{A}\) by \(\mathbf{L}\mathbf{U}\) gives \(\mathbf{L}\mathbf{U}\mathbf{x}=\mathbf{P}\mathbf{b}\). Set \(\mathbf{y}=\mathbf{U}\mathbf{x}\). Then the equation separates into \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\) and \(\mathbf{U}\mathbf{x}=\mathbf{y}\).

The Solve Procedure and Why It Works

For a lower-triangular matrix, forward substitution determines entries from top to bottom. If \(\mathbf{L}\) is unit lower-triangular, the equations in \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\) give

$$ y_i=(\mathbf{P}\mathbf{b})_i-\sum_{j=1}^{i-1}l_{ij}y_j,\qquad i=1,\dots,n. $$

For an upper-triangular matrix with nonzero diagonal entries, back substitution determines entries from bottom to top:

$$ x_i=\frac{1}{u_{ii}}\left(y_i-\sum_{j=i+1}^{n}u_{ij}x_j\right),\qquad i=n,n-1,\dots,1. $$
Theorem: Suppose \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{P}\) is a permutation matrix, \(\mathbf{L}\) is unit lower-triangular, and \(\mathbf{U}\) is upper-triangular with \(u_{ii}\ne0\) for every \(i\). Then for every \(\mathbf{b}\in\mathbb{R}^n\), the system \(\mathbf{A}\mathbf{x}=\mathbf{b}\) has exactly one solution. It is obtained by solving \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\) and then \(\mathbf{U}\mathbf{x}=\mathbf{y}\).

Proof. Assume the stated factorization and let \(\mathbf{b}\) be any vector in \(\mathbb{R}^n\). A permutation matrix reorders rows, so its rows are the standard basis vectors in some order. Their dot products are \(1\) with themselves and \(0\) with one another; therefore \(\mathbf{P}\mathbf{P}^{\top}=\mathbf{I}_n\), and \(\mathbf{P}^{-1}=\mathbf{P}^{\top}\). Thus multiplying an equation by \(\mathbf{P}\) preserves equivalence: \(\mathbf{A}\mathbf{x}=\mathbf{b}\) holds exactly when \(\mathbf{P}\mathbf{A}\mathbf{x}=\mathbf{P}\mathbf{b}\) holds. Using the factorization, this last equation is \(\mathbf{L}\mathbf{U}\mathbf{x}=\mathbf{P}\mathbf{b}\).

Because \(\mathbf{L}\) is unit lower-triangular, its \(i\)th equation has coefficient \(1\) on \(y_i\), involves only \(y_1,\dots,y_i\), and determines \(y_i\) once \(y_1,\dots,y_{i-1}\) are known. Starting at \(i=1\), the forward-substitution formula therefore determines a unique \(\mathbf{y}\) satisfying \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\). Because each \(u_{ii}\ne0\), the \(i\)th equation of \(\mathbf{U}\mathbf{x}=\mathbf{y}\) determines \(x_i\) from \(x_{i+1},\dots,x_n\). Starting at \(i=n\), back substitution determines a unique \(\mathbf{x}\). For that vector, \(\mathbf{L}\mathbf{U}\mathbf{x}=\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\), so \(\mathbf{P}\mathbf{A}\mathbf{x}=\mathbf{P}\mathbf{b}\). Multiplying by \(\mathbf{P}^{\top}\) gives \(\mathbf{A}\mathbf{x}=\mathbf{b}\). Any solution of the original system would also give a solution of both triangular systems, whose solutions are unique; hence the original solution is unique as well. \(\square\)

The nonzero diagonal condition on \(\mathbf{U}\) matters: it ensures that every back-substitution step can divide by \(u_{ii}\). If a diagonal entry is zero, this procedure does not guarantee a unique solution; the system may be inconsistent or may have more than one solution. In the examples below, all diagonal entries of \(\mathbf{U}\) are nonzero.

Worked Solves

Worked Example: One Row Exchange in a Three-Variable System

Suppose

$$ \mathbf{A}= \begin{bmatrix} 0&2&1\\ 1&1&0\\ 2&0&1 \end{bmatrix},\qquad \mathbf{P}= \begin{bmatrix} 0&1&0\\ 1&0&0\\ 0&0&1 \end{bmatrix}, $$

and the factors are

$$ \mathbf{L}= \begin{bmatrix} 1&0&0\\ 0&1&0\\ 2&-1&1 \end{bmatrix},\qquad \mathbf{U}= \begin{bmatrix} 1&1&0\\ 0&2&1\\ 0&0&2 \end{bmatrix}. $$

First verify the factorization. Multiplying \(\mathbf{L}\mathbf{U}\) gives rows \((1,1,0)\), \((0,2,1)\), and \(2(1,1,0)-(0,2,1)+(0,0,2)=(2,0,1)\). These are the rows of \(\mathbf{P}\mathbf{A}\), so \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\). Solve for \(\mathbf{b}=(3,2,5)^{\top}\). The row exchange gives

$$ \mathbf{P}\mathbf{b}= \begin{bmatrix} 2\\3\\5 \end{bmatrix}. $$

Forward substitution in \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\) gives \(y_1=2\), \(y_2=3\), and \(2y_1-y_2+y_3=5\), so \(y_3=5-4+3=4\). Thus \(\mathbf{y}=(2,3,4)^{\top}\). Back substitution gives \(2x_3=4\), so \(x_3=2\); then \(2x_2+x_3=3\), so \(x_2=(3-2)/2=1/2\); and \(x_1+x_2=2\), so \(x_1=2-1/2=3/2\).

Check in the original system:

$$ \mathbf{A}\mathbf{x}= \begin{bmatrix} 2(1/2)+2\\ 3/2+1/2\\ 2(3/2)+2 \end{bmatrix} = \begin{bmatrix} 3\\2\\5 \end{bmatrix} =\mathbf{b}. $$

The computed vector solves the original system, not merely the permuted one.

Worked Example: A Three-Cycle of Rows

Consider the factors

$$ \mathbf{P}= \begin{bmatrix} 0&1&0\\ 0&0&1\\ 1&0&0 \end{bmatrix},\quad \mathbf{L}= \begin{bmatrix} 1&0&0\\ 2&1&0\\ -1&3&1 \end{bmatrix},\quad \mathbf{U}= \begin{bmatrix} 2&1&1\\ 0&3&-1\\ 0&0&2 \end{bmatrix}. $$

Multiplication gives

$$ \mathbf{L}\mathbf{U}= \begin{bmatrix} 2&1&1\\ 4&5&1\\ -2&8&-2 \end{bmatrix}. $$

The rows of \(\mathbf{P}\mathbf{A}\) are rows 2, 3, 1 of \(\mathbf{A}\). Therefore the original matrix is

$$ \mathbf{A}= \begin{bmatrix} -2&8&-2\\ 2&1&1\\ 4&5&1 \end{bmatrix}. $$

Take \(\mathbf{b}=(-14,3,1)^{\top}\). The permutation reorders its entries to \(\mathbf{P}\mathbf{b}=(3,1,-14)^{\top}\). The forward equations give \(y_1=3\), \(2y_1+y_2=1\), hence \(y_2=-5\), and \(-y_1+3y_2+y_3=-14\), hence \(y_3=-14+3+15=4\). So \(\mathbf{y}=(3,-5,4)^{\top}\).

For back substitution, \(2x_3=4\) gives \(x_3=2\). Next, \(3x_2-x_3=-5\) gives \(3x_2=-3\), so \(x_2=-1\). Finally, \(2x_1+x_2+x_3=3\) gives \(2x_1-1+2=3\), so \(x_1=1\).

Check: the rows of \(\mathbf{A}\mathbf{x}\) are \(-2(1)+8(-1)-2(2)=-14\), \(2(1)+(-1)+2=3\), and \(4(1)+5(-1)+2=1\). Therefore \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Worked Example: Building the Factors After a Swap

Let \(\mathbf{A}=\begin{bmatrix}1&2\\3&4\end{bmatrix}\), \(\mathbf{b}=(5,11)^{\top}\), and exchange the two rows. Then

$$ \mathbf{P}= \begin{bmatrix}0&1\\1&0\end{bmatrix},\qquad \mathbf{P}\mathbf{A}= \begin{bmatrix}3&4\\1&2\end{bmatrix}. $$

Eliminating the \(1\) below the first pivot uses multiplier \(1/3\), giving the upper-triangular matrix \(\mathbf{U}=\begin{bmatrix}3&4\\0&2/3\end{bmatrix}\). The multiplier is stored below the pivot in \(\mathbf{L}=\begin{bmatrix}1&0\\1/3&1\end{bmatrix}\). Indeed,

$$ \mathbf{L}\mathbf{U}= \begin{bmatrix}3&4\\1&4/3+2/3\end{bmatrix} = \begin{bmatrix}3&4\\1&2\end{bmatrix} =\mathbf{P}\mathbf{A}. $$

Now \(\mathbf{P}\mathbf{b}=(11,5)^{\top}\). Forward substitution gives \(y_1=11\) and \(y_1/3+y_2=5\), so \(y_2=5-11/3=4/3\). Back substitution gives \((2/3)x_2=4/3\), so \(x_2=2\); then \(3x_1+4x_2=11\), so \(x_1=(11-8)/3=1\). Thus \(\mathbf{x}=(1,2)^{\top}\).

Check: \(\mathbf{A}\mathbf{x}=(1+4,3+8)^{\top}=(5,11)^{\top}=\mathbf{b}\).

Common Mistake: Using the Unpermuted Right-Hand Side

In the first worked example, applying forward substitution to \(\mathbf{L}\mathbf{y}=\mathbf{b}\) instead of \(\mathbf{L}\mathbf{y}=\mathbf{P}\mathbf{b}\) would give \(y_1=3\), \(y_2=2\), and \(2(3)-2+y_3=5\), so \(y_3=1\). Back substitution would then give \(x_3=1/2\), \(x_2=3/4\), and \(x_1=9/4\). This is a concrete but incorrect answer: the first entry of \(\mathbf{A}\mathbf{x}\) would be \(2(3/4)+1/2=2\), not the required \(3\).

The correction is to apply \(\mathbf{P}\) to the right-hand side before either triangular solve. The matrix \(\mathbf{P}\) in that example swaps the first two entries, so \(\mathbf{P}\mathbf{b}=(2,3,5)^{\top}\); using this vector gives the checked solution \((3/2,1/2,2)^{\top}\). A second common error is to apply \(\mathbf{P}^{\top}\) instead of \(\mathbf{P}\). For a single swap these matrices happen to be equal, but a longer permutation need not equal its transpose. The safe rule follows directly from the displayed identity: \(\mathbf{P}\mathbf{A}\mathbf{x}=\mathbf{P}\mathbf{b}\), so the right-hand side is \(\mathbf{P}\mathbf{b}\).

In practice, the factorization is reusable: for each new right-hand side, form its permuted vector, solve the two triangular systems, and check the resulting \(\mathbf{x}\) in the original equation when a direct verification is appropriate. The permutation changes the order of equations; it does not change the unknown vector or the meaning of the original system.

Check Your Understanding

For each question, keep the order of operations explicit and use the original equation to check any computed solution.

  1. If \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), what triangular system must be solved first for a right-hand side \(\mathbf{b}\), and why does its right-hand side involve \(\mathbf{P}\)?
  2. For \(\mathbf{P}=\begin{bmatrix}0&1\\1&0\end{bmatrix}\) and \(\mathbf{b}=(4,-2)^{\top}\), compute \(\mathbf{P}\mathbf{b}\).
  3. Using \(\mathbf{L}=\begin{bmatrix}1&0\\2&1\end{bmatrix}\), solve \(\mathbf{L}\mathbf{y}=(3,1)^{\top}\) by forward substitution.
  4. Why does a nonzero diagonal in \(\mathbf{U}\) ensure that back substitution determines a unique vector \(\mathbf{x}\)?
  5. Describe a direct check that distinguishes a solution of the original system from an incorrect result caused by omitting the permutation.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon