Tutorials › Linear Algebra › Deriving PA = LU With Row Exchanges

LU Factorization and Numerical Considerations · Tutorial 909 of 1000

Deriving PA = LU With Row Exchanges

Learn how pivoting changes the stored elimination data and how to construct and check a factorization of the form PA = LU.

Intermediate 9 min read

What You'll Learn

  • State when elimination with row exchanges produces a factorization PA = LU.
  • Track the permutation matrix as pivot rows are exchanged.
  • Explain why earlier multipliers must move when active rows are swapped.
  • Compute lower and upper triangular factors through multiple pivot steps.
  • Verify a proposed factorization by multiplying L and U and comparing with PA.
  • Identify the error caused by swapping rows of U but not the stored multipliers.

Why Row Exchanges Change the LU Record

In elimination without row exchanges, each step subtracts a multiple of a pivot row from rows below it. The multipliers used in these operations are stored below the diagonal of a lower triangular matrix \(\mathbf{L}\); the resulting upper triangular matrix is \(\mathbf{U}\). When a pivot is zero or is not the pivot chosen by partial pivoting, rows of the active part of \(\mathbf{U}\) are exchanged. Those exchanges also change the order of the original equations, recorded by a permutation matrix \(\mathbf{P}\).

There is an additional bookkeeping requirement. If a row is exchanged after earlier elimination steps, its previously stored multipliers belong with that row and must be exchanged too. The factorization is therefore not generally \(\mathbf{A}=\mathbf{L}\mathbf{U}\), but \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\). We derive the update rule and then check it by multiplication.

Definition: A permutation matrix is a square matrix obtained by permuting the rows of an identity matrix. Left multiplication by a permutation matrix permutes the rows of a matrix. A factorization \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{P}\) is a permutation matrix, \(\mathbf{L}\) is lower triangular with diagonal entries \(1\), and \(\mathbf{U}\) is upper triangular, is called a permuted LU factorization.

For partial pivoting at column \(k\), the pivot row is chosen among rows \(k,\dots,n\), usually as a row whose entry in column \(k\) has largest absolute value. The derivation below requires only that the selected pivot be nonzero. If every candidate in that active column is zero, this elimination step cannot proceed. The algorithm describes a factorization when it completes all the required steps.

The Elimination and Bookkeeping Rule

Start with \(\mathbf{U}=\mathbf{A}\), \(\mathbf{P}=\mathbf{I}_n\), and \(\mathbf{L}=\mathbf{I}_n\). At step \(k\), exchange the selected pivot row \(r\) with row \(k\) in \(\mathbf{U}\) and \(\mathbf{P}\). In \(\mathbf{L}\), exchange rows \(k\) and \(r\) only in columns \(1,\dots,k-1\). These columns contain the multipliers from completed steps; the remaining part of \(\mathbf{L}\) is still being constructed. Next, for each \(i>k\), set \(l_{ik}=u_{ik}/u_{kk}\), perform \(R_i\to R_i-l_{ik}R_k\) on \(\mathbf{U}\), and store \(l_{ik}\) in \(\mathbf{L}\).

Theorem (Permuted LU elimination): Suppose the pivoting and elimination process just described completes for \(\mathbf{A}\in\mathbb{R}^{n\times n}\), with a nonzero pivot at each step. Then the final matrices satisfy \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{P}\) is the product of the row exchanges applied to \(\mathbf{A}\), \(\mathbf{L}\) is unit lower triangular, and \(\mathbf{U}\) is upper triangular.

Proof. We track the relation between the permuted original matrix and the current elimination data. Before step \(k\), let \(\mathbf{B}=\mathbf{P}\mathbf{A}\), so the current record satisfies \(\mathbf{B}=\mathbf{L}\mathbf{U}\). At this stage, rows \(1,\dots,k-1\) of \(\mathbf{U}\) have been completed, and in columns \(1,\dots,k-1\) the entries below the diagonal are zero. The active rows of \(\mathbf{L}\), in columns \(k,\dots,n\), still form an identity block.

