Matrix Calculator
Ten matrix operations up to 5×5, with exact fractions
Add, subtract, multiply, raise to a power, transpose, invert and find the determinant, trace or rank of matrices up to 5×5. Accepts fractions, shows exact or decimal results and checks the size rules for you.
Linear AlgebraUpdated October 21, 2026Checked against 8 reference values
Examples
AB (2×2)
| 2 | −1 |
| 6 | 2 |
- Operation
- A × B
- Size of A
- 2×3
- Size of B
- 3×2
Working
- 1
Check the sizes
2×3 times 3×2: inner sizes match, so AB is 2×2. - 2
Entry (1, 1)
Row 1 of A · column 1 of B = 1×2 + 2×0 + 0×4 = 2 - 3
Entry (1, 2)
Row 1 of A · column 2 of B = 1×1 + 2×−1 + 0×3 = −1 - 4
Entry (2, 1)
Row 2 of A · column 1 of B = −1×2 + 3×0 + 2×4 = 6 - 5
Entry (2, 2)
Row 2 of A · column 2 of B = −1×1 + 3×−1 + 2×3 = 2
AB as a heat map
Need every step for one operation? Use the dedicated determinant, inverse, multiplication or RREF calculators.
Ten matrix operations in one place
This calculator handles the everyday matrix operations for matrices up to 5×5: addition, subtraction, multiplication, scalar multiples, integer powers, the transpose, the determinant, the inverse, the trace and the rank. Pick an operation, size the matrices, and the result updates as you type. Entries can be integers, decimals or fractions such as 2/3, and results can be shown as exact fractions or as decimals.
It suits homework checks, quick transformations in graphics or physics, and chaining several steps together. When you want the full hand working for one operation, the dedicated pages go further: the determinant calculator shows cofactor expansion and row reduction, the inverse calculator shows every Gauss-Jordan row operation, and the RREF calculator reads off solutions of linear systems.
Which sizes each operation accepts
Most errors with matrices are size errors. The calculator checks these rules before computing and tells you which one failed.
| Operation | Requirement | Result |
|---|---|---|
| A + B, A − B | A and B the same size | Same size as A |
| A × B | Columns of A = rows of B | Rows of A × columns of B |
| k × A | Any matrix | Same size as A |
| Aⁿ | Square A (invertible if n < 0) | Same size as A |
| Aᵀ | Any matrix | Rows and columns swapped |
| det(A), tr(A) | Square A | A single number |
| A⁻¹ | Square A with det(A) ≠ 0 | Same size as A |
| rank(A) | Any matrix | A whole number |
In a product, entry (i, j) of AB is the dot product of row i of A with column j of B: (AB)ᵢⱼ = Σ aᵢₖbₖⱼ. That is why the inner sizes must match, and why a 2×3 matrix times a 3×2 matrix gives a 2×2 result.
Worked examples
A 2×3 matrix times a 3×2 matrix
With A = [[1, 2, 0], [−1, 3, 2]] and B = [[2, 1], [0, −1], [4, 3]], entry (1, 1) is 1·2 + 2·0 + 0·4 = 2 and entry (2, 2) is (−1)·1 + 3·(−1) + 2·3 = 2. The full product is AB = [[2, −1], [6, 2]].
Inverse of a 3×3 matrix
The matrix [[2, −1, 0], [−1, 2, −1], [0, −1, 2]] has determinant 4, so it is invertible, and Gauss-Jordan elimination gives A⁻¹ = [[3/4, 1/2, 1/4], [1/2, 1, 1/2], [1/4, 1/2, 3/4]]. Every entry is a multiple of 1/4 because the determinant is 4.
A matrix power
Raising [[1, 1], [1, 0]] to the 10th power gives [[89, 55], [55, 34]]. The entries are consecutive Fibonacci numbers, which is a fast way to compute them: repeated squaring needs only a handful of multiplications for large powers.
Rank of a 3×4 matrix
For [[1, 2, 3, 4], [2, 4, 6, 8], [1, 0, 1, 0]], the second row is twice the first, so row reduction leaves 2 nonzero rows. The rank is 2: the rows span a plane, not all of space.
Why the order of multiplication matters
Matrix multiplication is not commutative. For P = [[1, 2], [3, 4]] and Q = [[5, 6], [7, 8]], PQ = [[19, 22], [43, 50]] but QP = [[23, 34], [31, 46]]. Applying one transformation and then another is generally different from applying them the other way round, just as rotating then stretching a shape differs from stretching then rotating.
Other rules carry over from ordinary arithmetic: multiplication is associative, (AB)C = A(BC), and distributes over addition. The transpose and inverse of a product reverse the order: (AB)ᵀ = BᵀAᵀ and (AB)⁻¹ = B⁻¹A⁻¹.
Precision and limits
- Arithmetic uses double precision. Determinants of integer matrices are computed by cofactor expansion without division, so they come out as exact integers.
- Fraction display converts each decimal result to the nearest fraction with a denominator up to 1,000 that matches it to about nine significant digits; anything else stays a decimal.
- A matrix is reported as singular when Gauss-Jordan elimination finds a column with no usable pivot, judged relative to the size of the entries. Nearly singular matrices can have inverses with very large entries that are sensitive to rounding.
- Powers are limited to exponents from −50 to 50 to keep the entries within floating-point range.
Matrix Calculator: common questions
Is matrix multiplication commutative?
No. AB and BA are usually different, and one of them may not even be defined when the matrices are not square. For example, [[1, 2], [3, 4]] times [[5, 6], [7, 8]] gives [[19, 22], [43, 50]], while the reverse order gives [[23, 34], [31, 46]].
What sizes can be multiplied together?
A product AB exists when the number of columns of A equals the number of rows of B. An m×n matrix times an n×p matrix gives an m×p matrix, so a 2×3 times a 3×4 is a 2×4, while a 2×3 times a 2×3 is undefined.
When does a matrix have an inverse?
A matrix has an inverse only if it is square and its determinant is not zero. Such a matrix is called invertible or nonsingular, and A times its inverse gives the identity matrix.
What does the rank of a matrix tell me?
The rank is the number of independent rows, which always equals the number of independent columns. It is the number of pivots left after row reduction, and it tells you the dimension of the space the matrix maps onto.
Can I enter fractions and get exact answers?
Yes. Type entries such as 3/4 or −5/2, and choose Fractions to see results like 1/3 instead of 0.333333. The calculator works in floating point and converts results back to fractions when they match a fraction with a denominator up to 1,000.
Sources
- Strang, G., Introduction to Linear Algebra, 5th ed., Wellesley-Cambridge Press, 2016, chapters 2 and 5
- Lay, D. C., Lay, S. R. and McDonald, J. J., Linear Algebra and Its Applications, 5th ed., Pearson, 2016, chapters 2 and 3
Related calculators
- Matrix Multiplication CalculatorMultiply two matrices up to 5×5 with every entry of the product written out as a dot product. Highlights the row and column behind any entry, checks the size rule, compares AB with BA and accepts fractions.
- Matrix Determinant CalculatorFind the determinant of a 2×2 to 5×5 matrix with full working by cofactor expansion along the best row or column, or by row reduction to triangular form. Accepts fractions and charts each expansion term.
- Matrix Inverse CalculatorFind the inverse of a 2×2 to 5×5 matrix with every Gauss-Jordan row operation on [A | I], or with the cofactor and adjugate method. Accepts fractions, gives exact results and checks that A times the inverse is I.
- Matrix RREF CalculatorReduce any matrix up to 6×7 to reduced row echelon form with each Gauss-Jordan row operation shown. Marks the pivots, gives the rank and null space, and reads the solution of a linear system from an augmented matrix.
- Matrix Transpose CalculatorTranspose any matrix up to 6×6 and see rows turn into columns. Checks whether a square matrix is symmetric, skew-symmetric or orthogonal, splits it into symmetric and skew parts, and shows AᵀA and AAᵀ.
- Eigenvalue & Eigenvector CalculatorFind the eigenvalues and eigenvectors of a 2×2 or 3×3 matrix, including complex and repeated eigenvalues, with the characteristic polynomial, multiplicities, the PDP⁻¹ factorization and every step shown.