Calculus, Linear Algebra & Discrete Math Matrices & Linear Algebra Gauss-Jordan elimination with partial pivoting

RREF and Gauss-Jordan Elimination Calculator

Type a matrix one row per box and this calculator reduces it to reduced row echelon form, listing every elementary row operation it performs along the way. Tick the augmented box and the last column is read as the right-hand side of a linear system, so you also get the verdict — one solution, infinitely many, or none — together with the rank, the nullity that counts the free variables, the names of those free variables, and the solution itself when it is unique.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Row 1Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your system has fewer equations.2, 1, -1, 8
Row 2Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your system has fewer equations.-3, -1, 2, -11
Row 3Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your system has fewer equations.-2, 1, 2, -3
Row 4Only needed for a fourth equation. Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your system has fewer equations.
The last column is the right-hand side bTick this to treat the rows as equations; untick it to reduce a plain matrix and read off its rank.Yes

It returns

  • Rank of the coefficient matrix — The number of pivots — how many of your equations carry independent information.
  • Nullity (free variables) — Columns minus rank. Zero means at most one solution.
  • Determinant of the coefficient matrix — Shown only when the coefficient matrix is square.
  • x₁ — Shown when the solution is unique.
  • x₂
  • x₃
  • Row operations performed

The formula

rank(A)+nullity(A)=n
rank(A)=rank([A|b])=n

In plain text: rank + nullity = number of columns

  • rank(A)The number of pivots in the reduced form (—)
  • nullity(A)The number of free columns, equal to the dimension of the null space (—)
  • nThe number of columns of the coefficient matrix — the number of unknowns (—)
  • [A | b]The augmented matrix, coefficients beside the right-hand side (—)

This is the rank-nullity theorem. It is why a system with more unknowns than independent equations can never have a single solution.

Updated Category Matrices & Linear Algebra Verified against published test cases Reading time 10 min

What reduced row echelon form is

Reduced row echelon form is the simplest matrix you can reach from yours using only row operations, and it is unique: every route to it lands on the same answer. Three conditions define it. Every non-zero row starts with a leading 1, called a pivot. Each pivot sits strictly to the right of the pivot in the row above. And each pivot is the only non-zero entry anywhere in its column.

That last condition is what separates RREF from plain row echelon form. Ordinary Gaussian elimination clears only below each pivot, leaving an upper-triangular shape that still needs back-substitution. Gauss-Jordan elimination clears above as well, so the answer is readable with no further work — the price is roughly 50% more arithmetic.

The three legal row operations are exactly the ones that cannot change the solution set: swap two rows, multiply a row by a non-zero constant, and add a multiple of one row to another. Each is reversible, which is why the system you finish with has precisely the same solutions as the system you started with. Nothing is lost and nothing is gained.

How the reduced form answers the question

Once a system is in reduced form, the verdict is visible without any thinking.

No solution shows up as a row reading 0 0 0 | c with c non-zero. That row says 0 = c, which is false, so the whole system is contradictory. In rank language, the coefficient matrix has smaller rank than the augmented matrix, because the right-hand column introduced a pivot of its own.

Exactly one solution happens when every variable column contains a pivot. The reduced form then reads x₁ = something, x₂ = something, straight down the diagonal.

Infinitely many solutions happens when the system is consistent but some column has no pivot. Those are the free variables: you may set them to anything, and the pivot variables are then determined. The number of free variables is the nullity, and the solution set is a flat of that dimension — a line for nullity 1, a plane for nullity 2.

The rank-nullity theorem ties it together: rank + nullity = number of columns. So a system with more unknowns than independent equations always has free variables, and therefore never has a unique solution. Four unknowns and three equations cannot pin down a point, however the equations are arranged.

Worked example: solving 2x + y − z = 8, −3x − y + 2z = −11, −2x + y + 2z = −3

