# Gaussian elimination

In mathematics, Gaussian elimination (also called row reduction) is a method used to solve systems of linear equations. It is named after Carl Friedrich Gauss, a famous German mathematician who wrote about this method, but did not invent it.

To perform Gaussian elimination, the coefficients of the terms in the system of linear equations are used to create a type of matrix called an augmented matrix. Then, elementary row operations are used to simplify the matrix. The three types of row operations used are:

Type 1: Switching one row with another row.
Type 2: Multiplying a row by a non-zero number.
Type 3: Adding or subtracting a row from another row.

The goal of Gaussian elimination is to get the matrix in row-echelon form. If a matrix is in row-echelon form, that means that reading from left to right, each row will start with at least one more zero term than the row above it. Some definitions of Gaussian elimination say that the matrix result has to be in reduced row-echelon form. That means that the matrix is in row-echelon form and the only non-zero term in each row is 1. Gaussian elimination that creates a reduced row-echelon matrix result is sometimes called Gauss-Jordan elimination.

## Example

Suppose the goal is to find the answers to this system of linear equations.

\begin{alignat}{7} 2x &&\; + \;&& y &&\; - \;&& z &&\; = \;&& 8 & \qquad (R_1) \\ -3x &&\; - \;&& y &&\; + \;&& 2z &&\; = \;&& -11 & \qquad (R_2) \\ -2x &&\; + \;&& y &&\; +\;&& 2z &&\; = \;&& -3 & \qquad (R_3) \end{alignat}

First, the system needs to be turned into an augmented matrix. In an augmented matrix, each linear equation becomes a row. On one side of the augmented matrix, the coefficients of each term in the linear equation become numbers in the matrix. On the other side of the augmented matrix are the constant terms each linear equation is equal to. For this system, the augmented matrix is:

$\left[ \begin{array}{ccc|c} 2 & 1 & -1 & 8 \\ -3 & -1 & 2 & -11 \\ -2 & 1 & 2 & -3 \end{array} \right]$

Then, row operations can be done on the augmented matrix to simplify it. The table below shows the row reduction process on the system of equations and on the augmented matrix.

System of equations Row operations Augmented matrix
\begin{alignat}{7} 2x &&\; + \;&& y &&\; - \;&& z &&\; = \;&& 8 & \\ -3x &&\; - \;&& y &&\; + \;&& 2z &&\; = \;&& -11 & \\ -2x &&\; + \;&& y &&\; +\;&& 2z &&\; = \;&& -3 & \end{alignat} $\left[ \begin{array}{ccc|c} 2 & 1 & -1 & 8 \\ -3 & -1 & 2 & -11 \\ -2 & 1 & 2 & -3 \end{array} \right]$
\begin{alignat}{7} 2x &&\; + && y &&\; - &&\; z &&\; = \;&& 8 & \\ && && \frac{1}{2}y &&\; + &&\; \frac{1}{2}z &&\; = \;&& 1 & \\ && && 2y &&\; + &&\; z &&\; = \;&& 5 & \end{alignat} $R_2 + \frac{3}{2}R_1 \rightarrow R_2$
$R_3 + R_1 \rightarrow R_3$
$\left[ \begin{array}{ccc|c} 2 & 1 & -1 & 8 \\ 0 & 1/2 & 1/2 & 1 \\ 0 & 2 & 1 & 5 \end{array} \right]$
\begin{alignat}{7} 2x &&\; + && y \;&& - &&\; z \;&& = \;&& 8 & \\ && && \frac{1}{2}y \;&& + &&\; \frac{1}{2}z \;&& = \;&& 1 & \\ && && && &&\; -z \;&&\; = \;&& 1 & \end{alignat} $R_3 + -4R_2 \rightarrow R_3$ $\left[ \begin{array}{ccc|c} 2 & 1 & -1 & 8 \\ 0 & 1/2 & 1/2 & 1 \\ 0 & 0 & -1 & 1 \end{array} \right]$

The matrix is now in row-echelon form. This is also called triangular form.

System of equations Row operations Augmented matrix
\begin{alignat}{7} 2x &&\; + && y \;&& &&\; \;&& = \;&& 7 & \\ && && \frac{1}{2}y \;&& &&\; \;&& = \;&& 3/2 & \\ && && && &&\; -z \;&&\; = \;&& 1 & \end{alignat} $R_2+\frac{1}{2}R_3 \rightarrow R_2$
$R_1 - R_3 \rightarrow R_1$
$\left[ \begin{array}{ccc|c} 2 & 1 & 0 & 7 \\ 0 & 1/2 & 0 & 3/2 \\ 0 & 0 & -1 & 1 \end{array} \right]$
\begin{alignat}{7} 2x &&\; + && y \;&& &&\; \;&& = \;&& 7 & \\ && && y \;&& &&\; \;&& = \;&& 3 & \\ && && && &&\; z \;&&\; = \;&& -1 & \end{alignat} $2R_2 \rightarrow R_2$
$-R_3 \rightarrow R_3$
$\left[ \begin{array}{ccc|c} 2 & 1 & 0 & 7 \\ 0 & 1 & 0 & 3 \\ 0 & 0 & 1 & -1 \end{array} \right]$
\begin{alignat}{7} x &&\; && \;&& &&\; \;&& = \;&& 2 & \\ && && y \;&& &&\; \;&& = \;&& 3 & \\ && && && &&\; z \;&&\; = \;&& -1 & \end{alignat} $R_1 - R_2 \rightarrow R_1$
$\frac{1}{2}R_1 \rightarrow R_1$
$\left[ \begin{array}{ccc|c} 1 & 0 & 0 & 2 \\ 0 & 1 & 0 & 3 \\ 0 & 0 & 1 & -1 \end{array} \right]$

The matrix is now in reduced row-echelon form. Reading this matrix tells us that the solutions for this system of equations occur when x = 2, y = 3, and z = -1.