Suppose rows \(k\) and \(r\) are exchanged. Apply the same exchange to \(\mathbf{B}\), which is achieved by updating \(\mathbf{P}\), and to \(\mathbf{U}\). In the product relation, each active row of \(\mathbf{B}\) is a combination of the already completed rows of \(\mathbf{U}\), with coefficients given by the stored entries in columns \(1,\dots,k-1\) of \(\mathbf{L}\), plus that active row of \(\mathbf{U}\) itself. Swapping the active rows therefore requires swapping their stored coefficients in those earlier columns of \(\mathbf{L}\). The rows of \(\mathbf{U}\) above \(k\) are unchanged, and their rows in \(\mathbf{L}\) have zero entries in columns \(k,\dots,n\), so their product equations are unchanged. Thus the relation is preserved by the pivot exchange when the earlier multipliers are exchanged as stated.

Now eliminate below the pivot. For each \(i>k\), the row operation replaces row \(i\) of \(\mathbf{U}\) by row \(i\) minus \(l_{ik}\) times row \(k\). The corresponding row equation for \(\mathbf{B}\) remains valid if its coefficient on row \(k\) of \(\mathbf{U}\) is increased by \(l_{ik}\). That is exactly the update that stores \(l_{ik}\) in position \((i,k)\) of \(\mathbf{L}\). Hence the relation \(\mathbf{B}=\mathbf{L}\mathbf{U}\) is preserved through the elimination step as well. Initially \(\mathbf{P}=\mathbf{L}=\mathbf{I}_n\) and \(\mathbf{U}=\mathbf{A}\), so the relation holds before the first step. By applying the two updates at every step, it holds at completion. The elimination has made \(\mathbf{U}\) upper triangular, and the stored multipliers make \(\mathbf{L}\) unit lower triangular. Therefore \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\). \(\square\)

A Factorization With Two Exchanges

Worked Example: Updating Earlier Multipliers

Use partial pivoting to factor

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

In column 1, the largest absolute entry is \(4\), in row 2. Exchange rows 1 and 2 in \(\mathbf{U}\) and \(\mathbf{P}\). The first-column multipliers for the new rows 2 and 3 are \(2/4=1/2\) and \(1/4\). Subtract those multiples of the pivot row:

$$ \begin{bmatrix} 4&1&0\\ 2&1&1\\ 1&3&2 \end{bmatrix} \sim \begin{bmatrix} 4&1&0\\ 0&\tfrac12&1\\ 0&\tfrac{11}{4}&2 \end{bmatrix}. $$

At column 2, compare \(\tfrac12\) and \(\tfrac{11}{4}\). The larger absolute value is \(\tfrac{11}{4}\), so exchange rows 2 and 3 in \(\mathbf{U}\). Crucially, exchange the previously stored entries \(l_{21}=\tfrac12\) and \(l_{31}=\tfrac14\) in \(\mathbf{L}\) as well. The new multiplier is

$$ l_{32}=\frac{\tfrac12}{\tfrac{11}{4}}=\frac{2}{11}. $$

Subtract \(\tfrac{2}{11}\) times the new row 2 from row 3. The resulting upper triangular matrix and the completed multiplier record are

$$ \mathbf{U}= \begin{bmatrix} 4&1&0\\ 0&\tfrac{11}{4}&2\\ 0&0&\tfrac{7}{11} \end{bmatrix}, \qquad \mathbf{L}= \begin{bmatrix} 1&0&0\\ \tfrac14&1&0\\ \tfrac12&\tfrac{2}{11}&1 \end{bmatrix}. $$

The row exchanges take the original rows into the order 2, 3, 1. Hence

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

Check by multiplication: the rows of \(\mathbf{L}\mathbf{U}\) are row 1 of \(\mathbf{U}\), \(\tfrac14\) row 1 plus row 2, and \(\tfrac12\) row 1 plus \(\tfrac{2}{11}\) row 2 plus row 3. Thus

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

For example, the last row has second entry \(\tfrac12+\tfrac{2}{11}\cdot\tfrac{11}{4}=\tfrac12+\tfrac12=1\), and third entry \(\tfrac{2}{11}\cdot2+\tfrac{7}{11}=\tfrac{4}{11}+\tfrac{7}{11}=1\). The factorization checks entry by entry.

Examples With an Initial Exchange

Worked Example: A Zero First Pivot

For \(\mathbf{A}=\begin{bmatrix}0&2\\3&1\end{bmatrix}\), the first pivot position is zero, so exchange the two rows. There are no earlier multipliers to update. The resulting matrices are

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

