Skip to main content
Home
Calculating...
Home Linear Systems Gaussian_Elimination

Gaussian Elimination Calculator: Solve Linear Systems Step-by-Step

Gaussian elimination (also known as row reduction) is a method for solving systems of linear equations. It transforms the system's augmented matrix into row echelon form (REF) using elementary row operations, making it easy to find solutions through back-substitution.

Calculator

Enter your matrix below and click "Calculate" to see the step-by-step solution.

Rows:
Variables:
Enter fractions like 1/2 or decimals like 0.5. The last column (b) is the constants.

Learn About Gaussian_Elimination

Understanding the concepts behind the calculations.


What is Gaussian Elimination?

Definition

Gaussian elimination (also called row reduction) is a systematic algorithm for solving systems of linear equations. Named after the mathematician Carl Friedrich Gauss, this method transforms a system into an equivalent but simpler form using elementary row operations.

The Core Idea

Any system of linear equations can be written as an augmented matrix. Instead of writing them horizontally, we stack them vertically:

$$ \begin{cases} a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n = b_1 \\\\ a_{21}x_1 + a_{22}x_2 + \cdots + a_{2n}x_n = b_2 \\\\ \vdots \\\\ a_{m1}x_1 + a_{m2}x_2 + \cdots + a_{mn}x_n = b_m \end{cases} \quad\Rightarrow\quad \left[\begin{array}{cccc|c} a_{11} & a_{12} & \cdots & a_{1n} & b_1 \\\\ a_{21} & a_{22} & \cdots & a_{2n} & b_2 \\\\ \vdots & \vdots & \ddots & \vdots & \vdots \\\\ a_{m1} & a_{m2} & \cdots & a_{mn} & b_m \end{array}\right] $$

Gaussian elimination transforms this matrix into Row Echelon Form (REF), where:

  1. All zero rows are at the bottom.
  2. The leading coefficient (pivot) of each non-zero row is strictly to the right of the pivot above it.
  3. All entries below a pivot are zero.

The Three Elementary Row Operations

These operations preserve the solution set of the system (they do not change the answers):

1. Row Swap (Interchange)

Swap any two rows: R_i ↔ R_j

When to use: When a pivot position contains zero and you need a non-zero entry from a row below.

Example:

$$ \left[\begin{array}{cc|c} 0 & 2 & 4 \\\\ 1 & 1 & 3 \end{array}\right] \xrightarrow{R_1 \leftrightarrow R_2} \left[\begin{array}{cc|c} 1 & 1 & 3 \\\\ 0 & 2 & 4 \end{array}\right] $$

2. Row Scaling (Multiplication)

Multiply a row by a non-zero constant k: R_i ← k · R_i, k ≠ 0

When to use: To create a pivot of 1 (makes calculation cleaner) or to simplify fractions.

Example:

$$ \left[\begin{array}{cc|c} 0 & 2 & 4 \\\\ 1 & 1 & 3 \end{array}\right] \xrightarrow{R_1 \leftarrow \frac{1}{2}R_1} \left[\begin{array}{cc|c} 0 & 1 & 2 \\\\ 1 & 1 & 3 \end{array}\right] $$

3. Row Addition (Replacement)

Add a multiple of one row to another: R_i ← R_i + k·R_j

When to use: To eliminate entries below (or above) pivots. This is the most frequently used operation.

Example:

$$ \left[\begin{array}{cc|c} 1 & 1 & 3 \\\\ 0 & 2 & 4 \end{array}\right] \xrightarrow{R_1 \leftarrow R_1 - \frac{1}{2}R_2} \left[\begin{array}{cc|c} 1 & 0 & 1 \\\\ 0 & 2 & 4 \end{array}\right] $$

Row Echelon Form vs Reduced Row Echelon Form

Row Echelon Form (REF)

Conditions:

  1. All zero rows are at the bottom.
  2. Leading coefficient (pivot) is strictly to the right of the pivot above.
  3. All entries below a pivot are zero.
$$ \left[\begin{array}{cccc|c} \boxed{2} & 1 & -1 & 0 & 8 \\\\ 0 & \boxed{1} & 2 & 3 & 5 \\\\ 0 & 0 & \boxed{3} & -1 & 2 \\\\ 0 & 0 & 0 & 0 & 0 \end{array}\right] $$

Reduced Row Echelon Form (RREF)

Additional Conditions:

  1. Each pivot is 1.
  2. All entries above and below each pivot are zero.
$$ \left[\begin{array}{cccc|c} \boxed{1} & 0 & 0 & 2 & 3 \\\\ 0 & \boxed{1} & 0 & -1 & 1 \\\\ 0 & 0 & \boxed{1} & 1 & 2 \\\\ 0 & 0 & 0 & 0 & 0 \end{array}\right] $$

Which One to Use?

Method Stops At Best For Back-substitution?
Gaussian Elimination REF Solving systems efficiently Yes (required)
Gauss-Jordan Elimination RREF Finding inverses, theoretical clarity No

Step-by-Step Algorithm

