Tutorials › Linear Algebra › The Effect Of Swapping Two Rows

Properties of Determinants · Tutorial 239 of 1000

The Effect Of Swapping Two Rows

Learn why a row swap multiplies a determinant by \(-1\), and how to track that sign through a sequence of interchanges.

Intermediate 9 min read

What You'll Learn

  • State the determinant rule for interchanging two distinct rows of a square matrix.
  • Derive the sign change from multilinearity and the repeated-rows property.
  • Track the determinant through a sequence of row swaps.
  • Check a predicted sign by computing the determinant directly.
  • Avoid confusing the number of positions between two rows with the number of swaps.

Why a Row Swap Changes the Sign

A determinant records information about a square matrix that is sensitive to the order of its rows. Interchanging two rows does not change the entries themselves, but it reverses the sign of the determinant. This rule is useful both for understanding determinant properties and for keeping an exact record of a determinant while rows are reordered.

Throughout, let \(\mathbf{A}\in\mathbb{R}^{n\times n}\). Write its rows as \(\mathbf{r}_1,\dots,\mathbf{r}_n\). For distinct indices \(i\) and \(j\), let \(\mathbf{A}^{(i\leftrightarrow j)}\) denote the matrix obtained by interchanging rows \(i\) and \(j\) of \(\mathbf{A}\), leaving every other row unchanged. A row interchange is defined only between distinct rows; when \(n=1\), there is no pair of rows to interchange.

The determinant is multilinear in its rows: holding all but one row fixed, replacing that row by a sum of two vectors makes the determinant the sum of the two determinants obtained by using each vector separately. We will also use the previously established repeated-rows property: a square matrix with two identical rows has determinant zero. Together, these facts give the sign rule.

Theorem (Effect of a row swap): If \(\mathbf{A}\in\mathbb{R}^{n\times n}\) and \(i\ne j\), then \(\det\bigl(\mathbf{A}^{(i\leftrightarrow j)}\bigr)=-\det(\mathbf{A})\).

Proof. Form a matrix \(\mathbf{C}\) from \(\mathbf{A}\) by replacing both rows \(i\) and \(j\) with the row vector \(\mathbf{r}_i+\mathbf{r}_j\), leaving every other row unchanged. Rows \(i\) and \(j\) of \(\mathbf{C}\) are equal, so the repeated-rows property gives \(\det(\mathbf{C})=0\). Expand this determinant using multilinearity, first in row \(i\) and then in row \(j\). The result is the sum of four determinants: the one with rows \((\mathbf{r}_i,\mathbf{r}_j)\), the one with rows \((\mathbf{r}_i,\mathbf{r}_i)\), the one with rows \((\mathbf{r}_j,\mathbf{r}_j)\), and the one with rows \((\mathbf{r}_j,\mathbf{r}_i)\), in positions \(i,j\), respectively. The middle two determinants vanish because each has repeated rows. The first is \(\det(\mathbf{A})\), and the last is \(\det\bigl(\mathbf{A}^{(i\leftrightarrow j)}\bigr)\). Therefore \(\det(\mathbf{A})+\det\bigl(\mathbf{A}^{(i\leftrightarrow j)}\bigr)=0\), which gives the stated rule. \(\square\)

The rule applies to any pair of distinct rows, not only adjacent rows. It also applies whether the determinant is positive, negative, or zero. If \(\det(\mathbf{A})=0\), then the swapped determinant is \(-0=0\); the rule does not require a nonzero determinant.

One Swap: Calculate and Check

Worked Example: Interchange the First and Third Rows

Let \(\mathbf{A}=\begin{bmatrix}1&2&0\\3&1&4\\2&-1&1\end{bmatrix}\). Find the determinant after interchanging rows 1 and 3, and check the prediction by direct calculation.

First calculate the original determinant by expansion along row 1. The first minor is \(\det\begin{bmatrix}1&4\\-1&1\end{bmatrix}=1\cdot1-4(-1)=5\). The second minor is \(\det\begin{bmatrix}3&4\\2&1\end{bmatrix}=3\cdot1-4\cdot2=-5\). The third term is zero because the entry in row 1, column 3 is zero. Hence

