Matrix Calculator
Enter one or two matrices up to 5 × 5 and pick an operation. Results use exact fractions, and determinants, inverses and row reductions come with every step.
Matrix A
Matrix B
Cells accept integers, decimals and fractions like -2/3. Empty cells count as 0.
Operation
Steps
How to use the Matrix Calculator
- Set the size of matrix A and matrix B with the Rows and Cols menus.
- Type the entries – integers, decimals or fractions like 3/4. Use Random or Identity to fill quickly.
- Pick an operation such as A × B, det, Inverse or RREF, and choose whether it applies to A or B.
- Press Calculate to see the result and, for det, inverse, rank and RREF, every elimination step.
- Copy the result or press Use result as A to chain operations.
Matrix operations at a glance
| Operation | Rule | Size requirement |
|---|---|---|
| A + B, A − B | Add or subtract matching entries | Same size |
| A × B | (i, j) entry = row i of A · column j of B | Columns of A = rows of B; result is rows(A) × cols(B) |
| k × A | Multiply every entry by k | Any |
| Aᵀ | Swap rows and columns | Any; m × n becomes n × m |
| det(A) | Product of the pivots after elimination, with a sign flip per row swap | Square |
| A⁻¹ | Row reduce [A | I] to [I | A⁻¹] | Square with det ≠ 0 |
| RREF, rank | Gauss–Jordan elimination; rank = number of pivots | Any |
| tr(A) | Sum of the main diagonal | Square |
Matrix multiplication is not commutative: A × B is usually different from B × A, and one may be defined when the other is not.
Worked example: inverse of a 2 × 2 matrix
For A = [[4, 7], [2, 6]], det(A) = 4·6 − 7·2 = 10. The shortcut for 2 × 2 matrices is A⁻¹ = (1/det) × [[d, −b], [−c, a]] = (1/10) × [[6, −7], [−2, 4]] = [[3/5, −7/10], [−1/5, 2/5]]. The calculator gets the same answer by reducing [A | I], and keeps the entries as exact fractions.
Reduced row echelon form and rank
A matrix is in reduced row echelon form (RREF) when every non-zero row starts with a leading 1 (the pivot), each pivot is to the right of the one above it, every other entry in a pivot column is 0, and zero rows are at the bottom. The rank is the number of pivots. It tells you how many rows (or columns) are linearly independent: a square n × n matrix is invertible exactly when its rank is n and its determinant is non-zero.
Determinant properties worth knowing
- Swapping two rows changes the sign of the determinant.
- Adding a multiple of one row to another leaves it unchanged – that is why elimination works.
- det(A × B) = det(A) × det(B), and det(Aᵀ) = det(A).
- det(kA) = kⁿ det(A) for an n × n matrix.
Frequently asked questions
How do you find the inverse of a matrix?
Write the matrix next to the identity matrix, [A | I], and use row operations until the left side becomes the identity. The right side is then A⁻¹. If a zero pivot appears and cannot be swapped away, the matrix has no inverse.
When does a matrix have no inverse?
A square matrix is not invertible (singular) when its determinant is 0, which happens when its rows or columns are linearly dependent, so its rank is less than its size. Non-square matrices never have a regular inverse.
How is the determinant calculated?
The calculator uses Gaussian elimination: it turns the matrix into upper triangular form, multiplies the diagonal entries, and flips the sign once for every row swap. This is much faster than cofactor expansion for larger matrices and gives the same result.
Why can't I multiply these two matrices?
A × B is only defined when the number of columns in A equals the number of rows in B. A 2 × 3 matrix can multiply a 3 × 4 matrix (giving 2 × 4), but not a 2 × 3 matrix.
What does RREF tell me?
The reduced row echelon form shows the rank, which columns are independent (pivot columns), and the solution of a linear system when the matrix is augmented with the right-hand side.
Does the calculator round results?
No. All arithmetic is done with exact fractions using big integers, so there is no rounding error. Tick Show decimals to see decimal approximations instead.