Interactive Linear Algebra

Chapter 3: Row Reduction and Gauss--Jordan Elimination

Turn systems into matrices, row-reduce them, find pivots and free variables, and read the solution set directly from reduced row-echelon form.

3elementary row operations
rrefreveals pivots and free variables
3possible outcomes
rankcounts independent constraints

Learning goals

The main algorithm of this chapter is Gauss--Jordan elimination. It is the computational engine behind solving systems, finding pivots, identifying free variables, detecting inconsistency, and eventually understanding rank and bases.

Compute

Perform elementary row operations and reduce matrices to row-echelon form or reduced row-echelon form.

Interpret

Read pivot variables, free variables, consistency, and solution type from the final matrix.

Express

Write solution sets clearly, including parametric vector form when free variables occur.

Elementary row operations

Each row of an augmented matrix represents one equation. Row operations rewrite the system without changing its solution set.

1. Swap rows

$$R_i \leftrightarrow R_j$$

Only changes the order of equations.

2. Scale a row

$$R_i\leftarrow cR_i,\qquad c\ne0$$

Multiplies an equation by a nonzero number.

3. Replace a row

$$R_i\leftarrow R_i+cR_j$$

Adds a multiple of one equation to another.

Core principle. Elementary row operations preserve the solution set of a linear system. They change the appearance of the system, not the answer.

Row-echelon form versus reduced row-echelon form

Row-echelon form

A staircase pattern of pivots, with zeros below each pivot.

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

Useful for back substitution.

Reduced row-echelon form

Each pivot is $1$ and is the only nonzero entry in its column.

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

Useful because solutions can be read off directly.

Vocabulary. Pivot columns give pivot variables. Non-pivot variable columns give free variables.

Interactive rref lab

Enter an augmented matrix or choose a preset. The tool performs exact Gauss--Jordan elimination using rational arithmetic, displays the row-operation steps, identifies pivots/free variables, and classifies the solution set.

Use one row per line. Entries may be integers, decimals, or fractions, for example 1 -3 -5 1 or 0 1 3/2 -1/2.

What to look for

Final patternMeaning
Pivot in every variable columnUnique solution, unless contradiction appears
At least one free variableInfinitely many solutions, unless contradiction appears
$[0\;0\;\cdots\;0\mid c]$, $c\ne0$No solution
Important. A zero row means redundant information. A row like $0=1$ means contradiction.

The three possible outcomes

Unique solution

Every variable is a pivot variable and there is no contradiction.

$$\left[\begin{array}{ccc|c}1&0&0&2\\0&1&0&-1\\0&0&1&3\end{array}\right]$$
Infinitely many

At least one free variable and no contradiction.

$$\left[\begin{array}{ccc|c}1&0&2&3\\0&1&-1&4\\0&0&0&0\end{array}\right]$$
No solution

A contradiction row appears, such as $0=1$.

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

Homogeneous systems

A homogeneous system has the form $Ax=0$. It is always consistent because $x=0$ is always a solution.

Only zero solution

If every variable is a pivot variable, then $x=0$ is the only solution.

Infinitely many solutions

If at least one variable is free, then infinitely many solutions pass through the origin.

$$\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}=s\begin{bmatrix}-2\\1\\0\end{bmatrix}+t\begin{bmatrix}-3\\0\\1\end{bmatrix}$$

Rank preview

The rank of a matrix is the number of pivot positions in its row-echelon form. Rank measures how much independent information is contained in the rows or columns.

In data and AI, row reduction is a first exact model of detecting redundancy and independent structure. Later, QR factorization and SVD will give more stable and scalable versions of this idea.

Python connection

For exact row reduction, use SymPy. For square systems with a unique numerical solution, NumPy's np.linalg.solve is convenient.

Exact rref with SymPy

import sympy as sp

M = sp.Matrix([
    [1, -3, -5, 1],
    [1, -1, -2, 0],
    [3, -1,  1, 3]
])

M_rref, pivot_columns = M.rref()
M_rref, pivot_columns

Numerical solving with NumPy

import numpy as np

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

b = np.array([1, 0, 3], dtype=float)
x = np.linalg.solve(A, b)
A @ x

Common mistakes

Using zero as a pivot

A pivot must be nonzero. Swap rows if needed.

Dividing by zero

Scaling a row is allowed only by a nonzero scalar.

Ignoring the right-hand side

In augmented matrices, operate on the entire row, including constants.

Losing free variables

Do not set free variables to zero unless you only want one particular solution.

Quick check

1. Which row operation is not allowed: $R_2\leftarrow 0R_2$, $R_2\leftarrow R_2-3R_1$, or $R_1\leftrightarrow R_3$?
$R_2\leftarrow 0R_2$ is not allowed because multiplying a row by zero loses information and cannot be reversed.
2. What does a row $[0\;0\;0\mid 5]$ mean?
It means $0=5$, a contradiction. The system is inconsistent and has no solution.
3. In a system with 5 variables and 3 pivots, how many free variables are there?
There are $5-3=2$ free variables.