The Matrix Calculator adds, subtracts, and multiplies matrices with full dimension checking, so you can verify homework, graphics transforms, and systems-of-equations work without arithmetic slips. Enter both matrices, choose the operation, and the result is computed entry by entry.
How It Works
Addition and subtraction are element-wise: each result entry is the sum or difference of the entries in the same position, which is why both matrices must have identical dimensions. Multiplication is the row-by-column dot product: entry (i, j) of the result is the sum over k of A[i][k] times B[k][j], which requires the columns of the first matrix to equal the rows of the second, and produces a result with the first matrix's rows and the second's columns.
Dimension rules
| Operation | Requirement | Result size | |---|---|---| | Add | A and B identical size | Same size | | Subtract | A and B identical size | Same size | | Multiply | Columns of A = rows of B | Rows of A x columns of B |
Worked example
Let A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]. Addition gives [[6, 8], [10, 12]] and subtraction (A - B) gives [[-4, -4], [-4, -4]]. Multiplication: entry (1,1) = 1x5 + 2x7 = 19; (1,2) = 1x6 + 2x8 = 22; (2,1) = 3x5 + 4x7 = 43; (2,2) = 3x6 + 4x8 = 50, so A x B = [[19, 22], [43, 50]]. Reverse the order and B x A = [[23, 34], [31, 46]], a different matrix: multiplication is not commutative, and this calculator follows the order you enter, first matrix on the left.
Why multiplication order and shape matter
Matrix multiplication encodes composition: applying transformation A then B is the product B x A in the convention most graphics and linear-algebra texts use, and swapping the order composes them backwards. The dimension rule is the type system of that world: a 2x3 matrix (two rows, three columns) can multiply a 3x4, producing 2x4, because the inner 3s agree. When the calculator returns a dimension error it is not being pedantic; the operation is undefined, and in an application it would mean mismatched data shapes long before it meant wrong numbers.
Checking your own work
Three habits catch most errors. Verify the result's dimensions before its values. Spot-check one entry by hand with the dot product, ideally a corner. And use associativity sanity checks on small cases, for example multiplying by an identity matrix must return the original unchanged. For hand-sized matrices this calculator is fast enough to test a conjecture: if you suspect A x B equals B x A for two specific matrices, compute both and compare instead of assuming.
Limitations
The calculator covers addition, subtraction, and multiplication of the two matrices you enter. It does not compute determinants, inverses, transposes, eigenvalues, or scalar operations as separate modes, and entries are ordinary numbers evaluated in floating point, so very large products can accumulate rounding error. Symbolic entries (variables) are not supported.
Where you will use this outside class
Matrix multiplication runs the modern world quietly: graphics engines compose rotations, translations, and scaling as products of 4x4 matrices; recommendation and ranking systems are matrix arithmetic at scale; input-output economics and Markov chains multiply state vectors by transition matrices to step a system forward. The habit worth building from this small calculator is dimensional discipline: in every application, a dimension error means the model itself is mismatched, and the practitioners who catch it early are the ones who check shapes before numbers, exactly as the worked example does.
Identity and zero matrices
Multiplying any matrix by the identity matrix of the matching size returns it unchanged, and adding the zero matrix does the same for addition. These are the fastest sanity checks available: if A x I does not return A in your hand calculation, the error is in your multiplication, not in the theory. They also expose why multiplication needs the identity to be square and sized to the side it multiplies from, a subtlety that becomes intuitive after two experiments here.
Frequently Asked Questions
Why can I not multiply a 2x2 by a 3x3?
The first matrix has 2 columns and the second has 3 rows; the inner dimensions must match for the dot products to exist. The product is undefined, not zero.
Is A x B the same as B x A?
Almost never. Matrix multiplication is not commutative, as the worked example shows with two different results from the same pair. Addition is commutative; multiplication generally is not.
What does the calculator do with mismatched sizes for addition?
It returns a dimension error rather than padding or truncating, because silently reshaping data hides mistakes that matter downstream.