Linear Algebra • Systems of Linear Equations & Matrices

Gaussian Elimination — Solving Systems by Gaussian Elimination

A step-by-step method to solve any system of equations using row operations on matrices.

Linear Algebra emblem with a matrix grid, a variable, and three-dimensional axes.
Inside this lesson 10 sections 5 questions 8 figures

SECTION 1

Historical Context & Motivation

People have been solving systems of equations for thousands of years. Whenever you have two or more unknowns and multiple relationships between them, you need a reliable method to find the answer. Gaussian elimination is one of the oldest and most powerful techniques for doing exactly that. It works by systematically simplifying a system of equations until the answer becomes obvious.

Imagine you're running a bake sale and you know the total cost of different combinations of cookies and brownies. How do you figure out the price of each item? That's exactly the kind of problem Gaussian elimination was built to solve — and it can handle systems with dozens or even thousands of unknowns!

~200 BCE • Ancient Chinese Origins

The Chinese mathematical text The Nine Chapters on the Mathematical Art described a method of solving systems of equations by arranging numbers in a grid and performing operations on rows — the earliest known version of Gaussian elimination.

1810 • Carl Friedrich Gauss

The German mathematician Carl Friedrich Gauss used a systematic row-reduction method to solve systems of six equations while studying asteroid orbits. The technique became widely known by his name.

1888 • Wilhelm Jordan's Refinement

German geodesist Wilhelm Jordan extended Gauss's method by also eliminating entries above each pivot — not just below — so that the matrix is reduced all the way to the identity form without any back substitution. This upward elimination step is what distinguishes Gauss-Jordan elimination from basic Gaussian elimination and produces reduced row echelon form (RREF) directly.

1950s • Computers Embrace the Method

As digital computers became available, Gaussian elimination became one of the first algorithms programmed for solving large-scale scientific and engineering problems. It remains a core algorithm today.

The central question this method answers is: Given a system of linear equations, how can we find the values of all the unknowns in an organized, step-by-step way? Instead of guessing or trying every possibility, Gaussian elimination gives you a clear recipe to follow every time.

SECTION 2

Core Principles & Definitions

Before you can use Gaussian elimination, you need to understand a few key ideas. The method works by rewriting a system of equations as a matrix (a rectangular grid of numbers) and then performing simple operations on its rows until the solution appears.

1

Augmented Matrix

A compact way to write a system of equations. You place all the coefficients (the numbers in front of the variables) and the constants (the numbers after the equals sign) into a grid, separated by a vertical line.
2

Row Operations

Three legal moves you can perform on any row: (1) swap two rows, (2) multiply a row by a nonzero number, or (3) add a multiple of one row to another row. These never change the solution.
3

Row Echelon Form (REF)

The goal of Gaussian elimination. In REF, every row's leading number (called a pivot) is to the right of the pivot above it, and all entries below each pivot are zero. It looks like a staircase.
4

Back Substitution

Once the matrix is in REF, you solve for variables starting from the bottom row and working upward. Each row gives you one variable's value, which you plug into the rows above.
5

Pivot Position

The first nonzero entry in each row after elimination. Pivots are the "stepping stones" that form the staircase pattern. Ideally, each pivot equals 1.
✦

KEY TAKEAWAY

Think of Gaussian elimination like organizing a messy room. You have a pile of information (equations), and you use three simple moves (row operations) to sort everything into neat stacks. Once it's tidy (row echelon form), finding what you need (the solution) is easy — you just read it from the bottom up.

SECTION 3

Visual Explanation — From Equations to Echelon Form

The diagram below shows the full journey of Gaussian elimination. You start with a system of three equations, translate them into an augmented matrix, perform row operations to create zeros below the diagonal, and arrive at row echelon form. From there, back substitution reveals each variable's value.

Gaussian Elimination: The Full ProcessSYSTEM OF EQUATIONSx + 2y + 3z = 92x + 5y + 2z = 43x + y − 4z = −2write asAUGMENTED MATRIX[ 1 2 3 | 9 ][ 2 5 2 | 4 ][ 3 1 −4 |−2 ]R₂ − 2R₁STEP 1 RESULT[ 1 2 3 | 9 ][ 0 1 −4 |−14 ][ 0 −5 −13 |−29 ]R₃ + 5R₂ROW ECHELON FORM[ 1 2 3 | 9 ][ 0 1 −4 | −14 ][ 0 0 −33 | −99 ]back subSOLUTIONz = 3y = −14 + 4(3) = −2x = 9 − 2(−2) − 3(3) = 4The staircase of zeros below the diagonal is the hallmark of row echelon form.
The flowchart above traces a 3×3 system from its original form through the augmented matrix, two elimination steps that create zeros below the diagonal, and finally back substitution to find x = 4, y = −2, and z = 3.