$$ \det(\mathbf{A})=1(5)-2(-5)+0=15. $$

After the row interchange, the matrix is \(\mathbf{A}^{(1\leftrightarrow3)}=\begin{bmatrix}2&-1&1\\3&1&4\\1&2&0\end{bmatrix}\). The theorem predicts its determinant is \(-15\). To check directly, expand along its first row:

$$ \begin{aligned} \det\bigl(\mathbf{A}^{(1\leftrightarrow3)}\bigr) &=2(1\cdot0-4\cdot2)-(-1)(3\cdot0-4\cdot1)+1(3\cdot2-1\cdot1)\\ &=2(-8)+1(-4)+5\\ &=-16-4+5=-15. \end{aligned} $$

The direct calculation agrees with the sign rule: one row swap changes \(15\) to \(-15\).

For practical use, the key information is the number of swaps, rather than how far apart the row positions are. Each individual interchange contributes one factor of \(-1\). An even number of swaps therefore contributes a net factor of \(1\), while an odd number contributes a net factor of \(-1\).

Corollary (A sequence of row swaps): Suppose \(\mathbf{A}_0,\mathbf{A}_1,\dots,\mathbf{A}_k\) are square matrices, and each \(\mathbf{A}_{m+1}\) is obtained from \(\mathbf{A}_m\) by one row interchange, for \(m=0,\dots,k-1\). Then \(\det(\mathbf{A}_k)=(-1)^k\det(\mathbf{A}_0)\).

Proof. We use induction on the nonnegative integer \(k\). For \(k=0\), no interchange is made, so \(\mathbf{A}_k=\mathbf{A}_0\) and \(\det(\mathbf{A}_k)=\det(\mathbf{A}_0)=(-1)^0\det(\mathbf{A}_0)\). Now suppose the formula holds for a sequence of \(k\) interchanges. One more interchange gives \(\det(\mathbf{A}_{k+1})=-\det(\mathbf{A}_k)\) by the row-swap theorem. Substituting the induction hypothesis, \(\det(\mathbf{A}_{k+1})=-(-1)^k\det(\mathbf{A}_0)=(-1)^{k+1}\det(\mathbf{A}_0)\). Thus the formula holds for \(k+1\), and induction proves it for every \(k\ge0\). \(\square\)

Tracking Several Interchanges

Worked Example: Two Swaps Preserve the Sign

Start with the diagonal matrix \(\mathbf{D}=\begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix}\), whose determinant is \(1\cdot2\cdot3=6\). Interchange rows 1 and 2, then interchange rows 2 and 3. Track the determinant at each step.

After the first interchange, the matrix and its determinant are

$$ \begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix} \longrightarrow \begin{bmatrix}0&2&0\\1&0&0\\0&0&3\end{bmatrix}, \qquad \det=-6. $$

After the second interchange, the matrix is

$$ \begin{bmatrix}0&2&0\\1&0&0\\0&0&3\end{bmatrix} \longrightarrow \begin{bmatrix}0&2&0\\0&0&3\\1&0&0\end{bmatrix}. $$

There have been two swaps, so the sequence rule predicts determinant \((-1)^2\cdot6=6\). Check by expanding the final matrix along its first row: \(\det=-2\det\begin{bmatrix}0&3\\1&0\end{bmatrix}=-2(0\cdot0-3\cdot1)=6\). The two sign reversals return the determinant to its original value.

Worked Example: Three Swaps Reverse the Sign

Let \(\mathbf{A}=\begin{bmatrix}1&2&0\\3&1&4\\2&-1&1\end{bmatrix}\), which has determinant \(15\) as computed above. Perform, in order, the swaps \(R_1\leftrightarrow R_2\), \(R_2\leftrightarrow R_3\), and \(R_1\leftrightarrow R_3\). Track the matrices and determinants.

