Matrix Multiplication Calculator
Multiply two matrices where columns of A equal rows of B.
Rows separated by semicolons, columns by commas. Cols of A must equal rows of B.
How Matrix Multiplication Works
Each element (i,j) in the product matrix C = A×B is computed as the dot product of row i of A with column j of B:
For this to work, the number of columns in A must equal the number of rows in B. If A is m×n and B is n×p, then C = A×B is m×p.
Worked Example
Multiply A (2×2) by B (2×2):
[3, 4] [7, 8]
C[0][0] = 1×5 + 2×7 = 19
C[0][1] = 1×6 + 2×8 = 22
C[1][0] = 3×5 + 4×7 = 43
C[1][1] = 3×6 + 4×8 = 50
A×B = [19, 22] [43, 50]
Key Properties
- NOT commutative: A×B ≠ B×A in general
- Associative: A×(B×C) = (A×B)×C
- Distributive: A×(B+C) = A×B + A×C
- Identity: A×I = I×A = A (where I is the identity matrix)
- Zero matrix: A×O = O×A = O
Dimension Rule
Only compatible dimensions can be multiplied:
- 2×3 matrix × 3×4 matrix = 2×4 matrix (valid)
- 2×3 matrix × 2×4 matrix = undefined (invalid: 3 ≠ 2)
- 1×3 row vector × 3×1 column vector = 1×1 scalar (dot product)
Real-World Applications
- Computer graphics: Rotation, scaling, and translation transformations are composed by multiplying transformation matrices.
- Machine learning: Neural network layers compute y = W×x + b where W is the weight matrix.
- Economics: Input-output models use matrix multiplication to track how industries depend on each other.
- Cryptography: Hill cipher encryption multiplies plaintext vectors by a key matrix.
Frequently Asked Questions
When can two matrices be multiplied?
Matrix A (m×n) can multiply B (n×p) only when cols(A) = rows(B). The result is m×p.
Is matrix multiplication commutative?
No. A×B ≠ B×A in general. It is associative and distributive, but not commutative.
What is the identity matrix for multiplication?
The identity matrix I has 1s on the diagonal and 0s elsewhere. A×I = I×A = A.
How do I compute a single element of the product?
Element C[i][j] = dot product of row i of A with column j of B = sum of A[i][k]×B[k][j] for all k.