Gaussian elimination is a systematic algorithm for solving systems of linear equations by converting the system into an augmented matrix and then applying row operations to reach a triangular form. Named after Carl Friedrich Gauss, it is the foundational method of linear algebra and the approach used by every computer algebra system in the world to solve linear systems.
Unlike substitution and elimination (which rely on intuition about which variable to isolate), Gaussian elimination is purely mechanical — follow the steps and you will always reach the answer, whether the system has one solution, no solution, or infinitely many solutions.
The Augmented Matrix
An augmented matrix is a compact way to write a system of equations. You strip away the variables and write only the coefficients and constants, separated by a vertical bar.
For the system:
2x+3y=8
x−y=1
The augmented matrix is:
[213−181]
Each row represents one equation. The columns to the left of the bar correspond to the variable coefficients (first column is x, second is y), and the column to the right is the constants.
For a 3-variable system like:
x+2y−z=3
2x−y+3z=7
−x+y+2z=4
The augmented matrix is:
12−12−11−132374
The Three Row Operations
You may perform exactly three operations on the rows of a matrix. These operations do not change the solution set of the system.
Operation
Notation
Description
Swap two rows
Ri↔Rj
Exchange the positions of two rows
Scale a row
kRi→Ri
Multiply every entry in a row by a nonzero constant k
Row replacement
Ri+kRj→Ri
Add a multiple of one row to another row
These are the only moves you need. Every Gaussian elimination problem uses some combination of these three operations.
Row Echelon Form (REF)
The goal of Gaussian elimination is to transform the matrix into row echelon form, where:
All nonzero rows are above any all-zero rows
The leading entry (called the pivot) of each nonzero row is to the right of the pivot in the row above
All entries below each pivot are zero
A 3x3 system in row echelon form looks like:
100∗10∗∗1∗∗∗
where ∗ represents any number. Once you reach this form, you solve by back-substitution — start with the bottom equation and work upward.
Reduced Row Echelon Form (RREF) — Gauss-Jordan
Gauss-Jordan elimination continues beyond REF to reduced row echelon form (RREF), where every pivot is 1 and every other entry in a pivot column is 0:
100010001abc
In RREF, the solution reads directly from the matrix: x=a, y=b, z=c. No back-substitution needed.
Worked Examples
Example 1: Solving a 2x2 System
Solve:
2x+3y=8
x−y=1
Step 1 — Write the augmented matrix:
[213−181]
Step 2 — Swap rows to put a leading 1 in the top-left position (R1↔R2):
[12−1318]
Step 3 — Eliminate the entry below the pivot. Apply R2−2R1→R2:
[10−1516]
Step 4 — Scale Row 2 (51R2→R2):
[10−11156]
This is row echelon form. Back-substitute: from Row 2, y=56. Substituting into Row 1: x−56=1, so x=1+56=511.
Answer:x=511, y=56
To verify: 2(511)+3(56)=522+518=540=8 and 511−56=55=1.
Example 2: Solving a 3x3 System
Solve:
x+2y−z=3
2x−y+3z=7
−x+y+2z=4
Step 1 — Write the augmented matrix:
12−12−11−132374
Step 2 — Eliminate below the first pivot. Apply R2−2R1→R2 and R3+R1→R3:
1002−53−151317
Step 3 — Scale Row 2 (−51R2→R2):
100213−1−113−517
Step 4 — Eliminate below the second pivot. Apply R3−3R2→R3:
100210−1−143−51538
Step 5 — Scale Row 3 (41R3→R3):
100210−1−113−511019
This is row echelon form. Now back-substitute:
From Row 3: z=1019
From Row 2: y−z=−51, so y=−51+1019=−102+1019=1017
From Row 1: x+2y−z=3, so x=3−2(1017)+1019=3−1034+1019=3−1015=3−23=23
Answer:x=23, y=1017, z=1019
Example 3: An Inconsistent System
Solve:
x+y=3
2x+2y=10
Augmented matrix:
[1212310]
Apply R2−2R1→R2:
[101034]
Row 2 now reads 0x+0y=4, which is 0=4 — a contradiction. This system is inconsistent and has no solution. Geometrically, the two lines are parallel.
Example 4: A Dependent System with Free Variables
Solve:
x+2y−z=1
2x+4y−2z=2
−x−2y+z=−1
Augmented matrix:
12−124−2−1−2112−1
Apply R2−2R1→R2 and R3+R1→R3:
100200−100100
All three equations were multiples of the same equation. There is only one independent equation with three unknowns, so y and z are free variables. Let y=s and z=t (where s and t are any real numbers). Then from Row 1:
x=1−2s+t
Answer: The system has infinitely many solutions: (x,y,z)=(1−2s+t,s,t) for any real numbers s and t.
An electrician analyzing a circuit with three loops writes Kirchhoff’s voltage equations:
I1+2I2−I3=5
3I1−I2+2I3=10
−I1+I2+3I3=8
where I1, I2, I3 are loop currents in amps. Rather than juggling three equations by hand, the electrician writes the augmented matrix and applies Gaussian elimination — the same mechanical process regardless of how many loops the circuit has. For circuits with 10 or 20 unknowns (common in industrial work), Gaussian elimination is the only practical approach.
Common Mistakes
Applying a row operation to the wrong row. When you compute R2−3R1, the result replaces R2, not R1. The pivot row stays unchanged.
Forgetting to apply the operation to every entry. When you multiply a row by a constant or add a multiple of another row, every entry in the row (including the constant after the bar) must be updated.
Dividing by zero. If a pivot position contains 0, swap that row with a row below that has a nonzero entry in that column. If no such row exists, the variable is free.
Arithmetic errors with fractions. Gaussian elimination often produces fractions. Work carefully, or multiply a row by a convenient number to clear denominators before proceeding.
Practice Problems
Test your understanding with these problems. Click to reveal each answer.
Problem 1: Write the augmented matrix for the system 3x−2y=7, x+4y=−1.
[31−247−1]
Problem 2: Solve using Gaussian elimination: x+y=5, 3x−y=3.
Augmented matrix:
[131−153]
R2−3R1→R2:
[101−45−12]
−41R2→R2:
[101153]
From Row 2: y=3. From Row 1: x+3=5, so x=2.
Answer:x=2, y=3
Problem 3: Solve the 3x3 system: x+y+z=6, 2x−y+z=3, x+2y−z=5.
Augmented matrix:
1211−1211−1635
R2−2R1→R2 and R3−R1→R3:
1001−311−1−26−9−1
Swap R2↔R3:
10011−31−2−16−1−9
R3+3R2→R3:
1001101−2−76−1−12
−71R3→R3:
1001101−216−1712
From Row 3: z=712
From Row 2: y=−1+2⋅712=−1+724=717
From Row 1: x=6−717−712=6−729=713
Answer:x=713, y=717, z=712
Problem 4: Determine whether this system is inconsistent, dependent, or has a unique solution: x−2y=3, −2x+4y=5.
Augmented matrix:
[1−2−2435]
R2+2R1→R2:
[10−20311]
Row 2 reads 0=11, a contradiction. The system is inconsistent (no solution). The lines are parallel.
Problem 5: Solve and express the solution in terms of a free variable: x+3y−2z=4, 2x+6y−4z=8.
Augmented matrix:
[1236−2−448]
R2−2R1→R2:
[1030−2040]
Row 2 is all zeros — the two equations are identical. Both y and z are free variables. Let y=s, z=t:
x=4−3s+2t
Answer:(x,y,z)=(4−3s+2t,s,t) for any real numbers s and t.
Key Takeaways
An augmented matrix separates coefficients from constants with a vertical bar, compactly representing a system of equations
The three row operations (swap, scale, replace) transform a matrix without changing the solution set
Row echelon form (REF) has zeros below each pivot — solve by back-substitution
Reduced row echelon form (RREF) has zeros above and below each pivot — the solution reads directly
A row of the form [00⋯0∣c] with c=0 signals an inconsistent system (no solution)
A row of all zeros indicates a dependent equation — expect free variables and infinitely many solutions
Gaussian elimination works for systems of any size and always terminates