Gaussian Elimination

Gaussian Elimination transforms a system of linear equations into row echelon form to solve for unknown variables systematically.

[Ab]row echelon form[A \mid b] \to \text{row echelon form}

Solve a problem with Gaussian Elimination

Type the problem. The solver will use Gaussian Elimination where Gaussian Elimination is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Gaussian Elimination takes
AA
bb
Gaussian Elimination
SymbolMeaning
AAThe coefficient matrix containing the numbers in front of each variable in your system of equations.
bbThe augmented column (or constant vector) containing the numbers on the right side of the equals signs in your equations.

When to use it

Use Gaussian Elimination when you need to solve a system of linear equations with multiple unknowns.

Level

Usually taught in: Linear Algebra

Worked examples

1. Solve a 2×2 system with integer solutions

Problem

Solve the system x+2y=5x + 2y = 5 and 2xy=52x - y = 5.
  1. [125215]\left[\begin{array}{cc|c} 1 & 2 & 5 \\ 2 & -1 & 5 \end{array}\right]

    Write the augmented matrix [A | b] where the columns are the coefficients of xx and yy, and the last column is the constants.

  2. R22R1[125055]R_2 - 2R_1 \to \left[\begin{array}{cc|c} 1 & 2 & 5 \\ 0 & -5 & -5 \end{array}\right]

    Eliminate the first entry in row 2 by subtracting 2R12R_1 from R2R_2.

  3. R2/(5)[125011]R_2 / (-5) \to \left[\begin{array}{cc|c} 1 & 2 & 5 \\ 0 & 1 & 1 \end{array}\right]

    Divide row 2 by 5-5 to make the leading coefficient 1.

  4. y=1y = 1

    From the second row, read off y=1y = 1.

  5. x+2(1)=5x=3x + 2(1) = 5 \Rightarrow x = 3

    Back-substitute y=1y = 1 into the first row and solve for xx.

Answer: x=3,y=1x = 3, \quad y = 1

Gaussian Elimination is the systematic way to solve this 2×2 system by eliminating variables one at a time. We first eliminated xx from the second equation, then solved for yy, and finally solved for xx using back-substitution.

2. Solve a 3×3 system requiring row swaps

Problem

Solve the system 2xy+z=82x - y + z = 8, x+2yz=3x + 2y - z = -3, and 3x+y+2z=113x + y + 2z = 11.
  1. [2118121331211]\left[\begin{array}{ccc|c} 2 & -1 & 1 & 8 \\ 1 & 2 & -1 & -3 \\ 3 & 1 & 2 & 11 \end{array}\right]

    Write the augmented matrix with three equations and three unknowns.

  2. R1R2[1213211831211]R_1 \leftrightarrow R_2 \to \left[\begin{array}{ccc|c} 1 & 2 & -1 & -3 \\ 2 & -1 & 1 & 8 \\ 3 & 1 & 2 & 11 \end{array}\right]

    Swap rows 1 and 2 so the first pivot is 1, avoiding fractions in subsequent operations.

  3. R22R1,R33R1[12130531405520]R_2 - 2R_1, R_3 - 3R_1 \to \left[\begin{array}{ccc|c} 1 & 2 & -1 & -3 \\ 0 & -5 & 3 & 14 \\ 0 & -5 & 5 & 20 \end{array}\right]

    Eliminate the first column below the pivot using R22R1R_2 - 2R_1 and R33R1R_3 - 3R_1.

  4. R3R2[1213053140026]R_3 - R_2 \to \left[\begin{array}{ccc|c} 1 & 2 & -1 & -3 \\ 0 & -5 & 3 & 14 \\ 0 & 0 & 2 & 6 \end{array}\right]

    Eliminate the second column in row 3 by subtracting R2R_2 from R3R_3; this is now in row echelon form.

  5. 2z=6z=32z = 6 \Rightarrow z = 3

    From the third row, solve for zz.

  6. 5y+3(3)=145y=5y=1-5y + 3(3) = 14 \Rightarrow -5y = 5 \Rightarrow y = -1

    Back-substitute z=3z = 3 into the second row and solve for yy.

  7. x+2(1)3=3x=2x + 2(-1) - 3 = -3 \Rightarrow x = 2

    Back-substitute y=1y = -1 and z=3z = 3 into the first row and solve for xx.

Answer: x=2,y=1,z=3x = 2, \quad y = -1, \quad z = 3

