math-gaussian-elimination.html


* created: 2025-05-29T10:40
* modified: 2025-06-24T18:28

title

Gaussian Elimination

description

Describes a method of solving systems of linear equations in which the coefficient matrix is brought into it upper triangular form, which allows us to solve the equation by back substitution.

Solving for multiple unknowns

We use Gaussian Elimination when trying to the value an unknown variable could be (sometimes could be multiple) in a line's equation system like this, for example: \begin{aligned} & \mathrm{(I)} \quad x_{1} + x_{2} = 60 \\ & \mathrm{(II)} \quad x_{1} - 2x_{2} = 0 \\ \end{aligned}


Coefficient Matrix

The matrix of all coefficients :). Going with the previous example, the coefficient matrix would look like this: \begin{bmatrix} 1 & 1 \\ 1 & -2 \end{bmatrix}


Extended Coefficient Matrix

The extended coefficient matrix includes the resulting values is denoted like this: \left[ \begin{array}{cc|c} 1 & 1 & 60 \\ 1 & -2 & 0 \end{array} \right]


Row Echelon Form (REF)

In German: Zeilenstufenform

Allowed operations:

  1. Swap two rows
  2. Multiply a row by a non-zero constant
  3. Add or subtract another row or the multiple of another row

Solving a linear equation.

The following example illustrates how we can use to solve for our unknown variables.

Defining the linear equation system.

Anna and Ben have picked 60 apples together. Anna has twice as many apples as Ben. How many apples do Anna and Ben each have? Set up a corresponding system of linear equations and solve it using the Gaussian elimination method.

Given is: \begin{aligned} & \mathrm{(I)} \quad x_{1} + x_{2} = 60 \\ & \mathrm{(II)} \quad x_{1} - 2x_{2} = 0 \\ \end{aligned}

Solution:

We subtracted \mathrm{(I)} from \mathrm{(II)}: $$ \begin{aligned}

&& (x_{1} + x_{2}) - (x_{1} - 2x_{2}) &= 60 - 0 \ &\Leftrightarrow &3x_{2} &= 60 ; | \div 3 \ &\Leftrightarrow &x_{2} &= 20 \ \

&& x_{1} = 2x_{2} = 2 \times 20 &= 40 \ \end{aligned} $$

The solution to the linear equation system is: $$ \begin{bmatrix} x_{1} \ x_{2} \end{bmatrix}

\begin{bmatrix} 40 \ 20 \end{bmatrix} $$

Solving with the shorthand matrix notation

This is especially useful if we have complex operation we don't want to write out by hand.

Given are the following linear equations systems over \mathbb{R}: \begin{align} & \mathrm{(I)} & 2x_{1} + 3x_{2} - x_{3} & = 7 \\ & \mathrm{(II)} & 4x_{1} - 2x_{2} + 5x_{3} & = 12 \\ & \mathrm{(III)} & x_{1} + x_{2} + 3x_{3} & = 5 \end{align}

This is the coefficient matrix: \begin{bmatrix} 2 & 3 & -1 \\ 4 & -2 & 5 \\ 1 & 1 & 3 \end{bmatrix}

We first need to define the extended coefficient matrix: B := \left[ \begin{array}{ccc|c} 2 & 3 & -1 & 7 \\ 4 & -2 & 5 & 12 \\ 1 & 1 & 3 & 5 \end{array} \right]

Now we need to convert the extended coefficient matrix into its row echelon form. This is done by cleverly transforming the matrix: $$ \begin{align}

& \left[ \begin{array}{ccc|c} 2 & 3 & -1 & 7 \ 4 & -2 & 5 & 12 \ 1 & 1 & 3 & 5 \end{array} \right]

\xrightarrow{R_{\mathrm{II}} \to R_{\mathrm{II}} - 2R_{\mathrm{I}}, ; R_{\mathrm{III}} \to R_{III} - 0.5R_{\mathrm{I}}} \

& \left[ \begin{array}{ccc|c} 2 & 3 & -1 & 7 \ 0 & -8 & 7 & -2 \ 0 & -0.5 & 3.5 & 1.5 \end{array} \right]

\xrightarrow{R_{\mathrm{III} } \to R_{\mathrm{III}} - \frac{0.5}{8} R_{\mathrm{II}}} \

& \left[ \begin{array}{ccc|c} 2 & 3 & -1 & 7 \ 0 & -8 & 7 & -2 \ 0 & 0 & 3.0625 & 1.625 \end{array} \right]

\end{align} $$

We can derive \begin{bmatrix} x_{1} & x_{2} & x_{3} \end{bmatrix} through back substitution: \begin{align} 3.0625 x_{3} & = 1.625 \; | \div 3.0625 \\ x_{3} & \approx 0.531 \end{align}

We can now substitute x_{3} in R_{\mathrm{II}} to solve for x_{2}: \begin{align} -8x_{2} + 7 \cdot 0.531 & = -2 \\ -8x_{2} + 3.717 & = -2 & | -3.717 \\ -11.717x_{2} & = -5.717 & | \div 11.171 \\ x_{2} & \approx 0.488 \end{align}

Finally, we solve for x_1 by substituting x_{2}, x_{3} in R_{I}: \begin{align} 2x_{1} + 3 \cdot 0.488 + -1 \cdot 0.531 & = 7 \\ 2x_{1} + 1.464 - 0.531 & = 7 \\ 2x_{1} + 0.933 & = 7 & | -0.933\\ 2x_{1} & = 6.067 & | \div 2\\ x_{1} & = 3.0335 \\ \end{align}

Therefor: \begin{bmatrix} x_{1} \\ x_{2} \\ x_{3} \end{bmatrix} \approx \begin{bmatrix} 0.531 \\ 0.488 \\ 3.0335 \end{bmatrix}