# Matrix row operations

Learn how to perform the matrix elementary row operations. These operations will allow us to solve complicated linear systems with (relatively) little hassle!

## Matrix row operations

The following table summarizes the three elementary matrix row operations.
Matrix row operationExample
Switch any two rows
Multiply a row by a nonzero constant
Matrix row operations can be used to solve systems of equations, but before we look at why, let's practice these skills.

## Switch any two rows

### Example

Perform the row operation $R_1 \leftrightarrow R_2$ on the following matrix.
$\left[\begin{array} {rrr} 4 & 8 & 3 \\ 2 & 4 & 5 \\ 7 & 1 & 2 \end{array} \right]$

### Solution

$R_\blueD1 \leftrightarrow R_\greenD2$ means to interchange row $\blueD1$ and row $\greenD2$.
So the matrix $\left[\begin{array} {rrr} \blueD4 & \blueD8 & \blueD{3} \\ \greenD2 & \greenD4 & \greenD5 \\ 7 & 1 & 2 \end{array} \right]$ becomes $\left[\begin{array} {rrr} \greenD2 & \greenD4 & \greenD5 \\ \blueD4 & \blueD8 & \blueD{3} \\ 7 & 1 & 2 \end{array} \right]$.
Sometimes you will see the following notation used to indicate this change.
$\left[\begin{array} {rrr} 4 & 8 & 3 \\ 2 & 4 & 5 \\ 7 & 1 & 2 \end{array} \right] \xrightarrow{{R_1\leftrightarrow R_2}}\left[\begin{array} {rrr} 2 & 4 & 5 \\ 4 &8 & 3 \\ 7 & 1 & 2 \end{array} \right]$
Notice how row $1$ replaces row $2$ and row $2$ replaces row $1$. The third row is not changed.
Problem 1
Perform the row operation $R_2 \leftrightarrow R_3$ on the following matrix.
$\left[\begin{array} {rrr} 7 & 2 & 9 \\ 6 & 4 & 1 \\ 1 & 3 & 12 \end{array} \right]$
Problem 2
Perform the row operation $R_3 \leftrightarrow R_1$ on the following matrix.
$\left[\begin{array} {rrr} 2 & 11 & -5 \\ 7 & 2 & 18 \\ 0& -4 & 10 \end{array} \right]$

## Multiply a row by a nonzero constant

### Example

Perform the row operation $3R_2\rightarrow R_2$ on the following matrix.
$\left[\begin{array} {rrr} 6 & 6 & 1 \\ 2 & 3 & 0 \\ 4 & 5 & 9 \end{array} \right]$

### Solution

$\maroonD3R_\goldD2 \rightarrow R_\goldD2$ means to replace the $\goldD{2\text{nd}}$ row with $\maroonD3$ times itself.
$\left[\begin{array} {rrr} 6 & 6 & 1 \\ \goldD{2} & \goldD{3} & \goldD{0} \\ 4 & 5 & 9 \end{array} \right]$ becomes $\left[\begin{array} {rrr} 6 & 6 & 1 \\ \maroonD{3}\cdot \goldD{2} &\maroonD{3}\cdot \goldD{3} &\maroonD{3}\cdot \goldD{0} \\ 4 & 5 & 9 \end{array} \right] =\left[\begin{array} {rrr} 6 & 6 & 1 \\ 6 & 9 & {0} \\ 4 & 5 & 9 \end{array} \right]$
To indicate this matrix row operation, we often see the following:
$\left[\begin{array} {rrr} 6 & 6 & 1 \\ 2 & 3 & 0 \\ 4 & 5 & 9 \end{array} \right] \xrightarrow{\Large{3R_2\rightarrow R_2}}\left[\begin{array} {rrr} 6 & 6 & 1 \\ 6 & 9 & {0} \\ 4 & 5 & 9 \end{array} \right]$
Notice here three times the second row replaces the second row. The other rows remain the same.
Problem 3
Perform the row operation $2R_1\rightarrow R_1$ on the following matrix.
$\left[\begin{array} {ccc} 2 & 6 & 5 & 1 \\ 7 & 4 & 8 & 0 \end{array} \right]$
Problem 4
Perform the row operation $-5R_3\rightarrow R_3$ on the following matrix.
$\left[\begin{array} {rr} -2 & 1 \\ 7 & 4 \\ -3&6 \end{array} \right]$