This 3×3 system needed a row swap to make the arithmetic cleaner. After eliminating below the pivots to reach row echelon form, back-substitution from the bottom row upward gives the solution.

3. Solve a word problem using a system of three equations

Problem

A person invests $10,000 across three savings accounts earning 2%, 3%, and 4% interest respectively. The amount in the second account is twice the first. After one year, the total interest earned is $310. How much was invested in each account? Let aa, bb, and cc be the amounts in accounts 1, 2, and 3.
  1. a+b+c=10000,b=2a,0.02a+0.03b+0.04c=310a + b + c = 10000, \quad b = 2a, \quad 0.02a + 0.03b + 0.04c = 310

    Write the three equations from the problem: total amount, the relationship between accounts, and total interest.

  2. 2a+b+0c=0,2a+3b+4c=31000-2a + b + 0c = 0, \quad 2a + 3b + 4c = 31000

    Rewrite the second and third equations in standard form; multiply the interest equation by 100 to eliminate decimals.

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

    Write the augmented matrix with the three rewritten equations.

  4. R2+2R1,R32R1[111100000322000001211000]R_2 + 2R_1, R_3 - 2R_1 \to \left[\begin{array}{ccc|c} 1 & 1 & 1 & 10000 \\ 0 & 3 & 2 & 20000 \\ 0 & 1 & 2 & 11000 \end{array}\right]

    Eliminate the first column below the pivot.

  5. R2R3[111100000121100003220000]R_2 \leftrightarrow R_3 \to \left[\begin{array}{ccc|c} 1 & 1 & 1 & 10000 \\ 0 & 1 & 2 & 11000 \\ 0 & 3 & 2 & 20000 \end{array}\right]

    Swap rows 2 and 3 to make the second pivot 1 and keep arithmetic simple.

  6. R33R2[111100000121100000413000]R_3 - 3R_2 \to \left[\begin{array}{ccc|c} 1 & 1 & 1 & 10000 \\ 0 & 1 & 2 & 11000 \\ 0 & 0 & -4 & -13000 \end{array}\right]

    Eliminate the second column in row 3 to reach row echelon form.

  7. 4c=13000c=3250-4c = -13000 \Rightarrow c = 3250

    From the third row, solve for cc (amount in account 3).

  8. b+2(3250)=11000b=4500b + 2(3250) = 11000 \Rightarrow b = 4500

    Back-substitute c=3250c = 3250 into row 2 to find bb (amount in account 2).

  9. a+4500+3250=10000a=2250a + 4500 + 3250 = 10000 \Rightarrow a = 2250

    Back-substitute into row 1 to find aa (amount in account 1).

Answer: a=2250,b=4500,c=3250a = 2250, \quad b = 4500, \quad c = 3250

This real-world problem translates to a system of three equations with three unknowns. Gaussian Elimination systematically eliminates variables to reach a form where back-substitution reveals how much was invested in each account.

Common mistakes

