= Gaussian elimination with a row swap
{c}
{title2=$x=(1,2,-1)^T$}
Consider this original <linear system> and its <augmented matrix>:
$$
A=\begin{pmatrix}0&2&1\\1&-2&-3\\2&3&1\end{pmatrix},\qquad b=\begin{pmatrix}3\\0\\7\end{pmatrix},\qquad [A\mid b]=\left[\begin{array}{rrr|r}0&2&1&3\\1&-2&-3&0\\2&3&1&7\end{array}\right].
$$
The first diagonal entry is zero, so it cannot serve as a <pivot element>. Interchange $R_1$ and $R_2$ to obtain a <pivot element> of one:
$$
\left[\begin{array}{rrr|r}1&-2&-3&0\\0&2&1&3\\2&3&1&7\end{array}\right].
$$
This chooses a convenient nonzero entry for exact arithmetic; <partial pivoting> would instead interchange $R_1$ and $R_3$, selecting the largest <absolute value>, two. For our chosen ordering, the first-column <elimination multipliers> are $m_2=0$ and $m_3=2$. The <elementary row operation> $R_3\leftarrow R_3-2R_1$ gives
$$
\left[\begin{array}{rrr|r}1&-2&-3&0\\0&2&1&3\\0&7&7&7\end{array}\right].
$$
The next <pivot element> is two and the next <elimination multiplier> is $7/2$. Applying $R_3\leftarrow R_3-\tfrac72R_2$ gives the <upper triangular matrix> system
$$
\left[\begin{array}{rrr|r}1&-2&-3&0\\0&2&1&3\\0&0&\tfrac72&-\tfrac72\end{array}\right].
$$
Every operation also changed the right-hand side. <Back substitution> now gives
$$
x_3=\frac{-7/2}{7/2}=-1,\qquad x_2=\frac{3-x_3}{2}=2,\qquad x_1=2x_2+3x_3=1.
$$
Checking the original equations, rather than only the reduced ones, verifies the answer by <matrix multiplication>:
$$
A\begin{pmatrix}1\\2\\-1\end{pmatrix}=\begin{pmatrix}4-1\\1-4+3\\2+6-1\end{pmatrix}=b.
$$
Thus a zero first diagonal entry was a row-order obstruction, not a <singular matrix>. Indeed, the diagonal product of the final <upper triangular matrix> is $7$; the single row interchange makes $\det A=-7$, since the two row additions preserve the <determinant>.
\Image[/gaussian-elimination-row-swap-pivots.png]
{title=A row interchange supplies the first <pivot element>; successive <elementary row operations> create zeros, then <back substitution> gives $(1,2,-1)^T$}
Back to article page