Tutorials › Linear Algebra › Partial Pivoting and Permutation Matrices

LU Factorization and Numerical Considerations · Tutorial 908 of 1000

Partial Pivoting and Permutation Matrices

Use partial pivoting to choose pivots, encode row swaps with permutation matrices, and track each update in an elimination calculation.

Intermediate 10 min read

What You'll Learn

  • Select a partial pivot from the active entries in a column.
  • Construct permutation matrices that encode row exchanges.
  • Track the order of multiple row swaps.
  • Compute elimination multipliers and updated rows exactly.
  • Check how row exchanges affect previously recorded multipliers.

Why Partial Pivoting Changes the Elimination Steps

In Gaussian elimination, a pivot is the entry used to eliminate the entries beneath it in its column. If that entry is zero, the step cannot be carried out as written; a row exchange may put a nonzero entry in the pivot position. Partial pivoting makes a more specific choice: among the available entries in the current pivot column, choose one with the largest absolute value. This ensures that the pivot is nonzero whenever any available entry in that column is nonzero, and it bounds the elimination multipliers in that step.

The row exchanges must be tracked as part of the calculation. A permutation matrix records the order change, while the updated matrix records the elimination. These are related but distinct tasks: choosing a pivot tells us which rows to exchange, and multiplying on the left by the corresponding permutation matrix applies that exchange to the rows.

Definition: At elimination stage \(k\) of an \(n\times n\) matrix, the active entries in the pivot column are \(a_{kk},a_{k+1,k},\dots,a_{nk}\), using the entries of the current matrix at that stage. Partial pivoting chooses an index \(p\) with \(k\le p\le n\) such that \(\lvert a_{pk}\rvert\) is largest among these absolute values. If \(a_{pk}\ne0\), exchange rows \(k\) and \(p\), then use the resulting entry in position \((k,k)\) as the pivot. If all active entries are zero, no row exchange can provide a nonzero pivot in column \(k\).

If several entries tie for the largest absolute value, any of their row indices is a valid choice. A practical implementation needs a tie-breaking rule, but the mathematics of partial pivoting does not prescribe one. The pivot choice is made in the current matrix, after any earlier row exchanges and elimination updates; it is not necessarily made from the original column.

Row Exchanges as Permutation Matrices

A permutation matrix is obtained by rearranging the rows of the identity matrix. For example, exchanging rows 1 and 2 of \(\mathbf{I}_3\) gives \(\begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix}\). Multiplication by this matrix on the left exchanges rows 1 and 2 of any matrix with three rows. A sequence of row exchanges is recorded by multiplying the corresponding permutation matrices in the same order in which they act: if the first exchange uses \(\mathbf{P}_1\) and the second uses \(\mathbf{P}_2\), the combined action is \(\mathbf{P}_2\mathbf{P}_1\).

Proposition: If \(\mathbf{P}\) is formed by exchanging two rows of \(\mathbf{I}_n\), then \(\mathbf{P}\mathbf{A}\) is the matrix obtained by exchanging the same two rows of \(\mathbf{A}\). Also, applying that exchange twice returns the original matrix.

Proof. Left multiplication forms each row of \(\mathbf{P}\mathbf{A}\) as a linear combination of the rows of \(\mathbf{A}\), with coefficients from the corresponding row of \(\mathbf{P}\). The rows of \(\mathbf{P}\) are the rows of \(\mathbf{I}_n\), except that the two rows at the exchanged indices have been interchanged. Thus every row of \(\mathbf{P}\mathbf{A}\) equals the corresponding row of \(\mathbf{A}\), except that the selected pair is interchanged. Performing the same exchange a second time restores the original order, so the exchange matrix satisfies \(\mathbf{P}^2=\mathbf{I}_n\). \(\square\)

For multiple exchanges, it is important to preserve the order of multiplication. A later exchange acts on the result of the earlier one, so it appears on the left. The product is itself a permutation matrix, since its action simply rearranges the rows.

Worked Example: Exchange Rows to Obtain the First Pivot

Use partial pivoting for the first column of \(\mathbf{A}=\begin{bmatrix}\tfrac14&1\\2&3\end{bmatrix}\). Record the row exchange and carry out the elimination.

The active first-column entries have absolute values \(\tfrac14\) and \(2\), so the largest is \(2\), in row 2. Exchange rows 1 and 2 with

$$ \mathbf{P}=\begin{bmatrix}0&1\\1&0\end{bmatrix}. $$

