Matrix Calculator: Add, Subtract, or Multiply Matrices
Enter values into Matrix A and Matrix B, choose an operation, and see Matrix C update in real time. No sign-up, no server calls.
The Complete Guide to Matrix Operations
Matrices are one of the most powerful and widely applied structures in all of mathematics. Whether you are a student learning linear algebra for the first time or an engineer refreshing your memory, this guide walks through everything you need to understand matrix addition, subtraction, and multiplication.
How to Use This Calculator
Set the number of rows and columns for Matrix A and Matrix B using the dropdowns in each panel. Click any cell and type a number. The result in Matrix C updates the moment you type. To switch between operations, click the A + B, A - B, or A x B buttons at the top. Empty cells are treated as zero. There is no submit button - everything is live.
Addition and Subtraction: Element by Element
Adding or subtracting matrices is straightforward: both matrices must have the exact same dimensions, and you simply apply the operation to each pair of corresponding elements. The element at row 1, column 1 of Matrix A is added to (or subtracted from) the element at row 1, column 1 of Matrix B. This produces the element at row 1, column 1 of the result. The result matrix always has the same dimensions as the inputs. If the dimensions do not match, the operation is mathematically undefined.
Because matrix addition follows the same element-by-element rule as regular addition, it inherits commutativity: A + B always equals B + A. Subtraction, however, is not commutative - A - B is generally not the same as B - A, just as 5 - 3 differs from 3 - 5.
Multiplication: Rows Meet Columns
Matrix multiplication is more nuanced. To multiply Matrix A (size m x p) by Matrix B (size p x n), the number of columns in A must equal the number of rows in B - those are the "inner" dimensions. The result, Matrix C, has dimensions m x n.
Each element of Matrix C is computed as the dot product of a row from Matrix A and a column from Matrix B. Specifically, C[i][j] = sum over k of A[i][k] times B[k][j]. For every element in the result, you are pairing up an entire row of A with an entire column of B, multiplying each pair, and summing the products. This is why the inner dimensions must agree - there must be an equal number of elements to pair up.
Unlike addition, matrix multiplication is not commutative. A x B usually does not equal B x A. Sometimes only one order is even valid. In real applications - graphics pipelines, neural networks, quantum mechanics - the order of matrix multiplication determines the meaning of the transformation.