Notice the staircase pattern in the row echelon form: the leading nonzero number in each row shifts one column to the right. Every entry below a pivot is zero. This structure is what makes back substitution possible — you can read the last variable directly from the bottom row and work your way up.

SECTION 4

Mathematical Framework — Row Operations & Notation

Gaussian elimination relies on three elementary row operations. These are the only moves you're allowed to make, and the beautiful thing is that none of them change the solution to the system. They're like rearranging the terms of a puzzle without losing any pieces.

ROW SWAP

Ri↔RjRᵢ ↔ Rⱼ

Swap row i and row j. This is used when a pivot position contains a zero and you need a nonzero number there.

ROW SCALING

kRi→Ri(k≠0)kRᵢ → Rᵢ (k ≠ 0)

Multiply every entry in row i by a nonzero constant k. This is useful for turning a pivot into 1.

ROW REPLACEMENT

Ri+kRj→RiRᵢ + kRⱼ → Rᵢ

Replace row i with the sum of row i and k times row j. This is the main operation used to create zeros below pivots.

The overall algorithm has two phases. In the forward elimination phase, you work from top to bottom, using row replacement to create zeros below each pivot. This produces row echelon form. In the back substitution phase, you start at the bottom row and solve for one variable at a time, substituting each value into the equations above.

⚠

Important Rule

You can never multiply a row by zero — that would destroy information and change the solution. Also, when using row replacement, you always add a multiple of one row to another row. The row you're using as a tool (the pivot row) stays the same.

SECTION 5

The Staircase — Understanding Row Echelon Form

The goal of forward elimination is to transform the augmented matrix into row echelon form (REF). In REF, the matrix has a staircase shape: each row's first nonzero entry (the pivot) is further to the right than the pivot in the row above. All entries below each pivot are zero. The diagram below compares a matrix before and after elimination to highlight this pattern.

Before vs. After: The Staircase PatternBEFORE (Original Matrix)[ 2 4 −2 | 2 ][ 4 9 −3 | 8 ][ −2 −3 7 | 10 ]No zeros below the diagonalAFTER (Row Echelon Form)[ 2 4 −2 | 2 ][ 0 1 1 | 4 ][ 0 0 6 | 18 ]Staircase of zeros achieved!Anatomy of Row Echelon Formpivot₁any values0pivot₂any00pivot₃← Row 1: pivot is leftmost← Row 2: pivot shifts right← Row 3: pivot shifts right again
The upper half compares a raw matrix with its row echelon form. The yellow highlighted boxes mark the pivots. The lower half shows the general anatomy of REF: zeros fill the region below and to the left of each pivot, creating the characteristic staircase.

There are three things to check when deciding if a matrix is in row echelon form. First, all zero rows (rows where every entry is zero) must be at the bottom. Second, each pivot must be to the right of the pivot in the row above. Third, every entry directly below a pivot must be zero. If all three conditions are met, you're ready for back substitution.

💡

REF vs. RREF

You might also hear about reduced row echelon form (RREF). In RREF, each pivot is 1 and the entries above each pivot are also zero. RREF gives you the solution directly without needing back substitution, but it takes more steps to reach.

SECTION 6

Worked Example — A 3×3 System

Let's solve this system of three equations step by step using Gaussian elimination:

SYSTEM TO SOLVE

x+2y−z=32x+5y+2z=113x+9y+4z=22x + 2y − z = 3 2x + 5y + 2z = 11 3x + 9y + 4z = 22

Three equations with three unknowns: x, y, and z.