The second row of \(\mathbf{U}\) is obtained by subtracting \(0\) times the first row, so \(l_{21}=0\). Direct verification gives

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

Worked Example: A Nonzero Multiplier After Pivoting

Consider \(\mathbf{A}=\begin{bmatrix}1&1&0\\3&2&1\\2&1&4\end{bmatrix}\). Partial pivoting first exchanges rows 1 and 2. The multipliers are \(1/3\) and \(2/3\), giving

$$ \begin{bmatrix} 3&2&1\\ 1&1&0\\ 2&1&4 \end{bmatrix} \sim \begin{bmatrix} 3&2&1\\ 0&\tfrac13&-\tfrac13\\ 0&-\tfrac13&\tfrac{10}{3} \end{bmatrix}. $$

The two candidates in column 2 have equal absolute value; choose row 2 as the pivot row, so no further exchange is needed. The multiplier is \((-\tfrac13)/(\tfrac13)=-1\). Adding row 2 to row 3 gives \(\mathbf{U}=\begin{bmatrix}3&2&1\\0&\tfrac13&-\tfrac13\\0&0&3\end{bmatrix}\). The initial exchange is represented by \(\mathbf{P}=\begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix}\), and the multiplier record is

$$ \mathbf{L}= \begin{bmatrix} 1&0&0\\ \tfrac13&1&0\\ \tfrac23&-1&1 \end{bmatrix}. $$

Checking by rows, row 2 of \(\mathbf{L}\mathbf{U}\) is \(\tfrac13(3,2,1)+(0,\tfrac13,-\tfrac13)=(1,1,0)\). Row 3 is \(\tfrac23(3,2,1)-(0,\tfrac13,-\tfrac13)+(0,0,3)=(2,1,4)\). Row 1 is \((3,2,1)\). Therefore \(\mathbf{L}\mathbf{U}=\begin{bmatrix}3&2&1\\1&1&0\\2&1&4\end{bmatrix}=\mathbf{P}\mathbf{A}\).

Common Pitfall: Leaving the Multipliers in Place

In the first example, after the second pivot exchange the multiplier in column 1 of row 2 must be \(1/4\), and the multiplier in row 3 must be \(1/2\). If those stored values are not exchanged, one might incorrectly use \(\widetilde{\mathbf{L}}=\begin{bmatrix}1&0&0\\1/2&1&0\\1/4&2/11&1\end{bmatrix}\) with the same \(\mathbf{U}\). Its second product row is \(\tfrac12(4,1,0)+(0,\tfrac{11}{4},2)=(2,\tfrac{13}{4},2)\), but row 2 of \(\mathbf{P}\mathbf{A}\) is \((1,3,2)\). So \(\widetilde{\mathbf{L}}\mathbf{U}\ne\mathbf{P}\mathbf{A}\). The correction is to swap the previously stored entries whenever active rows of \(\mathbf{U}\) are exchanged. The current pivot exchange changes which original row occupies each active position; the multipliers in earlier columns must follow that same row.

The order of the updates is therefore meaningful: exchange the active rows, move the earlier stored multipliers with them, and then compute and store the new multipliers. Once elimination is complete, \(\mathbf{P}\) records the row order, \(\mathbf{L}\) records the elimination multipliers in that order, and \(\mathbf{U}\) is the final upper triangular matrix. Multiplying the factors is the direct check that all three records agree.

Check Your Understanding

For each question, keep track of the row order as well as the numerical entries.

  1. In a \(4\times4\) elimination, rows 2 and 4 are exchanged at step 3. Which columns of the stored part of \(\mathbf{L}\) must be exchanged?
  2. Why is it necessary to exchange rows of \(\mathbf{P}\) whenever the corresponding rows of the current \(\mathbf{U}\) are exchanged?
  3. For \(\mathbf{A}=\begin{bmatrix}1&2\\4&3\end{bmatrix}\), use partial pivoting to find \(\mathbf{P}\), \(\mathbf{L}\), and \(\mathbf{U}\), then check \(\mathbf{P}\mathbf{A}=\mathbf{L}\mathbf{U}\).
  4. Explain why swapping active rows in \(\mathbf{U}\) but not earlier multipliers can make the product \(\mathbf{L}\mathbf{U}\) incorrect.
  5. What condition on the active column is needed to carry out the next elimination step?

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