## Add one row to another

### Example

Perform the row operation $R_1+R_2\rightarrow R_2$ on the following matrix.
$\left[\begin{array} {rrr} 2 & 3 & 4\\ 0 & 8 & 1 \end{array} \right]$

### Solution

$R_\tealD1+R_\purpleC2\rightarrow R_2$ means to replace the ${2\text{nd}}$ row with the sum of the $\tealD{1\text{st}}$ and $\purpleC{2\text{nd}}$ rows.
$\left[\begin{array} {rrr} \tealD2 & \tealD{3} &\tealD{ 4}\\ \purpleC0 & \purpleC8 & \purpleC1 \end{array} \right]$ becomes $\left[\begin{array} {lll} \tealD2 &{\tealD3} &{ \tealD4}\\ \tealD2+\purpleC0 & \tealD3+\purpleC8 & \tealD4 +\purpleC1 \end{array} \right]= \left[\begin{array} {rrr} 2 & 3 & 4\\ 2 & 11 & 5 \end{array} \right]$
To indicate this matrix row operation, we can write the following:
$\left[\begin{array} {rrr} 2 & 3 & 4\\ 0 & 8 & 1 \end{array} \right] \xrightarrow{\Large{R_1+R_2\rightarrow R_2}} \left[\begin{array} {rrr} 2 & 3 & 4\\ 2 & 11 & 5 \end{array} \right]$
Notice how the sum of row $1$ and $2$ replaces row $2$. The other row remains the same.
Problem 5
Perform the row operation $R_1+R_3\rightarrow R_3$ on the following matrix.
$\left[\begin{array} {rrr} -1 & 6 & -2 \\ -3 & 5 & 0 \\ 7 & 2 & 1 \end{array} \right]$
Problem 6
Perform the row operation $R_2+R_3\rightarrow R_2$ on the following matrix.
$\left[\begin{array} {rrr} -4 & 12 & 9 \\ 7 & 4 & 2 \\ 1 & 5 & 10 \end{array} \right]$
Challenge problem
Perform the row operation $R_1+2R_3\rightarrow R_1$ on the following matrix.
$\left[\begin{array} {rrr} -5 & 7 & 3 \\ -2 & -1 & 4 \\ 8 & 8 & -6 \end{array} \right]$

## Systems of equations and matrix row operations

Recall that in an augmented matrix, each row represents one equation in the system and each column represents a variable or the constant terms.
For example, the system on the left corresponds to the augmented matrix on the right.
SystemMatrix
\begin{aligned} 1x+3y &=5\\2x+5y &=6\end{aligned}$\left[\begin{array}{rr}1&3&5\\2&5&6\end{array}\right]$
When working with augmented matrices, we can perform any of the matrix row operations to create a new augmented matrix that produces an equivalent system of equations. Let's take a look at why.

### Switching any two rows

Equivalent SystemsAugmented matrix
\begin{aligned} \blueD1x+\blueD3y &=\blueD{5} \\\greenD{2}x+\greenD{{5}}y &=\greenD{6} \end{aligned}$\left[\begin{array}{rr}1&3&5\\2&5&6\end{array}\right]$
$\downarrow$
\begin{aligned}\greenD{2}x+\greenD{{5}}y &=\greenD{6}\\ \blueD1x+\blueD3y &=\blueD{5} \end{aligned}$\left[\begin{array}{rr}2&5&6\\1&3&5\end{array}\right]$
The two systems in the above table are equivalent, because the order of the equations doesn't matter. This means that when using an augmented matrix to solve a system, we can interchange any two rows.