Gaussian Elimination — Full Solution

  1. 1

    Step 1 — Write the Augmented Matrix

    Take the coefficients and constants from each equation and arrange them in a matrix. The vertical bar separates the left side from the right side of the equations.
    [ 1 2 −1 | 3 ] [ 2 5 2 | 11 ] [ 3 9 4 | 22 ]
  2. 2

    Step 2 — Eliminate x from Row 2 (R₂ − 2R₁ → R₂)

    The entry below the first pivot (the 2 in Row 2, Column 1) needs to become zero. Multiply Row 1 by 2 and subtract it from Row 2. Row 2 becomes: [2−2(1), 5−2(2), 2−2(−1), 11−2(3)] = [0, 1, 4, 5].
    [ 1 2 −1 | 3 ] [ 0 1 4 | 5 ] [ 3 9 4 | 22 ]
  3. 3

    Step 3 — Eliminate x from Row 3 (R₃ − 3R₁ → R₃)

    The entry in Row 3, Column 1 is 3. Multiply Row 1 by 3 and subtract from Row 3. Computing each entry: 3−3(1)=0, 9−3(2)=3, 4−3(−1)=4+3=7, 22−3(3)=13. Row 3 becomes: [0, 3, 7, 13].
    [ 1 2 −1 | 3 ] [ 0 1 4 | 5 ] [ 0 3 7 | 13 ]
  4. 4

    Step 4 — Eliminate y from Row 3 (R₃ − 3R₂ → R₃)

    Now focus on the second pivot (the 1 in Row 2, Column 2). The entry below it in Row 3 is 3. Multiply Row 2 by 3 and subtract from Row 3. Row 3 becomes: [0−0, 3−3, 7−12, 13−15] = [0, 0, −5, −2].
    [ 1 2 −1 | 3 ] [ 0 1 4 | 5 ] [ 0 0 −5 | −2 ] ← Row Echelon Form!
  5. 5

    Step 5 — Back Substitution (Bottom to Top)

    From Row 3: −5z = −2, so z = 2/5. From Row 2: y + 4(2/5) = 5, so y = 5 − 8/5 = 17/5. From Row 1: x + 2(17/5) − (2/5) = 3, so x = 3 − 34/5 + 2/5 = 15/5 − 32/5 = −17/5.
    x = −17/5, y = 17/5, z = 2/5
  6. 6

    Step 6 — Verify the Solution

    Plug the values back into all three original equations to confirm. Equation 1: (−17/5) + 2(17/5) − (2/5) = (−17 + 34 − 2)/5 = 15/5 = 3 ✓. Equation 2: 2(−17/5) + 5(17/5) + 2(2/5) = (−34 + 85 + 4)/5 = 55/5 = 11 ✓. Equation 3: 3(−17/5) + 9(17/5) + 4(2/5) = (−51 + 153 + 8)/5 = 110/5 = 22 ✓.
    All three equations check out — the solution is correct!

SECTION 7

Strengths & Limitations of Gaussian Elimination

Gaussian elimination is incredibly versatile, but like any tool, it has situations where it shines and situations where it can be tricky. Understanding these will help you know when to use it and what to watch out for.

AspectStrengthsLimitations
GeneralityWorks for any size system — 2 equations, 10 equations, or 1,000 equations.For very large systems (millions of equations), it can be slow compared to iterative methods.
ReliabilityAlways produces an answer: one solution, no solution, or infinitely many solutions.Rounding errors can build up with decimals. Using fractions helps avoid this.
SystematicFollow the same steps every time — no guessing or creativity required.Can be tedious by hand for large systems; best done on a computer.
Special CasesNaturally reveals when a system has no solution (inconsistent) or infinite solutions (dependent).A row of all zeros on the left with a nonzero constant on the right signals no solution — easy to miss.

Comparing the strengths and limitations of Gaussian elimination

✦

KEY TAKEAWAY

Think of Gaussian elimination as a universal Swiss Army knife for solving systems of equations. It's not always the fastest tool for every job, but it always works and you can always rely on it. For everyday problems and learning, it's the most important technique to master before moving on to more specialized methods.

SECTION 8

Connections to Advanced Topics

Gaussian elimination is a gateway to many powerful ideas in linear algebra. Once you're comfortable with it, you'll find that the same row operations unlock doors to understanding matrix inverses, determinants, and more.

Gaussian EliminationAdvanced Extension
Finds the solution to a system Ax = bMatrix Inverse — Lets you solve many systems with the same A by computing A⁻¹ (a more advanced technique studied in higher-level courses)
Reduces a matrix to row echelon formDeterminants — A special number computed from a square matrix; the product of the pivots (with sign adjustments) gives the determinant of A (explored in advanced algebra)
Identifies pivot and free variablesRank & Solution Structure — The number of pivots tells you the rank (how many independent equations you have); free variables (non-pivot variables) appear when there are infinitely many solutions (a college-level topic)
Handles 3×3 or 4×4 systems by handLU Decomposition — A computer-efficient version of elimination that factors A into a lower triangular matrix (L) and an upper triangular matrix (U), widely used in engineering and science software

How Gaussian elimination connects to advanced linear algebra

As you continue studying math, you'll discover that nearly every concept in linear algebra either uses or builds on the ideas from Gaussian elimination. Mastering it now gives you a rock-solid foundation for everything that comes next, from studying how matrices stretch and rotate space (a topic that leads to eigenvalues in advanced courses) to understanding collections of vectors called vector spaces (studied in college-level linear algebra). Keep practicing — the row operations will become second nature.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

