What this calculator does
Matrix addition and subtraction work element by element, which is exactly what you would guess. Multiplication does not, and that is where the subject stops being intuitive.
The standard example makes the point. Rows 1, 2 and 3, 4 times rows 5, 6 and 7, 8 gives rows 19, 22 and 43, 50. Every entry in the result combines a whole row with a whole column, which is why order matters and why the operation does not commute.
The formula
Addition and subtraction operate on corresponding entries. Multiplication takes the dot product of each row of the first matrix with each column of the second. Scalar multiplication multiplies every entry.
| Term | Meaning |
|---|---|
| Element-wise | Operating on corresponding entries, which addition and subtraction do. |
| Matrix product | Row-by-column combination, which is not element-wise. |
| Non-commutative | AB and BA are generally different matrices. |
The inputs explained
| Field | What to enter |
|---|---|
| A row 1, col 1 | Matrix A, row 1, column 1. |
| A row 1, col 2 | Matrix A, row 1, column 2. |
| A row 2, col 1 | Matrix A, row 2, column 1. |
| A row 2, col 2 | Matrix A, row 2, column 2. |
| B row 1, col 1 | Matrix B, row 1, column 1. |
| B row 1, col 2 | Matrix B, row 1, column 2. |
| B row 2, col 1 | Matrix B, row 2, column 1. |
| B row 2, col 2 | Matrix B, row 2, column 2. |
| Scalar k | The scalar to multiply matrix A by. |
When to use it
Learning matrix arithmetic
Seeing all four operations on the same pair shows how differently they behave.
Combining transformations
Multiplying matrices composes the transformations they represent.
Checking hand calculations
Matrix multiplication is easy to get wrong by hand.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How does the scalar affect matrix A?
The same pair of matrices at three scalar values.
| Scalar k | k × A | A × B |
|---|---|---|
| k = 1 | [ 1.00, 2.00 ; 3.00, 4.00 ] | [ 19.00, 22.00 ; 43.00, 50.00 ] |
| k = 2 | [ 2.00, 4.00 ; 6.00, 8.00 ] | [ 19.00, 22.00 ; 43.00, 50.00 ] |
| k = 4 | [ 4.00, 8.00 ; 12.00, 16.00 ] | [ 19.00, 22.00 ; 43.00, 50.00 ] |
Questions
Why is matrix multiplication defined that way?
Because matrices represent linear transformations, and the row-by-column rule is exactly what composing two transformations produces. Element-wise multiplication exists and is useful, but it does not correspond to composition.
Does AB equal BA?
Almost never. Matrix multiplication is non-commutative, and swapping the order generally gives a different result. This reflects reality: rotating then stretching is not the same as stretching then rotating.
Can any two matrices be multiplied?
Only when the first has as many columns as the second has rows. For 2x2 matrices that is always satisfied, which is why the constraint is easy to forget until larger matrices appear.
What does scalar multiplication do geometrically?
It scales the whole transformation uniformly. Multiplying by 2 doubles the effect on every vector, and multiplying by a negative number also reverses direction.
For inverting a matrix, see the matrix inverse calculator. For the determinant, see the determinant calculator.