A matrix is a rectangular grid of numbers, and most of linear algebra comes down to a handful of operations on those grids. This matrix calculator handles the everyday ones — addition, subtraction, multiplication, scalar multiples, transposes and powers — keeps every entry as an exact fraction, and lays out how each entry of the answer was produced.
How to use the matrix calculator
- Pick the Operation: A + B, A − B, A × B, k × A, the transpose Aᵀ, or the power Aⁿ.
- Type Matrix A with one row per line and the entries separated by spaces or commas. Fractions such as 2/3 are fine.
- For sums, differences and products, type Matrix B the same way. For a scalar multiple, enter k; for a power, enter n from 0 to 20.
- Read the result on the tape (or below it for larger matrices). The work panel shows how the first entries were computed, and the result block repeats the whole equation.
Matrix operations and their size rules
| Operation | Size requirement | Each entry of the result |
|---|---|---|
| A + B, A − B | A and B the same size | cij = aij ± bij |
| k × A | any | k × aij |
| A × B | columns of A = rows of B | row i of A times column j of B |
| Aᵀ | any | (Aᵀ)ij = aji |
| Aⁿ | A square | A multiplied by itself n times |
The product rule is the one worth memorizing:
An m × n matrix times an n × p matrix produces an m × p matrix. The inner sizes must match and disappear; the outer sizes give the shape of the answer.
Worked example: multiplying a 2 × 3 by a 3 × 2
Let A have rows (2, −1, 0) and (1, 3, 4), and let B have rows (1, 2), (0, −3) and (5, 1). The inner sizes are both 3, so the product is 2 × 2.
Row 1 · column 1: 2·1 + (−1)·0 + 0·5 = 2
Row 1 · column 2: 2·2 + (−1)·(−3) + 0·1 = 7
Row 2 · column 1: 1·1 + 3·0 + 4·5 = 21
Row 2 · column 2: 1·2 + 3·(−3) + 4·1 = −3
So A × B has rows (2, 7) and (21, −3). Its trace is 2 + (−3) = −1 and its determinant is 2·(−3) − 7·21 = −153.
Reversing the order, B × A is a 3 × 3 matrix — a completely different object. That single example shows why the order of factors matters.
Why matrix multiplication works this way
Each matrix describes a linear transformation: a rule that stretches, rotates, reflects or projects vectors. Multiplying matrices composes those transformations, and the row-times-column rule is exactly what you get when you apply B first and then A to a vector. That is why the product is associative — (AB)C = A(BC) — but not commutative: rotating and then stretching is not the same as stretching and then rotating.
Powers follow from the same idea. A² applies the transformation twice, so a rotation by 30° squared is a rotation by 60°. A nice classroom example is the matrix with rows (1, 1) and (1, 0): its powers contain Fibonacci numbers, and its tenth power has rows (89, 55) and (55, 34). Compare with the Fibonacci calculator.
Tips and common mistakes
- Adding mismatched sizes. Only same-size matrices can be added or subtracted; there is no padding with zeros.
- Multiplying entry by entry. The product is not formed by multiplying matching entries. That entry-wise operation exists (the Hadamard product) but is a different thing.
- Losing exactness. Typing 0.333 instead of 1/3 introduces rounding that grows through repeated multiplication. Enter fractions to keep results exact.
- Forgetting the identity. A × I = I × A = A, where I is the identity matrix. It plays the role of 1.
For square matrices, the next questions are usually whether the matrix can be undone and how it scales area or volume. Use the matrix determinant calculator and the matrix inverse calculator, or solve equations directly with the system of linear equations calculator.
Frequently asked questions
When can two matrices be multiplied?
A × B is defined only when the number of columns of A equals the number of rows of B. A 2 × 3 matrix times a 3 × 2 matrix works and gives a 2 × 2 result, but a 2 × 3 times a 2 × 3 does not.
Is A × B the same as B × A?
Usually not. Matrix multiplication is not commutative: the two products can contain different numbers, have different sizes, or one of them may not exist at all. The calculator tells you whether your two square matrices happen to commute.
How do I type a matrix?
Put each row on its own line and separate the entries with spaces or commas. Brackets are optional. Decimals such as −0.25 and fractions such as 3/4 are kept exact, so 1/3 never turns into 0.333.
What does the transpose do?
It turns rows into columns: entry (i, j) moves to (j, i). A 2 × 3 matrix becomes 3 × 2. A square matrix that equals its own transpose is called symmetric.
What is A to the power 0?
For any square matrix, A⁰ is the identity matrix of the same size, with 1s on the diagonal and 0s elsewhere, just as any non-zero number to the power 0 is 1.