Write the augmented matrix and reduce it. Partial pivoting would start by swapping the largest first-column entry into place; done by hand it is easier to keep the order and use fractions.

  1. Start. [[2, 1, −1 | 8], [−3, −1, 2 | −11], [−2, 1, 2 | −3]].
  2. Make the first pivot 1. Divide row 1 by 2: [1, 0.5, −0.5 | 4].
  3. Clear column 1. Add 3 × row 1 to row 2: [0, 0.5, 0.5 | 1]. Add 2 × row 1 to row 3: [0, 2, 1 | 5].
  4. Make the second pivot 1. Multiply row 2 by 2: [0, 1, 1 | 2].
  5. Clear column 2. Subtract 0.5 × row 2 from row 1: [1, 0, −1 | 3]. Subtract 2 × row 2 from row 3: [0, 0, −1 | 1].
  6. Make the third pivot 1. Multiply row 3 by −1: [0, 0, 1 | −1].
  7. Clear column 3. Add row 3 to row 1: [1, 0, 0 | 2]. Subtract row 3 from row 2: [0, 1, 0 | 3].

The reduced form is [[1,0,0 | 2], [0,1,0 | 3], [0,0,1 | −1]], so x = 2, y = 3, z = −1.

Check all three original equations: 2(2) + 3 − (−1) = 4 + 3 + 1 = 8 ✓. −3(2) − 3 + 2(−1) = −6 − 3 − 2 = −11 ✓. −2(2) + 3 + 2(−1) = −4 + 3 − 2 = −3 ✓.

Every variable column got a pivot, so the rank is 3, the nullity is 3 − 3 = 0, and the solution is unique. The determinant of the coefficient matrix is −1: non-zero, which is the same fact stated another way.

What the rank is actually telling you

Rank counts genuinely independent information. If you write four equations but one is the sum of two others, the rank is 3, not 4, and the calculator says how many of your rows were redundant. That is often the most useful thing on the page: it tells you that a measurement was duplicated, or that a model is over-parameterised.

Rank is the same whether you count rows or columns. Row rank equals column rank for every matrix, which is not obvious and is one of the genuinely surprising theorems of the subject. It also means the rank can never exceed the smaller of the two dimensions.

Nullity is the dimension of the solution space of Ax = 0. A nullity of zero means the only vector A sends to zero is the zero vector, so A is injective and no two inputs collide. For a square matrix that is equivalent to having a non-zero determinant and to having an inverse.

Full rank is the healthy state. A square matrix of rank n is invertible; a tall matrix of full column rank gives a least-squares problem with a unique answer; anything less means directions that your data cannot distinguish.

What each combination of ranks means for a system

n is the number of unknowns. Every row of this table can be produced in the calculator above by editing the default system.
rank(A)rank([A|b])Relation to nSolutionsGeometry, for three unknowns
33= nExactly oneThree planes meeting at a point
22< nInfinitely many, one free variableThree planes sharing a line
11< nInfinitely many, two free variablesThree copies of the same plane
23NonePlanes meeting pairwise but with no common point
12NoneParallel distinct planes

Whenever rank([A|b]) exceeds rank(A) the system is inconsistent, regardless of how the numbers compare to n. When they are equal, the gap between rank and n counts the free variables.

Where row reduction goes wrong

  • Forgetting to tick or untick the augmented box. The same numbers mean two different things. As a plain matrix, [[1,1,2],[2,2,4]] has rank 1 in a three-column space; as a system it is one equation in two unknowns with a whole line of solutions.
  • Reading a zero row as an error. A row of all zeros in the coefficients and the right-hand side is fine — it means one equation was redundant. It is only a contradiction when the coefficients are zero and the right-hand side is not.
  • Multiplying a row by zero. Not a legal row operation. It destroys information and can turn an inconsistent system into a consistent-looking one.
  • Assuming echelon form is unique. Plain row echelon form is not — different elimination orders give different results. Reduced row echelon form is unique, which is why it is the canonical answer.
  • Trusting exact zeros in floating point. With decimal data an entry that should be zero may come out as 1e−17, which would be mistaken for a pivot. This calculator compares against a tolerance scaled to the size of your entries, and treats anything below it as zero.
  • Pivoting on a tiny entry. Dividing by a near-zero pivot amplifies every rounding error downstream. Partial pivoting — always swapping the largest available entry into the pivot position — is what prevents it, and it is what this calculator does.

Gauss-Jordan or plain Gaussian elimination?