Forward Elimination (Creating REF)

  1. Start with the leftmost column.
  2. Find a pivot (non-zero entry) in this column. If the current row has a zero, swap with a row below that has a non-zero entry.
  3. Eliminate all entries below the pivot using row addition (Rᵢ ← Rᵢ - k·Rₚᵢᵥₒₜ).
  4. Move to the next row and next column. Repeat until no more rows or columns remain.

Back-Substitution (Solving from REF)

  1. Start from the last non-zero row.
  2. Solve for the pivot variable.
  3. Substitute this value into the row above.
  4. Repeat upwards until all variables are found.

Types of Solutions

1. Unique Solution (Consistent, Full Rank)

Characteristics: Number of pivots = number of variables. No free variables. Exactly one solution exists.

$$ \left[\begin{array}{ccc|c} \boxed{1} & * & * & * \\\\ 0 & \boxed{1} & * & * \\\\ 0 & 0 & \boxed{1} & * \end{array}\right] $$

2. No Solution (Inconsistent)

Characteristics: A row of the form [0 0 ... 0 | c] where c ≠ 0. This represents the impossible equation 0 = c.

$$ \left[\begin{array}{ccc|c} \boxed{1} & * & * & * \\\\ 0 & \boxed{1} & * & * \\\\ 0 & 0 & 0 & \boxed{5} \end{array}\right] $$

Last row implies 0 = 5, which is impossible.

3. Infinite Solutions (Underdetermined)

Characteristics: Number of pivots < number of variables. Free variables exist (columns without pivots).

$$ \left[\begin{array}{cccc|c} \boxed{1} & * & * & * & * \\\\ 0 & \boxed{1} & * & * & * \\\\ 0 & 0 & 0 & 0 & 0 \end{array}\right] $$

Variables corresponding to columns 3 and 4 are free.


Solving Systems: Complete Examples

Example 1: 2×2 System (Unique Solution)

System:

$$ \begin{cases} 2x + 3y = 8 \\\\ 4x - y = 2 \end{cases} $$

Step 1: Augmented Matrix

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

Step 2: Eliminate below pivot (Col 1)
R₂ ← R₂ - 2R₁

$$ \left[\begin{array}{cc|c} 2 & 3 & 8 \\\\ 0 & -7 & -14 \end{array}\right] $$

Step 3: Back-Substitution

  • From Row 2: -7y = -14 → y = 2
  • From Row 1: 2x + 3(2) = 8 → 2x = 2 → x = 1
Solution: x = 1, y = 2

Example 2: 2×2 System (No Solution)

System:

$$ \begin{cases} x + 2y = 5 \\\\ 2x + 4y = 9 \end{cases} $$

Step 1: Augmented Matrix

$$ \left[\begin{array}{cc|c} 1 & 2 & 5 \\\\ 2 & 4 & 9 \end{array}\right] $$

Step 2: Eliminate
R₂ ← R₂ - 2R₁

$$ \left[\begin{array}{cc|c} 1 & 2 & 5 \\\\ 0 & 0 & -1 \end{array}\right] $$
Conclusion: Row 2 implies 0 = -1, which is a contradiction. No solution.

Example 3: 3×3 System (Unique Solution)

System:

$$ \begin{cases} x + y + z = 6 \\\\ 2x - y + z = 3 \\\\ x + 2y - z = 3 \end{cases} $$

Step 1: Augmented Matrix

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

Step 2: Eliminate Column 1
R₂ ← R₂ - 2R₁ and R₃ ← R₃ - R₁

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

Step 3: Eliminate Column 2
R₃ ← R₃ + (1/3)R₂

$$ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\\\ 0 & -3 & -1 & -9 \\\\ 0 & 0 & -\frac{7}{3} & -6 \end{array}\right] $$

Step 4: Back-Substitution

  • z = -6 / (-7/3) = 18/7
  • -3y - 18/7 = -9 → y = 15/7
  • x + 15/7 + 18/7 = 6 → x = 9/7
Solution: x = 9/7, y = 15/7, z = 18/7

Example 4: 3×4 System (Infinite Solutions)

System:

$$ \begin{cases} x + y + z + w = 4 \\\\ x + 2y + 3z + 4w = 10 \\\\ x + 3y + 5z + 7w = 16 \end{cases} $$

Step 1: Augmented Matrix

$$ \left[\begin{array}{cccc|c} 1 & 1 & 1 & 1 & 4 \\\\ 1 & 2 & 3 & 4 & 10 \\\\ 1 & 3 & 5 & 7 & 16 \end{array}\right] $$

Step 2: Eliminate Column 1 & 2

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

Step 3: Interpret

  • Pivots in Column 1 (x) and Column 2 (y).
  • Free variables: z and w. Let z = s, w = t.
$$ \begin{cases} y = 6 - 2s - 3t \\\\ x = -2 + s + 2t \end{cases} $$

Special Cases and Edge Conditions

Case 1: Zero Pivot

If the pivot position is 0, you must swap rows with a row below that has a non-zero entry in that column. If no such row exists, move to the next column (this creates a free variable).

Case 2: Singular Matrix

A square matrix is singular if its determinant is 0. During elimination, this manifests as a row of zeros in the coefficient matrix.

  • If the augmented part is also 0: Infinite solutions
  • If the augmented part is non-zero: No solution