Direct multiplication shows the effect of the exchange:

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

The pivot is \(2\). The multiplier for the entry below it is \(\tfrac{1}{4}/2=\tfrac18\). Subtract \(\tfrac18\) times row 1 from row 2:

$$ \begin{bmatrix}2&3\\\tfrac14&1\end{bmatrix} \ \xrightarrow{\,R_2\to R_2-\tfrac18R_1\,}\ \begin{bmatrix}2&3\\0&\tfrac58\end{bmatrix}. $$

Check: the updated second entry is \(1-\tfrac18(3)=\tfrac58\), and the first entry is \(\tfrac14-\tfrac18(2)=0\). The multiplier \(\tfrac18\) has absolute value less than 1.

Why the Pivot Choice Bounds the Multipliers

Partial pivoting has a useful property that follows directly from its selection rule. It does not say that every part of the elimination is numerically harmless; it gives a bound on the multipliers for the current column.

Theorem: Suppose that, at stage \(k\), at least one active entry in the pivot column is nonzero. If partial pivoting selects pivot \(a_{pk}\), exchanges it into position \((k,k)\), and uses it to eliminate the entries below, then every multiplier in that column has absolute value at most \(1\).

Proof. Let \(q\) be any row index below the pivot position after the exchange. Before the exchange, the magnitude of the entry in row \(q\), column \(k\) was no larger than \(\lvert a_{pk}\rvert\), because the chosen entry had largest absolute value among all active entries. The exchange moves \(a_{pk}\) to position \((k,k)\) and does not change the other active entries. The multiplier for row \(q\) is its column-\(k\) entry divided by the pivot. Therefore its magnitude is at most \(\lvert a_{pk}\rvert/\lvert a_{pk}\rvert=1\). The denominator is nonzero by the hypothesis that at least one active entry is nonzero and the selection rule chooses a largest one. \(\square\)

The condition matters. If every available entry is zero, the largest magnitude is zero, so there is no nonzero pivot and no multiplier can be computed. Partial pivoting chooses among entries in the current column only; it does not move a nonzero entry from another column into the pivot position.

Tracing Several Exchanges and Updates

Worked Example: Two Pivot Choices in a Three-by-Three Matrix

Apply partial pivoting to \(\mathbf{A}=\begin{bmatrix}1&1&0\\4&2&1\\2&5&3\end{bmatrix}\), recording the row order, pivot choices, multipliers, and updated entries.

In column 1, the active magnitudes are \(1,4,2\), so exchange rows 1 and 2. In column 1 of the resulting matrix, the first pivot is \(4\). The multipliers for the entries below it are \(1/4\) and \(1/2\). The row updates give

$$ \begin{bmatrix}4&2&1\\1&1&0\\2&5&3\end{bmatrix} \ \xrightarrow{\substack{R_2\to R_2-\tfrac14R_1\\ R_3\to R_3-\tfrac12R_1}}\ \begin{bmatrix}4&2&1\\0&\tfrac12&-\tfrac14\\0&4&\tfrac52\end{bmatrix}. $$

For example, row 2 becomes \((1,1,0)-\tfrac14(4,2,1)=(0,\tfrac12,-\tfrac14)\). Row 3 becomes \((2,5,3)-\tfrac12(4,2,1)=(0,4,\tfrac52)\). In column 2, the active entries are now \(\tfrac12\) and \(4\), so exchange the active rows to put \(4\) in the pivot position. The row order of the original matrix is now row 2, row 3, row 1.

The two exchanges are represented by

$$ \mathbf{P}_1=\begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix}, \qquad \mathbf{P}_2=\begin{bmatrix}1&0&0\\0&0&1\\0&1&0\end{bmatrix}, \qquad \mathbf{P}_2\mathbf{P}_1= \begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix}. $$

The second-stage multiplier is \((\tfrac12)/4=\tfrac18\). After the row exchange, subtract \(\tfrac18\) times the pivot row from the row below:

$$ \begin{bmatrix}4&2&1\\0&4&\tfrac52\\0&\tfrac12&-\tfrac14\end{bmatrix} \ \xrightarrow{\,R_3\to R_3-\tfrac18R_2\,}\ \begin{bmatrix}4&2&1\\0&4&\tfrac52\\0&0&-\tfrac9{16}\end{bmatrix}. $$

Check: the last entry is \(-\tfrac14-\tfrac18(\tfrac52)=-\tfrac4{16}-\tfrac5{16}=-\tfrac9{16}\). The final row order is also confirmed by multiplying the original matrix by \(\mathbf{P}_2\mathbf{P}_1\):