For solving one system by hand, plain Gaussian elimination plus back-substitution is less arithmetic: about n³/3 operations against roughly n³/2 for the full Gauss-Jordan reduction. For understanding a system — reading off rank, nullity, the free variables and a basis for the null space — the reduced form is worth the extra work, because everything is visible at once with no back-substitution to get wrong. That is why this calculator goes all the way to RREF.

If your coefficient matrix is square and you only want to know whether a unique solution exists, the determinant calculator answers that in one number. For a 2×2 or 3×3 system with a non-zero determinant, Cramer's rule gives each unknown as a ratio of determinants without any elimination at all — though it becomes impractical beyond 3×3.

If you need to solve the same matrix against many different right-hand sides, factor it once with the LU decomposition calculator and reuse the factors; each additional solve then costs n² instead of n³. If you genuinely need the inverse matrix as an object, the matrix inverse calculator runs this same Gauss-Jordan procedure on [A | I].

Row reduction is also the engine behind eigenvector computation: once you have an eigenvalue λ, the eigenvectors are the null space of A − λI, found by exactly the reduction on this page. The eigenvalue and eigenvector calculator does both halves. And to verify any solution, multiply it back through the original matrix with the matrix multiplication calculator.

Frequently asked questions

What is the difference between row echelon form and reduced row echelon form?

Row echelon form only clears entries below each pivot, leaving a staircase of zeros in the lower-left and requiring back-substitution to finish. Reduced row echelon form also clears above each pivot and scales every pivot to 1, so the solution can be read straight off. Row echelon form is not unique — different elimination orders produce different results — while RREF is unique for any given matrix.

How do I know if my system has no solution?

Look for a row in the reduced form whose coefficients are all zero but whose right-hand entry is not. That row asserts 0 = c for a non-zero c, which cannot hold. Equivalently, the rank of the augmented matrix exceeds the rank of the coefficient matrix. The calculator reports both ranks and states the verdict explicitly.

What are free variables and how do I write the general solution?

A free variable is one whose column has no pivot; you may assign it any value you like. Write each free variable as a parameter, then use the pivot rows to express every pivot variable in terms of those parameters. With one free variable the solution set is a line, with two it is a plane, and the number of them is exactly the nullity that the calculator reports.

Can I use this for a system with more equations than unknowns?

Yes. Enter up to four rows with as many columns as you need. An over-determined system is usually inconsistent, and row reduction will show that immediately as a contradictory row. If it turns out to be consistent, some of your equations were redundant, and the calculator tells you how many rows were combinations of the others.

Why does the calculator swap rows when I would not have?

Partial pivoting. Before eliminating in a column it moves the entry with the largest magnitude into the pivot position. This is not cosmetic: dividing by a small pivot multiplies every subsequent rounding error by a large factor, and without pivoting a perfectly ordinary matrix can produce a badly wrong answer in floating-point arithmetic. The final reduced form is the same either way.

What does a rank of zero mean?

That every entry of the matrix is zero, or close enough to zero to be within the tolerance. There are no pivots, so the nullity equals the full number of columns and every vector is in the null space. As a system, a zero coefficient matrix with a zero right-hand side is satisfied by absolutely everything, and with a non-zero right-hand side by nothing.

Is the rank the same as the number of non-zero rows?

In the reduced form, yes — that is the easiest way to count it. In the original matrix, no: rows can look non-zero and still be combinations of others, which is exactly what elimination exposes. The default system on this page has three non-zero rows and rank 3, but changing one equation to the sum of the other two would leave three visibly non-zero rows and a rank of 2.

Can I enter fractions?

Yes, with a slash: 1/3, -5/2. This matters, because rounding 1/3 to 0.333 before entering it can change the rank of a nearly-dependent matrix. Fractions are converted to their exact decimal value where one exists and to the nearest double otherwise, which is still far better than typing a truncated decimal yourself.

References

  • Introduction to Linear Algebra, 5th ed., chapters 2 and 3 (Solving Linear Equations; Vector Spaces and Subspaces) — Gilbert Strang, Wellesley-Cambridge Press
  • Linear Algebra and Its Applications, 5th ed., §1.2 (Row Reduction and Echelon Forms) — David C. Lay, Steven R. Lay and Judi J. McDonald, Pearson
  • Matrix Computations, 4th ed., §3.4 (Pivoting) — Gene H. Golub and Charles F. Van Loan, Johns Hopkins University Press