Where Gaussian Elimination usually goes wrong
Answer came out wrong
When performing R23R1R_2 - 3R_1 on the matrix [125314]\begin{bmatrix} 1 & 2 & | & 5 \\ 3 & -1 & | & 4 \end{bmatrix}, a student writes [125074]\begin{bmatrix} 1 & 2 & | & 5 \\ 0 & -7 & | & 4 \end{bmatrix} instead of [1250711]\begin{bmatrix} 1 & 2 & | & 5 \\ 0 & -7 & | & -11 \end{bmatrix}.
Always apply the row operation to the entire row: when performing R23R1R_2 - 3R_1, compute [3,1,,4]3[1,2,,5]=[0,7,,11][3, -1, |, 4] - 3[1, 2, |, 5] = [0, -7, |, -11].
When eliminating the first column, a student wants to eliminate the leading 3 in row 2 using row 1 as a pivot, but performs R22R1R_2 - 2R_1 instead of R23R1R_2 - 3R_1, resulting in [1,4,,10][1, 4, |, 10] instead of [0,2,,1][0, -2, |, 1].
Before performing a row elimination, calculate the multiplier: if row 2 has a leading 3 and row 1 has a leading 1, the multiplier must be 3/1=33 / 1 = 3, so perform R23R1R_2 - 3R_1.
A student reaches the matrix [113000]\begin{bmatrix} 1 & 1 & | & 3 \\ 0 & 0 & | & 0 \end{bmatrix} but treats it as having a unique solution and tries to solve for both variables.
When you get a row of the form [0,0,,0,,0][0, 0, \ldots, 0, |, 0], stop elimination and recognize that the system has infinitely many solutions; a row like [0,0,,c][0, 0, |, c] with c0c \ne 0 means no solution exists.
The mistakeWhy it is wrongThe fix
When performing R23R1R_2 - 3R_1 on the matrix [125314]\begin{bmatrix} 1 & 2 & | & 5 \\ 3 & -1 & | & 4 \end{bmatrix}, a student writes [125074]\begin{bmatrix} 1 & 2 & | & 5 \\ 0 & -7 & | & 4 \end{bmatrix} instead of [1250711]\begin{bmatrix} 1 & 2 & | & 5 \\ 0 & -7 & | & -11 \end{bmatrix}.The row operation must be applied to every entry in the row, including the augmented column; the correct computation is 43(5)=114 - 3(5) = -11, not 4.Always apply the row operation to the entire row: when performing R23R1R_2 - 3R_1, compute [3,1,,4]3[1,2,,5]=[0,7,,11][3, -1, |, 4] - 3[1, 2, |, 5] = [0, -7, |, -11].
When eliminating the first column, a student wants to eliminate the leading 3 in row 2 using row 1 as a pivot, but performs R22R1R_2 - 2R_1 instead of R23R1R_2 - 3R_1, resulting in [1,4,,10][1, 4, |, 10] instead of [0,2,,1][0, -2, |, 1].Using the wrong multiplier means the leading entry in row 2 does not actually become zero; only when the multiplier equals the ratio of the entries being eliminated does the first entry vanish.Before performing a row elimination, calculate the multiplier: if row 2 has a leading 3 and row 1 has a leading 1, the multiplier must be 3/1=33 / 1 = 3, so perform R23R1R_2 - 3R_1.
A student reaches the matrix [113000]\begin{bmatrix} 1 & 1 & | & 3 \\ 0 & 0 & | & 0 \end{bmatrix} but treats it as having a unique solution and tries to solve for both variables.A row of all zeros [0,0,,0][0, 0, |, 0] represents a redundant equation and means the system has infinitely many solutions (a free variable), not a unique solution.When you get a row of the form [0,0,,0,,0][0, 0, \ldots, 0, |, 0], stop elimination and recognize that the system has infinitely many solutions; a row like [0,0,,c][0, 0, |, c] with c0c \ne 0 means no solution exists.

Tips and when to use something else

  • Write down each row operation (like R23R1R_2 - 3R_1) as you work to stay organized and avoid confusion about which row you are modifying.
  • Stop as soon as you reach row echelon form if you only need to determine whether a solution exists; you don't need to reduce further to answer existence and uniqueness questions.
  • For small 2×2 or 3×3 systems with small integer coefficients, Cramer's Rule might be faster; Gaussian Elimination truly shines for larger systems where it is more efficient than other hand methods.
  • Always verify your final answer by substituting back into the original equations—arithmetic errors during elimination are easy to hide until you check.

Frequently asked questions

When should I use Gaussian Elimination instead of Cramer's Rule?
Use Gaussian Elimination when you have a large system (four or more equations) or when the system might not have a unique solution. Cramer's Rule works only when a unique solution exists and becomes slow for large systems. For 2×2 and 3×3 systems, either method works, but Gaussian Elimination is more versatile because it handles inconsistent (no solution) and dependent (infinitely many solutions) systems.
What does a row of zeros mean in the matrix?
A row of the form [0,0,,00][0, 0, \ldots, 0 | 0] (all zeros including the augmented part) is a redundant equation and indicates infinitely many solutions. A row like [0,0,,5][0, 0, |, 5] (zeros in the coefficients but nonzero on the right) represents an impossible equation like 0=50 = 5, so the system has no solution.
Can I swap rows during Gaussian Elimination?
Yes, swapping rows (an elementary row operation) is allowed and often useful. Swapping can help you avoid fractions: if the current pivot is a fraction and a row below has an integer coefficient in that column, swap to make arithmetic cleaner.
Do I have to stop at row echelon form, or can I continue?
You can continue to reduced row echelon form (RREF), where each pivot is 1 and all other entries in that column are zero. RREF requires extra work but lets you read the solution directly without back-substitution; choose based on which is faster for your system.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18