Gaussian Elimination Calculator

Reducing a System Row by Row

Gaussian elimination solves linear systems the way most people first learn to by hand — systematically combining equations to eliminate variables one at a time — but does it with matrix rows and partial pivoting for numerical stability. Forward elimination reduces the augmented matrix to a triangular form; back substitution then unwinds it into the final answer.

The Method

Forward elimination: use each pivot row to zero out the entries below it
Back substitution: solve the last variable first, then substitute upward

Partial pivoting swaps in the row with the largest available value in each column before eliminating, which keeps the arithmetic numerically stable and avoids dividing by a small or zero pivot.

Worked Example

Solving 2x + 3y = 8 and x − 2y = −3 — the same system as the Cramer's rule example, for comparison:

Gaussian elimination result
VariableValue
x1
y2

Gaussian elimination and Cramer's rule always agree on a unique solution — they're two different routes to the same answer.

Where This Matters

  • Larger linear systems — elimination scales far better than Cramer's rule as the number of equations grows, which is why it's the standard method in numerical software.
  • Engineering simulations — finite element and circuit solvers reduce their underlying equations with this same row-elimination approach.
  • Balancing chemical equations — systems of linear equations describing atom balance can be solved this way.

How to Use This Calculator

  1. Choose the system size: 2 Equations, 2 Unknowns or 3 Equations, 3 Unknowns.
  2. Enter each equation's coefficients and constant term.
  3. Select Calculate to see the row-reduction steps and the final solved values.

Related Calculations

Compare against the determinant-based Cramer's Rule Calculator, or invert the coefficient matrix directly with the Matrix Inverse Calculator.

Principles of Gaussian Elimination and Matrix Row Reduction

Named in honor of Carl Friedrich Gauss, Gaussian Elimination is the fundamental numerical linear algebra algorithm used to solve systems of linear equations, compute matrix inverses, and determine matrix rank. The algorithm systematically applies elementary row operations to transform an augmented matrix [A | b] into an equivalent upper-triangular Row Echelon Form (REF), from which solutions are computed via backward substitution.

The Three Elementary Row Operations

Elementary row operations preserve the exact solution set of the linear system:

  • 1. Row Swapping (Ri ↔ Rj): Interchanging the positions of two rows.
  • 2. Row Scaling (Ri → c × Ri, c ≠ 0): Multiplying all entries in a row by a non-zero scalar constant.
  • 3. Row Addition (Ri → Ri + k × Rj): Adding a scalar multiple of one row to another row.

Gauss-Jordan Elimination and Reduced Row Echelon Form (RREF)

Extending Gaussian elimination by eliminating entries both below AND above every pivot produces the Reduced Row Echelon Form (RREF):

  • The leading non-zero entry (pivot) in every non-zero row is exactly 1.
  • Each leading 1 is the only non-zero entry in its entire column.
  • Lower rows have pivots positioned strictly to the right of upper row pivots.

Step-by-Step Worked Calculation Example

Example: Solving a 3x3 System via Gaussian Elimination

Problem: Solve the 3-variable linear system:

(1) 2x + y - z = 8

(2) -3x - y + 2z = -11

(3) -2x + y + 2z = -3

Step 1: Set up the Augmented Matrix [A | b]:

[ [ 2, 1, -1 | 8 ],
 [-3, -1, 2 | -11 ],
 [-2, 1, 2 | -3 ] ]

Step 2: Eliminate x-column below Row 1:

R2 → R2 + 1.5 × R1  &implies;  [ 0, 0.5, 0.5 | 1 ]

R3 → R3 + 1.0 × R1  &implies;  [ 0, 2.0, 1.0 | 5 ]

Step 3: Eliminate y-column below Row 2:

R3 → R3 - 4.0 × R2  &implies;  [ 0, 0, -1.0 | 1 ]

Upper Triangular Row Echelon Form (REF):
[ [ 2, 1, -1 | 8 ],
  [ 0, 0.5, 0.5 | 1 ],
  [ 0, 0, -1.0 | 1 ] ]

Step 4: Back-Substitution:

From Row 3: -1.0 × z = 1  &implies;  z = -1

From Row 2: 0.5y + 0.5(-1) = 1  &implies;  0.5y = 1.5  &implies;  y = 3

From Row 1: 2x + (3) - (-1) = 8  &implies;  2x + 4 = 8  &implies;  x = 2

Conclusion: The unique solution is x = 2, y = 3, z = -1.

Partial Pivoting for Numerical Stability

In computer floating-point calculations, division by near-zero pivots causes extreme rounding error magnification. Algorithms implement Partial Pivoting: searching the active column for the element with largest absolute magnitude and swapping rows before elimination.

The LU Matrix Decomposition (Factorization)

In computational scientific computing, Gaussian elimination is formally executed as an LU Decomposition: factoring square coefficient matrix A into the product of a unit Lower-Triangular Matrix (L) and an Upper-Triangular Matrix (U):

P × A = L × U

Where P is a row permutation matrix generated by partial pivoting. Once matrix A is factored into L and U (requiring 2n³/3 floating-point operations):

  • Step 1: Solve L × y = P × b using forward substitution (requiring O(n²) operations).
  • Step 2: Solve U × x = y using backward substitution (requiring O(n²) operations).

For engineering problems requiring solutions across hundreds of different load vectors b (such as dynamic structural vibrations), LU decomposition solves subsequent load cases in O(n²) time without repeating the expensive O(n³) elimination phase.

Matrix Rank and Consistency Testing

Gaussian elimination determines the formal Rank of matrix A (the number of non-zero pivot rows in its Row Echelon Form). Under the Rouché-Capelli Theorem, the system A × x = b is consistent (has at least one solution) if and only if: Rank(A) = Rank([A | b]).

Gauss-Jordan Inversion Algorithm: [A | I] → [I | A-1]

Gaussian elimination provides a universal numerical method for inverting an n×n matrix A. By constructing the augmented block matrix [ A | In ] (where In is the n×n identity matrix) and applying elementary row operations until the left block reaches Reduced Row Echelon Form (In), the right block simultaneously transforms into the exact matrix inverse:

[ A | In ]  ⟶Row Operations  [ In | A-1 ]

If at any stage a full row of zeros appears in the left block, the matrix is singular and cannot be inverted.

Computational FLOP Count Analysis

Forward Gaussian elimination requires approximately 2n³ / 3 floating-point operations (FLOPs), while back-substitution requires n² FLOPs, demonstrating superior computational scalability over determinant-based methods.

Cholesky Decomposition for Symmetric Positive-Definite Systems

When coefficient matrix A is symmetric and positive-definite (A = AT and xTAx > 0, common in civil structural stiffness and financial portfolio covariance matrices), Gaussian elimination specializes into the Cholesky Decomposition: A = L × LT. Cholesky factorization requires half the memory and half the floating-point operations (n³/3 FLOPs) of standard LU decomposition with guaranteed numerical stability without pivoting.

Sparse Matrix Solvers and Skyline Storage

For massive structural finite element models with millions of nodes, Gaussian elimination algorithms utilize sparse compressed row (CSR) storage and fill-in reducing reordering (such as Reverse Cuthill-McKee) to preserve zero entries and accelerate factorization.