$$ (\mathbf{P}_2\mathbf{P}_1)\mathbf{A} = \begin{bmatrix}4&2&1\\2&5&3\\1&1&0\end{bmatrix}. $$

The displayed elimination updates are applied after those exchanges; the last displayed matrix is the result of elimination, not just a row permutation of the original matrix.

When elimination multipliers are stored for later use, a row exchange at a later stage also changes which row owns each earlier multiplier. In the example, the first-stage multipliers \(1/4\) and \(1/2\) belong to the two rows below the first pivot. When those active rows are exchanged for the second pivot, the earlier multipliers must be exchanged with them. Otherwise, the recorded values no longer describe the row updates that were actually performed. This is a bookkeeping rule for an elimination calculation; it does not change how the current pivot is selected.

Ties, Checks, and a Common Mistake

Worked Example: A Tie in the Pivot Column

Apply the first partial-pivoting step to \(\mathbf{B}=\begin{bmatrix}-3&1\\3&2\end{bmatrix}\), choosing the first row if the magnitudes tie.

Both active entries have magnitude \(3\), so either row is a valid pivot choice. The stated tie rule keeps row 1, giving pivot \(-3\). The multiplier is \(3/(-3)=-1\), and the update is

$$ \begin{bmatrix}-3&1\\3&2\end{bmatrix} \ \xrightarrow{\,R_2\to R_2+R_1\,}\ \begin{bmatrix}-3&1\\0&3\end{bmatrix}. $$

Check: the new second row is \((3,2)+(-3,1)=(0,3)\). If instead row 2 is chosen, the row order changes, but the pivot magnitude is still \(3\); the tie makes the choice non-unique, not invalid.

Common mistake: swapping the entries but forgetting the permutation. In the first worked example, the exchanged matrix is \(\begin{bmatrix}2&3\\\tfrac14&1\end{bmatrix}\). It would be incorrect to claim that this is \(\mathbf{I}_2\mathbf{A}\), because \(\mathbf{I}_2\mathbf{A}=\mathbf{A}\) leaves the rows in their original order. The correct record is \(\mathbf{P}\mathbf{A}\), with \(\mathbf{P}=\begin{bmatrix}0&1\\1&0\end{bmatrix}\). Multiplying back checks both the chosen row order and the entries.

A second error is to choose the first nonzero entry without checking whether a larger one is available. In the first worked example, choosing \(1/4\) as the pivot would give multiplier \(2/(1/4)=8\). Partial pivoting instead selects \(2\), giving multiplier \(1/8\). The rule is about the largest magnitude among the active entries in that column, not merely finding a nonzero entry.

A Reliable Calculation Checklist

At each stage, keep the pivot choice, the row order, and the arithmetic distinct. A careful calculation can be organized as follows:

1
Inspect the active column.
Compare the absolute values from the current pivot row down. If their maximum is zero, there is no available nonzero pivot in that column.
2
Record and apply the exchange.
Choose a row attaining the maximum, write the corresponding permutation matrix, and exchange the selected row with the pivot row.
3
Compute the multipliers and updates.
Divide each entry below the pivot by the pivot, then subtract that multiple of the pivot row. Check the resulting entries directly.
4
Update the bookkeeping.
For a sequence of exchanges, multiply each new permutation matrix on the left of the previous product. If earlier multipliers are being stored, exchange their row assignments when the corresponding active rows move.

These steps make the calculation auditable: the permutation records where the rows went, and each elimination update records what was subtracted. Partial pivoting also guarantees that each multiplier in a successfully processed column has magnitude at most \(1\). The question of how this choice affects broader numerical behavior requires additional analysis; the immediate task here is to apply and record the row exchanges correctly.

Check Your Understanding

For each question, state the pivot choice and show enough arithmetic to verify the result.

  1. In the first column of \(\begin{bmatrix}2&1\\-5&3\\4&0\end{bmatrix}\), which row does partial pivoting select?
  2. Write the permutation matrix that exchanges rows 1 and 3 of a three-row matrix, and describe the row order after the exchange.
  3. For \(\begin{bmatrix}1&2\\4&1\end{bmatrix}\), compute the first multiplier and the updated second row after partial pivoting.
  4. If two active entries tie for the largest magnitude, must partial pivoting exchange rows? Explain.
  5. Why must previously stored multipliers move with their rows when a later pivot step exchanges active rows?

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