MatrixCalc

RREF calculator — row echelon form and rank

Row-reduce any matrix to reduced row echelon form and see every elementary row operation, written as R2 → R2 − 3·R1. Solves linear systems and gives the rank.

Matrix A
rows: 3
cols: 3
Matrix B
rows: 3
cols: 3
Operations

Open the steps below to see the full answer.

Result
Pick an operation to see the result here. Errors will show up in this area.

Tips: adjust sizes (max 50×50). For A×B, cols(A)=rows(B). det/inverse/trace/power require square matrices.

React, Tailwind & shadcn/ui. No external math deps. — English

Enter your matrix, open the Decompositions tab and press RREF(A). The steps panel opens automatically and lists every operation in standard notation, so you can copy the working straight into your homework and check where your own attempt diverged. Press Row echelon(A) for plain Gaussian elimination instead, or rank(A) for the rank — all three come out of the same algorithm, explained below.

The three elementary row operations

Elimination is the single most useful algorithm in linear algebra. Rank, determinant, inverse and the solution of a linear system all fall out of it. It rests on three operations, none of which changes the solution set of the underlying system:

  1. Swap two rows: R(i) ↔ R(j)
  2. Multiply a row by a non-zero scalar: R(i) → k·R(i)
  3. Add a multiple of one row to another: R(i) → R(i) + k·R(j)

Multiplying a row by zero is not on the list, and is not legal: it destroys an equation rather than rewriting it.

Row echelon form

A matrix is in row echelon form (REF) when:

  • all-zero rows sit at the bottom;
  • each leading non-zero entry (the pivot) is strictly to the right of the pivot above it;
  • everything below a pivot is zero.
21−1
032
005

Reduced row echelon form

RREF goes further: every pivot equals 1 and is the only non-zero entry in its column. Crucially, every matrix has exactly one RREF — the answer does not depend on the order you did the operations in. That uniqueness is what makes it a reliable thing to compare your own working against.

The algorithm, step by step

  1. Start at the top-left. Find the largest entry in the current column — this is partial pivoting, and it keeps rounding errors small.
  2. If the whole column is zero, move one column right and try again.
  3. Swap that row up into pivot position.
  4. Divide the pivot row by the pivot so the pivot becomes 1.
  5. Subtract multiples of the pivot row from every other row to zero out the rest of the column.
  6. Move down one row and right one column, and repeat.

Applying step 5 only to rows below the pivot gives Gaussian elimination and row echelon form. Clearing the rows above as well gives Gauss-Jordan and the reduced form. Gauss-Jordan does more arithmetic; in exchange the solution can be read off without back substitution.

Worked example

121
243
365
120
001
000

The second column never gets a pivot, so its variable is free — and the zero row confirms the third equation carried no new information. Reading the form back: the rank is 2, and a system with this coefficient matrix has infinitely many solutions with one free parameter.

Solving a linear system

Enter the system as an augmented matrix: one row per equation, one column per unknown, and a final column for the constants. Three equations in three unknowns make a 3×4 matrix. Every row operation applies to the full row, right-hand side included. Take x + 2y − z = −4, 2x + 3y − z = −11, −2x − 3z = 22:

12−1−4
23−1−11
−20−322
12−1−4
0−11−3
00−12

The last row says −z = 2, so z = −2. Substituting upward gives y = 1 and then x = −8. Reading the three possible outcomes off the reduced form:

  • Unique solution: every column of the coefficient matrix has a pivot.
  • Infinitely many: some column has no pivot — those variables are free.
  • No solution: a row reads 0 0 0 | c with c ≠ 0, which claims 0 = c.

Rank: counting what survives

The rank of a matrix is the number of linearly independent rows — equivalently, of linearly independent columns. Those two numbers are always equal, a fact important enough to have a name: the row rank equals column rank theorem. To compute it, row-reduce and count the non-zero rows. Row operations never change the rank, which is exactly why this works.

123
456
579
123
0−3−6
000
rank = 2

Here the third row is exactly the first plus the second, so it contributes nothing new and elimination drives it to zero. For an m×n matrix, rank ≤ min(m, n); a matrix hitting that bound has full rank. For a square matrix, full rank is the same as being invertible and the same as having a non-zero determinant — three phrasings of one property.

Rank is also what decides whether a system is solvable at all. The Rouché–Capelli theorem says Ax = b is consistent exactly when rank(A) = rank([A | b]); if that common rank equals the number of unknowns the solution is unique, and otherwise there are n − rank free parameters. The companion identity is rank-nullity: rank(A) + nullity(A) = n.

Common mistakes

  • Stopping at row echelon form. Zeroing only below each pivot gives REF. RREF also clears everything above.
  • Leaving a pivot different from 1. The reduced form requires dividing each pivot row by its pivot.
  • Reordering columns. Swapping rows is allowed; swapping columns changes which variable is which.
  • Missing the inconsistent row. A row reading 0 0 0 | c with c ≠ 0 means the system has no solution at all.
  • Calling a zero row unsolvable. A row of all zeros is a redundant equation, so there are infinitely many solutions. Only 0 = c with c non-zero means none.
  • Counting non-zero rows before finishing. Rows only reveal themselves as dependent once elimination is complete. Reduce fully, then count.

Frequently asked questions

What is the difference between REF and RREF?
Row echelon form only requires zeros below each pivot. Reduced row echelon form also requires zeros above each pivot and every pivot equal to 1.
What is the difference between Gaussian and Gauss-Jordan elimination?
Gaussian elimination stops at row echelon form and finishes with back substitution. Gauss-Jordan carries on to the reduced form, where the solution can be read off directly. Gauss-Jordan does more arithmetic for the same answer.
Can I use RREF to find the rank?
Yes — the rank is the number of non-zero rows in the reduced form. The calculator also has a dedicated rank button that does exactly this.
How do I enter a system of equations?
As an augmented matrix: one row per equation, one column per unknown, and a final column for the constants. A system of three equations in three unknowns is a 3×4 matrix.
What if a pivot position holds a zero?
Swap in a row below that has a non-zero entry in that column. If every row below is zero there too, that column has no pivot — its variable is free, and the system has infinitely many solutions.
Can I row-reduce a non-square matrix?
Yes. Elimination works on any shape, which is what makes it useful for augmented matrices of linear systems. Rank is defined for any shape too, capped by the smaller dimension.

Other calculators