Case 3: Ill-Conditioned Systems

Small changes in input lead to large changes in output.

Example:

$$ \begin{cases} x + y = 2 \\\\ x + 1.00001y = 2.00001 \end{cases} $$

This system is sensitive to rounding errors. Using exact fractions (as our calculator does) avoids this issue.


Real-World Applications

🔧 Engineering: Structural Analysis

Calculating forces in truss bridges. Each joint creates equilibrium equations (∑F_x = 0, ∑F_y = 0), forming a large linear system solved by elimination.

⚡ Electrical Engineering: Circuit Analysis

Using Kirchhoff's Laws (KVL/KCL) to find currents in complex circuits. Each loop or node generates a linear equation.

📊 Statistics: Linear Regression

Finding the best-fit line y = mx + b involves solving the "Normal Equations," which are derived using linear algebra techniques rooted in elimination.

💰 Economics: Input-Output Models

The Leontief Input-Output model uses linear systems to predict how changes in demand for one industry affect production levels in all other industries.

🔬 Chemistry: Balancing Equations

Balancing chemical reactions (e.g., C₂H₆ + O₂ → CO₂ + H₂O) is essentially solving a homogeneous linear system for the stoichiometric coefficients.


Computational Complexity

Matrix Size (n × n) Approximate Operations
2×2~8
3×3~30
10×10~720
100×100~666,000
n × n≈ (2/3)n³

Note: Gaussian elimination is O(n³). For very large systems (n > 10,000), iterative methods are preferred. Our calculator handles up to 6×6 instantly with exact arithmetic.


Common Mistakes to Avoid

  1. Forgetting the Augmented Column: Always carry the right-hand side values through every row operation.
  2. Sign Errors: Be careful when subtracting rows. R₂ - 3R₁ means subtracting every element.
  3. Dividing by Zero: Never scale a row by 0.
  4. Stopping Early: Ensure all entries below the pivot are zero before moving to the next column.
  5. Misidentifying Free Variables: Only columns without pivots correspond to free variables.

Frequently Asked Questions

Q: What is the difference between Gaussian and Gauss-Jordan elimination?

A: Gaussian elimination stops at Row Echelon Form (REF) and requires back-substitution. Gauss-Jordan continues to Reduced Row Echelon Form (RREF), where the solution is visible directly without back-substitution.

Q: Can I use Gaussian elimination for non-square matrices?

A: Yes! It works for any m × n system. It will determine if the system is consistent and identify free variables if n > m.

Q: What is a pivot?

A: The first non-zero entry in a row after elimination. Pivots determine the rank of the matrix and the basic variables.

Q: Why do we need row swaps?

A: To avoid dividing by zero. If a pivot position is 0, we swap with a row below that has a non-zero entry. This is called pivoting.

Q: How do I know if a system has infinite solutions?

A: If you get a row of all zeros (0 = 0) AND there are fewer pivots than variables, the system has infinite solutions.


Practice Problems

Beginner

  1. Solve:

    $$ \begin{cases} 2x + y = 5 \\\\ x - y = 1 \end{cases} $$
  2. Determine if consistent:

    $$ \begin{cases} x + 2y = 3 \\\\ 2x + 4y = 7 \end{cases} $$

Intermediate

  1. Solve:

    $$ \begin{cases} x + 2y - z = 4 \\\\ 2x - y + 3z = 7 \\\\ -x + y + 2z = 3 \end{cases} $$
  2. Find the general solution:

    $$ \begin{cases} x + y + z = 3 \\\\ 2x + 2y + 2z = 6 \end{cases} $$

Advanced

  1. For what value of k does this system have no solution?

    $$ \begin{cases} x + 2y = 3 \\\\ 2x + ky = 6 \end{cases} $$
Click to reveal solutions

1. x = 2, y = 1

2. No solution (Row 2 becomes 0 = 1)

3. x = 1, y = 2, z = 1

4. x = 3 - t, y = t, z = 0 (t free)

5. k = 4


Summary

Key Takeaways

  • Goal: Transform augmented matrix to Row Echelon Form (REF).
  • Operations: Swap, Scale, Add rows.
  • Unique Solution: n pivots for n variables.
  • No Solution: Row like [0 ... 0 | c] with c ≠ 0.
  • Infinite Solutions: Fewer pivots than variables (free variables exist).

When to Use This Calculator

  • ✅ Solving small to medium systems (up to 6×6).
  • ✅ Learning the step-by-step algorithm.
  • ✅ Checking homework with exact fraction arithmetic.
  • ❌ Very large systems (>1000 variables) → Use numerical software.


Try It Yourself!

Use the calculator above to master Gaussian elimination:

  1. Enter your system as an augmented matrix.
  2. Click "Calculate" to see complete step-by-step elimination.
  3. Study each operation to understand how the matrix transforms.

Test these systems:

  • Unique: 2x + y = 5, x - y = 1
  • No Solution: x + y = 2, x + y = 3
  • Infinite: x + y = 2, 2x + 2y = 4

Pro Tip: Use fractions (e.g., 1/2) for exact arithmetic. Avoid decimals to prevent rounding errors!