Matrix Calculator
Multiply, add and subtract matrices up to 6 × 6, plus determinant, inverse, transpose and powers, exactly.
This RREF calculator row-reduces any matrix up to 6 × 7 to reduced row echelon form by Gauss–Jordan elimination, or to row echelon form (REF), in exact fractions with every row operation shown.
Reduced row echelon form
[[1, 0, 0, 1], [0, 1, 0, 2], [0, 0, 1, 3]]
The system is consistent and every unknown has a pivot, so it has exactly one solution: x₁ = 1, x₂ = 2, x₃ = 3.
The unknowns are named x₁, x₂, x₃ in column order.
Write the augmented matrix [A | b]
Each row is one equation. The columns left of the bar hold the coefficients of the unknowns; the last column holds the constants.
R2 → R2 − 2R1
Subtract 2 times row 1 from row 2 to make the entry in column 1 zero.
R3 → R3 − 3R1
Subtract 3 times row 1 from row 3 to make the entry in column 1 zero.
R2 → −R2
Multiply row 2 by −1 so that the pivot in column 2 becomes 1.
R1 → R1 − 2R2
Subtract 2 times row 2 from row 1 to make the entry in column 2 zero.
R3 → R3 + 7R2
Add 7 times row 2 to row 3 to make the entry in column 2 zero.
R3 → −(1/16)R3
Multiply row 3 by −1/16 so that the pivot in column 3 becomes 1.
R1 → R1 − 5R3
Subtract 5 times row 3 from row 1 to make the entry in column 3 zero.
R2 → R2 + 3R3
Add 3 times row 3 to row 2 to make the entry in column 3 zero.
Read off the solution
The left part of the matrix is now the identity (plus any zero rows), so each row gives one unknown directly.
It also gives the rank, pivot columns and null space, and for an augmented matrix whether the system has one solution, none or infinitely many.
Reduced row echelon form
Plain-text formula: [1, 0, ∗, 0; 0, 1, ∗, 0; 0, 0, 0, 1]
The shape every RREF has: a staircase of pivots equal to 1, zeros above and below each pivot, and any zero rows at the bottom. The four rules are spelled out below.
Rank–nullity theorem
Plain-text formula: rank(A) + nullity(A) = n
For a matrix with n columns, the number of pivot columns plus the number of free columns is n. The nullity is the number of free variables in A·x = 0.
When does a system have solutions?
Plain-text formula: rank(A) = rank([A∣b])
A system is consistent exactly when the constants column is not a pivot column. Then it has one solution if rank(A) equals the number of unknowns, and infinitely many if it is smaller (the Rouché–Capelli theorem).
Each pivot marks a basic variable and each column without a pivot marks a free variable. In a system, the free variables can take any value, and the RREF rows give the basic variables in terms of them. That is why the general solution is written as a particular solution plus combinations of null space vectors.
A row of zeros on the left with a nonzero constant on the right, such as , means the equations contradict each other: no solution. A zero row with a zero constant just means one equation was a combination of the others.
The rank is the number of independent rows (equal to the number of independent columns). A square matrix is invertible exactly when its RREF is the identity matrix, which you can confirm with the inverse matrix calculator.
Reduced row echelon form is the simplest matrix you can reach from a given matrix with row operations. A matrix is in RREF when it meets four rules: any rows of zeros are at the bottom; the first nonzero entry of every other row is 1, called a pivot or leading 1; each pivot is to the right of the pivot in the row above; and each pivot is the only nonzero entry in its column.
For example, is in RREF, but is not, because the 4 sits above the pivot in column 2. Every matrix has exactly one RREF, so it is a reliable way to compare answers, read off the rank and solve a system in one pass. That unique matrix is what this reduced row echelon form calculator returns by default.
Row echelon form (REF) only asks for the staircase shape: zeros below each pivot. Reduced row echelon form also clears the entries above each pivot and makes every pivot 1. Gaussian elimination stops at REF and finishes with back substitution; Gauss–Jordan elimination keeps going to RREF so the answer can be read directly. Choose REF above and the page works as a row echelon form calculator: it runs Gaussian elimination and stops once every pivot has zeros below it.
For the system in the worked example below, the REF is . Back substitution gives , then , then : the same solution the RREF shows at once.
| Rule | REF | RREF |
|---|---|---|
| Rows of zeros are at the bottom | Required | Required |
| Each pivot is to the right of the pivot above it | Required | Required |
| Entries below each pivot are 0 | Required | Required |
| Each pivot equals 1 | Optional (often used) | Required |
| Entries above each pivot are 0 | Not required | Required |
| Unique for a given matrix | No | Yes |
| Method that produces it | Gaussian elimination | Gauss–Jordan elimination |
Row reduction uses only three operations, and none of them changes the solutions of the system or the rank of the matrix. The table lists them with the notation the calculator uses in its steps.
Work one column at a time, left to right. (1) Find the leftmost column that has a nonzero entry at or below the current row; swap rows if needed to bring it into the pivot position. (2) Divide that row by the pivot so the pivot becomes 1. (3) Subtract multiples of the pivot row to make every other entry in the column 0: only the entries below for REF, above and below for RREF. (4) Move down one row and right to the next column, and repeat until you run out of rows or columns.
Doing this by hand, fractions appear quickly. The calculator keeps them exact, so you can compare each of its steps with your own working line by line. Each row operation is the same as multiplying on the left by an elementary matrix, which you can confirm with the matrix calculator.
| Operation | Notation | Example |
|---|---|---|
| Swap two rows | Ri ↔ Rj | R1 ↔ R2 brings a nonzero pivot to the top |
| Multiply a row by a nonzero number | Ri → kRi | R2 → −R2 turns a pivot of −1 into 1 |
| Add a multiple of one row to another | Ri → Ri + kRj | R3 → R3 − 3R1 clears column 1 of row 3 |
To solve a system, put the coefficients and constants in an augmented matrix and row reduce it. The last nonzero rows of the RREF tell you which of the three cases you are in, as the table shows. The examples above load one of each.
For x₁ + 2x₂ + x₃ = 4, 2x₁ + 4x₂ + 3x₃ = 11 and x₁ + 2x₂ = 1 (the Infinitely many solutions example), the RREF is . Column 2 has no pivot, so x₂ is free: , , and every value of x₂ gives a solution.
If you would rather type the equations themselves, such as 2x − y = 3, the system of equations calculator builds the augmented matrix for you.
| What the RREF shows | Ranks | Solutions |
|---|---|---|
| A row [0 0 … 0 | c] with c ≠ 0 | rank A < rank [A | b] | None: the system is inconsistent |
| A pivot in every coefficient column | rank A = rank [A | b] = number of unknowns | Exactly one |
| A coefficient column without a pivot, and no 0 = c row | rank A = rank [A | b] < number of unknowns | Infinitely many, one free variable per non-pivot column |
Untick the system box to analyze a matrix on its own. The rank is the number of pivots, the pivot columns of the original matrix form a basis for its column space, and each free column gives one vector of the null space: set that free variable to 1, the others to 0, and solve from the RREF.
For the Rank of a 4 × 5 matrix example the RREF is . The pivots are in columns 1 and 3, so the rank is 2 and the nullity is 5 − 2 = 3, with null space basis (−2, 1, 0, 0, 0), (−1, 0, −1, 1, 0) and (−3, 0, −1, 0, 1). For a square matrix, the determinant calculator gives the same verdict: full rank exactly when det A ≠ 0.
TI-84 Plus: press 2nd then x⁻¹ to open MATRIX, go to EDIT, choose [A], set the size and type the entries. On the home screen press 2nd, x⁻¹, go to MATH and choose rref(, then press 2nd, x⁻¹, choose [A] under NAMES, close the bracket and press ENTER. The same MATH menu has ref( for row echelon form. To see fractions, press MATH and choose ►Frac before ENTER.
Desmos: open the Desmos Matrix Calculator, create a matrix with New Matrix, type the entries, then press rref with the matrix name, for example rref(A).
Both show only the final matrix. Use this page to see the row operations that lead to it, the rank and the solution of the system.
Solve x + 2y − z = 2, 2x + 3y + z = 11 and 3x − y + 2z = 7 (augmented matrix rows 1, 2, −1, 2 / 2, 3, 1, 11 / 3, −1, 2, 7).
Answer: Exactly one solution: x = 1, y = 2, z = 3 (shown as x₁, x₂, x₃). Both the coefficient matrix and the augmented matrix have rank 3. This is the calculator's default input, so its steps match the ones above.
Row echelon form (REF) only needs zeros below each pivot, and the pivots need not be 1. Reduced row echelon form (RREF) also needs each pivot to be 1 with zeros above it. A matrix has many echelon forms but only one RREF.
Yes. Different sequences of valid row operations can pass through different intermediate matrices, but they always end at the same reduced row echelon form. The row echelon form is not unique.
Move all variables to the left and constants to the right, then write one row per equation with the coefficients in a fixed variable order and the constant last. Use 0 for a missing variable, then tick the augmented-matrix box.
Look at the RREF of the augmented matrix. A row that reads 0 = c with c not 0 means no solution. Otherwise, a coefficient column without a pivot means a free variable and infinitely many solutions; a pivot in every coefficient column means exactly one.
A free variable has no pivot in its column, so it can be any number. For example, x₁ + 2x₂ + x₃ = 4 together with x₃ = 3 leaves x₂ free: x₁ = 1 − 2x₂, so every choice of x₂ gives a solution.
No. Every entry must be a number, a decimal or a fraction. For a matrix with a parameter, row reduce by hand and note which values of the parameter make a pivot 0, then check those cases here with numbers.
For a square n × n matrix, the rank is n exactly when the determinant is nonzero, and then the RREF is the identity matrix. A rank below n means det A = 0 and the matrix is singular.
Solving systems of linear equations, finding the rank, a basis for the null space and column space, testing whether vectors are linearly independent, and finding an inverse by reducing [A | I] to [I | A⁻¹].
Multiply, add and subtract matrices up to 6 × 6, plus determinant, inverse, transpose and powers, exactly.
Exact inverses of 2x2 to 6x6 matrices by Gauss–Jordan elimination, with every row operation and a check.
Exact determinants of 2x2 to 6x6 matrices by row reduction or cofactor expansion, with every step.
Solve linear systems in 2 to 4 unknowns with exact row operations, a graph and a check.
Free worked solutions for equations, systems, inequalities, factoring, derivatives, integrals, limits and matrices.
Learn more: To see row reduction used on a real problem, read how to solve a system of three equations.
Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?