determin.ant
03-systems / 3.2

Module 3: Systems of Equations

Gaussian Elimination

Where you'll see this: Gaussian elimination is the workhorse behind most linear algebra software. NumPy's np.linalg.solve, MATLAB's backslash operator, and finite element solvers in engineering simulation all use variants of it. Understanding it means you understand what your tools are actually doing.

Knowing that a system has a solution is one thing. Finding it is another. Gaussian elimination is the systematic algorithm for doing that — and it works for any size system.

The idea: simplify without changing solutions

There are three operations you can perform on the rows of a system that preserve its solutions:

  • Swap two rows
  • Scale a row by any non-zero number
  • Add a multiple of one row to another

Using these, you reduce the system to a simpler form — one where the answer can be read off directly.

Step by step

The goal is upper triangular form: zeros below the diagonal. For a 2×2 system that means:

[ab0d][xy]=[ef]\begin{bmatrix} a & b \\ 0 & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} e \\ f \end{bmatrix}

Row 2 now says dy=fdy = f, so y=f/dy = f/d. Then substitute back into row 1 to find x. This is called back-substitution.

Step through all four examples in the interactive. Pay special attention to the "No solution" and "Infinite solutions" cases — watch what happens to the bottom row when the system is degenerate.

The augmented matrix

The columns are x-coefficients, y-coefficients, and the right-hand side (separated by the bar). Every row operation applies identically to all four numbers in a row — including the right-hand side.

In code

import numpy as np

A = np.array([[2, 1],
              [4, -1]], dtype=float)
b = np.array([5, 7], dtype=float)

x = np.linalg.solve(A, b)
print(x)   # [2. 1.]  — x=2, y=1

np.linalg.solve runs an optimised Gaussian elimination (LU decomposition) internally. Same algorithm, much faster for large systems.

Geometric InterpretationLU Decomposition
step through the row reduction
xy=
215
4-17
step 1 / 5
Starting system