# Gaussian elimination

algorithm for solving systems of linear equations

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.

{\displaystyle {\begin{alignedat}{7}2x&&\;+\;&&y&&\;-\;&&z&&\;=\;&&8&\qquad (R_{1})\\-3x&&\;-\;&&y&&\;+\;&&2z&&\;=\;&&-11&\qquad (R_{2})\\-2x&&\;+\;&&y&&\;+\;&&2z&&\;=\;&&-3&\qquad (R_{3})\end{alignedat}}}

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:

${\displaystyle \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
{\displaystyle {\begin{alignedat}{7}2x&&\;+\;&&y&&\;-\;&&z&&\;=\;&&8&\\-3x&&\;-\;&&y&&\;+\;&&2z&&\;=\;&&-11&\\-2x&&\;+\;&&y&&\;+\;&&2z&&\;=\;&&-3&\end{alignedat}}}  ${\displaystyle \left[{\begin{array}{ccc|c}2&1&-1&8\\-3&-1&2&-11\\-2&1&2&-3\end{array}}\right]}$
{\displaystyle {\begin{alignedat}{7}2x&&\;+&&y&&\;-&&\;z&&\;=\;&&8&\\&&&&{\frac {1}{2}}y&&\;+&&\;{\frac {1}{2}}z&&\;=\;&&1&\\&&&&2y&&\;+&&\;z&&\;=\;&&5&\end{alignedat}}}  ${\displaystyle R_{2}+{\frac {3}{2}}R_{1}\rightarrow R_{2}}$
${\displaystyle R_{3}+R_{1}\rightarrow R_{3}}$
${\displaystyle \left[{\begin{array}{ccc|c}2&1&-1&8\\0&1/2&1/2&1\\0&2&1&5\end{array}}\right]}$
{\displaystyle {\begin{alignedat}{7}2x&&\;+&&y\;&&-&&\;z\;&&=\;&&8&\\&&&&{\frac {1}{2}}y\;&&+&&\;{\frac {1}{2}}z\;&&=\;&&1&\\&&&&&&&&\;-z\;&&\;=\;&&1&\end{alignedat}}}  ${\displaystyle R_{3}+-4R_{2}\rightarrow R_{3}}$  ${\displaystyle \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
{\displaystyle {\begin{alignedat}{7}2x&&\;+&&y\;&&&&\;\;&&=\;&&7&\\&&&&{\frac {1}{2}}y\;&&&&\;\;&&=\;&&3/2&\\&&&&&&&&\;-z\;&&\;=\;&&1&\end{alignedat}}}  ${\displaystyle R_{2}+{\frac {1}{2}}R_{3}\rightarrow R_{2}}$
${\displaystyle R_{1}-R_{3}\rightarrow R_{1}}$
${\displaystyle \left[{\begin{array}{ccc|c}2&1&0&7\\0&1/2&0&3/2\\0&0&-1&1\end{array}}\right]}$
{\displaystyle {\begin{alignedat}{7}2x&&\;+&&y\;&&&&\;\;&&=\;&&7&\\&&&&y\;&&&&\;\;&&=\;&&3&\\&&&&&&&&\;z\;&&\;=\;&&-1&\end{alignedat}}}  ${\displaystyle 2R_{2}\rightarrow R_{2}}$
${\displaystyle -R_{3}\rightarrow R_{3}}$
${\displaystyle \left[{\begin{array}{ccc|c}2&1&0&7\\0&1&0&3\\0&0&1&-1\end{array}}\right]}$
{\displaystyle {\begin{alignedat}{7}x&&\;&&\;&&&&\;\;&&=\;&&2&\\&&&&y\;&&&&\;\;&&=\;&&3&\\&&&&&&&&\;z\;&&\;=\;&&-1&\end{alignedat}}}  ${\displaystyle R_{1}-R_{2}\rightarrow R_{1}}$
${\displaystyle {\frac {1}{2}}R_{1}\rightarrow R_{1}}$
${\displaystyle \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.