*This page is intended to be a part of the Numerical Analysis section of Math Online. Similar topics can also be found in the Linear Algebra section of the site.*

# The Gaussian Elimination Algorithm

Consider a general system of $n$ linear equations of $n$ unknowns:

(1)Suppose that this system indeed has a solution (that is the coefficient matrix is nonsingular). Now take the coefficient matrix $A$ for this system and adjoin the column matrix $b = \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix}$. We denote this new $n \times n + 1$ augmented matrix as $[ \: A \: | \: b \: ]$.

(2)Our goal is to use elementary row operations to transform the augmented matrix above into the following form:

(3)In other words, we want to reduce the coefficient matrix $A$ so that it is an upper triangular matrix while applying the same elementary row operations to the matrix $b$. The matrix above is row equivalent to the augmented matrix of our system, and so the solutions to this matrix are the same as the solutions to the original system equations. The benefit with having the matrix above is that it is much simpler to solve. Note that the above augmented matrix is equivalent to the following system of equations:

(4)We immediately see that $x_n = b_n$. We can then take this and substitute this into the equation $x_{n-1} + a_{(n-1, n)}x_n = b_{n-1}$ and solve for $x_{n-1}$. Repeating this process and we obtain the entire solution to the original system by successive **Back Substitution**. This entire technique is known as **Gaussian Elimination** and is a nice method for solving systems of $n$ equations with $n$ variables.

Now let's take a closer look at the Gaussian Elimination Algorithm. For this algorithm, we will assume that we are not every dividing by zero (we'll look more into this later). Let $E(k)$ denote the $k^{\mathrm{th}}$ equation in our system of $n$ equations in $n$ variables for $k = 1, 2, ..., n$. Our system can be written in the following form:

(5)The first step that we want to do is to eliminate the variable $x_1$ from equations $E(2)$ through to $E(n)$. This will make it so that our system of equations have zeros underneath the entry $a_{11}^{(1)}x_{1}$. In doing so, we obtain the equivalent system below.

(6)Let $m_{21} = \frac{a_{21}^{(1)}}{a_{11}^{(1)}}$, $m_{31} = \frac{a_{31}^{(1)}}{a_{11}^{(1)}}$, …, $m_{n1} = \frac{a_{n1}^{(1)}}{a_{11}^{(1)}}$. Then the coefficients $a_{ij}^{(2)}$ and $b_i^{(2)}$ in the matrix above can be obtained with the following formulas:

(7)At the $k^{\mathrm{th}}$ step, we will have the following (partially reduced) matrix to work with:

(8)At this step we will want to eliminate the variable $x_k$ from the equations $E(k+1)$ through to $E(n)$. This will make it so that all entries under $a_{kk}^{(k)}x_k$ are zero.

Let $m_{ik} = \frac{a_{ik}^{(k)}}{a_{kk}^{(k)}}$ for $i = k+1, k+2, ..., n$. For equations $E(k+1)$, $E(k+2)$, …, $E(n)$ we will subtract $m_{ik}$ times $E(k)$ from $E(i)$ for each $i = k+1, k+2, ..., n$. The coefficients below equation $E(k)$ will be:

(9)At the $(n - 1)^{\mathrm{th}}$ step will will have transformed our system into an "upper triangular" equivalent form:

(10)The coefficients of this row equivalent system we will denote as $u_{ij} = a_{ij}^{(i)}$ and $g_i = b_i^{(i)}$ for $i = 1, 2, ..., n$. We then proceed to solve this system of equations by back substitution. We have that for $i = n-1, n-2, ..., 1$:

(11)