Matrix Calculator
Add, subtract and multiply matrices, or find the determinant, inverse, transpose, power, rank and trace of a matrix up to 6×6 – in exact fractions.
Matrix A
Matrix B
Number k
Empty cells count as 0. Decimals and fractions such as 3/4 are fine.
How to use the matrix calculator
Pick the operation, set the number of rows and columns, and type the entries. Empty cells count as 0, and you can enter decimals or fractions such as 3/4. Every result is calculated in exact fractions, so 1/3 stays 1/3 instead of 0.3333 – switch to Decimals if you prefer.
Adding and subtracting matrices
Two matrices can be added only if they have the same size. You add the entries in the same position: the entry in row 1, column 2 of A + B is a₁₂ + b₁₂. Subtraction works the same way.
Multiplying matrices
A × B exists when A has as many columns as B has rows. A 2×3 matrix times a 3×4 matrix gives a 2×4 matrix. Each entry is a row of A multiplied by a column of B, entry by entry, then added up:
cij = ai1·b1j + ai2·b2j + … + ain·bnj
Example: A = [2 1; 1 3] and B = [1 2; 0 1]. The top-left entry is 2·1 + 1·0 = 2, the top-right 2·2 + 1·1 = 5, so A × B = [2 5; 1 5]. Note that matrix multiplication is not commutative: here B × A = [4 7; 1 3], a different matrix.
Other operations
- k · A – every entry is multiplied by the number k.
- Transpose Aᵀ – rows become columns; a 2×3 matrix becomes 3×2.
- Power Aⁿ – A multiplied by itself n times (square matrices only); A⁰ is the identity matrix I.
- Determinant – a single number; the matrix has an inverse exactly when it is not 0.
- Inverse A⁻¹ – the matrix with A × A⁻¹ = I.
- Rank – the number of linearly independent rows (or columns).
- Trace – the sum of the entries on the main diagonal.
Which operations need a square matrix?
The determinant, the inverse, powers and the trace are defined only for square matrices (2×2, 3×3 …). Addition, multiplication, the transpose and the rank work for any size, as long as the dimensions match.
Frequently asked questions
When can two matrices be multiplied?
When the number of columns of the first matrix equals the number of rows of the second. An m×n matrix times an n×p matrix gives an m×p matrix.
Is A × B the same as B × A?
Usually not. Matrix multiplication is not commutative, and B × A may not even exist when A × B does.
Can I enter fractions?
Yes. Type 3/4 or −5/2 in any cell. The calculator works with exact fractions, so results are not rounded.