### Multiply a row by a nonzero constant

We can multiply both sides of an equation by the same nonzero constant to obtain an equivalent equation.
In solving systems of equations, we often do this to eliminate a variable. Because the two equations are equivalent, we see that the two systems are also equivalent.
Equivalent SystemsAugmented matrix
\begin{aligned} \maroonD1x+\maroonD3y &=\maroonD5 \\2x+5y &=6\end{aligned}$\left[\begin{array}{rr}\maroonD1 & \maroonD3 &\maroonD5 \\2&5&6\end{array}\right]$
$\downarrow$
\begin{aligned}\goldD{-2}x+(\goldD{-6})y &=\goldD{-10} \\2x+\phantom{(-)}5y &=6\end{aligned}$\left[\begin{array}{rr}\goldD{-2}&\goldD{-6}& \goldD{-10}\\2&5&6\end{array}\right]$
This means that when using an augmented matrix to solve a system, we can multiply any row by a nonzero constant.

### Add one row to another

We know that we can add two equal quantities to both sides of an equation to obtain an equivalent equation.
So if $A=B$ and $C=D$, then $A+C=B+D$.
We do this often when solving systems of equations. For example, in this system \begin{aligned}-2x-6y &=-10 \\ {2}x+{{5}}y &={6}\end{aligned}, we can add the equations to obtain $-y=-4$.
Pairing this new equation with either original equation creates an equivalent system of equations.
When we add the equations from the original system, we obtain $-y=-4$, or $y=4$. But the other equations have not disappeared from the system; we use them to solve for $x$.
Choosing either one will create an equivalent system. In the following table we kept the top equation.
Equivalent SystemsAugmented matrix
\begin{aligned} -2x-6y &=-10\\2x+5y &=6\end{aligned}$\left[\begin{array}{rrr}-2&-6&-10\\2&5&6\end{array}\right]$
$\downarrow$
\begin{aligned}-2x+(-6)y &=-10\\\purpleC0x+(\purpleC{-1})y &=\purpleC{-4} \end{aligned}$\left[\begin{array}{rr}-2&-6&-10\\0&-1&-4\end{array}\right]$
So when using an augmented matrix to solve a system, we can add one row to another.
Concluding challenge problem
A sequence of row operations is performed on the matrix $\left[\begin{array}{rrr}{2} & {2} &{ 10} \\ {-2} & {-3} & {3} \end{array}\right]$. The table below describes the result of each step in the sequence.
Arrange the row operations according to each step.
Original matrix: $\left[\begin{array}{rrr}{2} & {2} &{ 10} \\ {-2} & {-3} & {3} \end{array}\right]$
Step
Row operation
• Step 1: $\left[\begin{array}{rrr}{2} & {2} &{10} \\ {0} & {-1} & {13} \end{array}\right]$
• Step 2: $\left[\begin{array}{rrr}{1} & {1} &{ 5} \\ {0} & {-1} & {13} \end{array}\right]$
• Step 3: $\left[\begin{array}{rrr}{1} & {1} &{ 5} \\ {0} & {1} & {-13} \end{array}\right]$
• Step 4: $\left[\begin{array}{rrr}{1} & {0} &{ 18} \\ {0} & {1} & {-13} \end{array}\right]$
• $R_1-R_2\rightarrow R_1$
• $\dfrac12R_1\rightarrow R_1$
• $R_1+R_2\rightarrow R_2$
• $-1R_2\rightarrow R_2$
Notice that the original matrix corresponds to \begin{aligned} 2x+2y &={10} \\ {-2}x-3y &={ 3} \end{aligned}, while the final matrix corresponds to \begin{aligned} x&=18 \\ y&=-13 \end{aligned} which simply gives the solution.
The system was solved entirely by using augmented matrices and row operations!