After the first swap, the rows are \((3,1,4),(1,2,0),(2,-1,1)\), so the matrix is \(\begin{bmatrix}3&1&4\\1&2&0\\2&-1&1\end{bmatrix}\), and its determinant is \(-15\). After the second swap, the rows are \((3,1,4),(2,-1,1),(1,2,0)\), giving \(\begin{bmatrix}3&1&4\\2&-1&1\\1&2&0\end{bmatrix}\), with determinant \(15\). After the third swap, the rows are \((1,2,0),(2,-1,1),(3,1,4)\), giving

$$ \begin{bmatrix}1&2&0\\2&-1&1\\3&1&4\end{bmatrix}. $$

Three swaps predict the determinant \((-1)^3\cdot15=-15\). To check, expand the final matrix along its first row: \(\det=1((-1)\cdot4-1\cdot1)-2(2\cdot4-1\cdot3)+0=-5-2(5)=-15\). The direct calculation agrees with the three successive sign changes: \(15\), then \(-15\), then \(15\), then \(-15\).

The sequence rule tracks the swaps actually performed. If a matrix is reordered by a different sequence, count the swaps in that sequence and apply the rule to that count. The rule concerns determinant changes at each step; it does not say that a row swap changes the determinant by a fixed amount. It multiplies the current determinant by \(-1\).

Common Mistake: Counting Row Positions Instead of Swaps

For the matrix in the first worked example, rows 1 and 3 are two positions apart. A tempting but incorrect argument is: “The rows are two places apart, so moving one row across two places takes an even number of swaps; the determinant stays \(15\).” The error is that moving a row to the other position while leaving the middle row in place takes three adjacent interchanges, not two.

In row order, the required route is \((\mathbf{r}_1,\mathbf{r}_2,\mathbf{r}_3)\to(\mathbf{r}_2,\mathbf{r}_1,\mathbf{r}_3)\to(\mathbf{r}_2,\mathbf{r}_3,\mathbf{r}_1)\to(\mathbf{r}_3,\mathbf{r}_2,\mathbf{r}_1)\). There are three swaps, so the determinant changes by \((-1)^3=-1\), giving \(-15\), not \(15\). The direct expansion in the first worked example confirms the correction.

Another useful boundary is that this rule is specifically about interchanging two rows of a square matrix. It does not, by itself, give the determinant effect of scaling a row or adding a multiple of one row to another. Those are different row operations and require their own determinant rules.

Why the Sign Rule Matters

Row swaps are often used to rearrange a matrix while calculating its determinant. The sign rule lets us keep track of the effect of each such rearrangement without recomputing the entire determinant after every step. For a sequence of \(k\) swaps, the only extra information needed is whether \(k\) is even or odd: even means the final determinant equals the initial one, and odd means it is its negative. If the initial determinant is zero, every value in the sequence remains zero, which is also consistent with the same formula.

When recording a calculation, it is good practice to state the swaps explicitly and update the sign after each one. This separates two tasks: determining the determinant of a convenient row arrangement, and accounting for how the arrangement was reached. Keeping those tasks separate prevents sign errors and makes the final answer straightforward to check.

Check Your Understanding

For each question, identify the number of swaps or use the theorem directly. When a matrix is given, check the predicted determinant by computation.

  1. If \(\det(\mathbf{A})=-7\), what is the determinant after interchanging rows 2 and 5?
  2. A matrix with determinant \(12\) undergoes four row interchanges. What is the determinant of the resulting matrix?
  3. Explain why a row swap still gives a correct sign rule when the original determinant is zero.
  4. For \(\mathbf{B}=\begin{bmatrix}1&0&0\\0&2&0\\0&0&4\end{bmatrix}\), interchange rows 1 and 3, then rows 1 and 2. Predict the final determinant and verify it directly.
  5. How many adjacent row swaps are needed to change the order \((\mathbf{r}_1,\mathbf{r}_2,\mathbf{r}_3)\) to \((\mathbf{r}_3,\mathbf{r}_2,\mathbf{r}_1)\), and what sign factor does that produce?

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