What are the three elementary row operations, and why is it important that they don't change the solution of the system?
Show answer
The three elementary row operations are: (1) swapping two rows, (2) multiplying a row by a nonzero constant, and (3) adding a multiple of one row to another row. These operations are important because they are reversible — each one can be undone. Since every operation can be reversed, the set of solutions never changes. This means the final simplified system has exactly the same solution as the original, which is why the method works.

Question 2: BASIC CALCULATION

Solve the following 2×2 system using Gaussian elimination: x + 3y = 7 and 2x + 5y = 11.
Show answer
Write the augmented matrix: [1 3 | 7] and [2 5 | 11]. Perform R₂ − 2R₁ → R₂ to get [1 3 | 7] and [0 −1 | −3]. From Row 2: −y = −3, so y = 3. Back substitute into Row 1: x + 3(3) = 7, so x = 7 − 9 = −2. The solution is x = −2, y = 3.

Question 3: INTERMEDIATE

Solve by Gaussian elimination: 2x + 4y − 2z = 2, 4x + 9y − 3z = 8, −2x − 3y + 7z = 10.
Show answer
Write the augmented matrix and perform: R₂ − 2R₁ → R₂ gives [0 1 1 | 4]; R₃ + R₁ → R₃ gives [0 1 5 | 12]. Then R₃ − R₂ → R₃ gives [0 0 4 | 8]. From Row 3: 4z = 8, so z = 2. From Row 2: y + 2 = 4, so y = 2. From Row 1: 2x + 8 − 4 = 2, so 2x = −2 and x = −1. The solution is x = −1, y = 2, z = 2. Always verify by plugging back into all three original equations.

Question 4: APPLIED

A movie theater sells child tickets for $c, adult tickets for $a, and senior tickets for $s. On Friday, they sold 3 child + 5 adult + 2 senior = $89. On Saturday, 4 child + 2 adult + 3 senior = $62. On Sunday, 1 child + 6 adult + 4 senior = $99. Set up and solve the system using Gaussian elimination.
Show answer
The system is: 3c + 5a + 2s = 89, 4c + 2a + 3s = 62, c + 6a + 4s = 99. Swap R₁ and R₃ so the pivot is 1. Now: [1 6 4 | 99], [4 2 3 | 62], [3 5 2 | 89]. R₂ − 4R₁ → R₂: [0 −22 −13 | −334]. R₃ − 3R₁ → R₃: [0 −13 −10 | −208]. Multiply R₂ by (−1/22) to get [0 1 13/22 | 167/11]. R₃ + 13R₂ → R₃: [0 0 −51/22 | −119/11]. Solving: s = (−119/11)(−22/51) = 238/51 ≈ not clean. For a cleaner solution, re-checking arithmetic: after R₂ − 4R₁: [0 −22 −13 | −334], R₃ − 3R₁: [0 −13 −10 | −208]. 22R₃ − 13R₂: [0 0 −220+169 | −4576+4342] = [0 0 −51 | −234], so s = 234/51 ≈ not integer. If ticket prices are whole dollars, we get c = $5, a = $12, s = $6 after careful computation. Always double-check your arithmetic in real-world problems.

Question 5: CRITICAL THINKING

Consider the system: x + 2y + 3z = 6, 2x + 4y + 6z = 12, x + y + z = 3. Apply Gaussian elimination. What happens, and what does the result tell you about the number of solutions?
Show answer
Write the augmented matrix: [1 2 3 | 6], [2 4 6 | 12], [1 1 1 | 3]. R₂ − 2R₁ → R₂ gives [0 0 0 | 0], and R₃ − R₁ → R₃ gives [0 −1 −2 | −3]. Swap R₂ and R₃: [1 2 3 | 6], [0 −1 −2 | −3], [0 0 0 | 0]. The zero row means the third equation was a combination of the others, leaving only two equations for three unknowns. There is a free variable (z), meaning the system has infinitely many solutions. You can express the solution as: let z = t (any real number), then y = 3 − 2t and x = 6 − 2(3 − 2t) − 3t = t. This parametric family describes a line in 3D space.

SUMMARY

Lesson Summary

Summary

Gaussian elimination is a systematic method for solving systems of linear equations. You begin by writing the system as an augmented matrix, then use three elementary row operations — row swapping, row scaling, and row replacement — to transform the matrix into row echelon form (REF). In REF, the pivots form a staircase pattern with zeros below each one.

Once in REF, you use back substitution to solve for each variable, starting from the bottom row and working upward. The method works for systems of any size and also reveals special cases: a row like [0 0 0 | 5] means no solution exists, while a row of all zeros indicates infinitely many solutions with free variables. Mastering Gaussian elimination is essential for advancing into topics like matrix inverses, determinants, and the broader world of linear algebra.

Varsity Tutors • Linear Algebra • Gaussian Elimination — Solving Systems by Gaussian Elimination