Math
Matrix operations calculator
Enter two matrices, one row per line, and choose an operation. For products, every entry of the answer is shown as the row-times-column sum that produced it. For AX = B you get the augmented matrix and each row operation, and the calculator tells you whether the system has one solution, none or infinitely many.
One row per line; entries separated by spaces or commas.
For AX = B, B is the right-hand side: one column for a single system.
| Entry | Row · column | Working |
|---|---|---|
| (1, 1) | row 1 · column 1 | 1×7 + 2×9 + 3×11 = 58 |
| (1, 2) | row 1 · column 2 | 1×8 + 2×10 + 3×12 = 64 |
| (2, 1) | row 2 · column 1 | 4×7 + 5×9 + 6×11 = 139 |
| (2, 2) | row 2 · column 2 | 4×8 + 5×10 + 6×12 = 154 |
Show the working, step by step
Check the sizes: 2×3 × 3×2. The inner numbers match (3), so the product exists, and the outer numbers give its size, 2×2.
A =123456B =789101112Each entry is the dot product of a row of the first matrix with a column of the second: multiply matching entries and add.
c11 = 1×7 + 2×9 + 3×11 = 58 c12 = 1×8 + 2×10 + 3×12 = 64 c21 = 4×7 + 5×9 + 6×11 = 139 c22 = 4×8 + 5×10 + 6×12 = 154
Collect the entries.
AB =5864139154
Matrix multiplication is not commutative: AB and BA are usually different, and one may exist without the other.
The rules
(A ± B)ᵢⱼ = Aᵢⱼ ± Bᵢⱼ same size only (kA)ᵢⱼ = k·Aᵢⱼ any size (AB)ᵢⱼ = Σₖ Aᵢₖ Bₖⱼ A is m×n, B is n×p, AB is m×p
A worked example: AB
The default A is 2×3 and B is 3×2:
A = [ 1 2 3 B = [ 7 8 4 5 6 ] 9 10 11 12 ]
The inner sizes (3 and 3) match, so AB exists and is 2×2. Each entry is a row of A dotted with a column of B:
| Entry | Row · column | Working | Value |
|---|---|---|---|
| (1, 1) | row 1 · column 1 | 1×7 + 2×9 + 3×11 | 58 |
| (1, 2) | row 1 · column 2 | 1×8 + 2×10 + 3×12 | 64 |
| (2, 1) | row 2 · column 1 | 4×7 + 5×9 + 6×11 | 139 |
| (2, 2) | row 2 · column 2 | 4×8 + 5×10 + 6×12 | 154 |
So AB = [58 64; 139 154]. Switch to BA and the product is 3×3 instead: [39 54 69; 49 68 87; 59 82 105]. Same two matrices, a different size of answer. Order matters.
A worked example: solving AX = B
The system
2x + y − z = 8 −3x − y + 2z = −11 −2x + y + 2z = −3
has coefficient matrix A = [2 1 −1; −3 −1 2; −2 1 2] and B = [8; −11; −3]. Enter those and choose “Solve AX = B”. Row-reducing [A | B] takes three pivots:
- R1 → R1 ÷ 2, then R2 → R2 + 3R1 and R3 → R3 + 2R1 clear column 1.
- R2 → 2R2, then R1 → R1 − ½R2 and R3 → R3 − 2R2 clear column 2.
- R3 → −R3, then R1 → R1 + R3 and R2 → R2 − R3 clear column 3.
The left block is now I, and the right-hand column reads x = 2, y = 3, z = −1. Substituting back: 2(2) + 3 − (−1) = 8, −3(2) − 3 + 2(−1) = −11 and −2(2) + 3 + 2(−1) = −3.
One, none or infinitely many solutions
| After row reduction | Meaning | Example |
|---|---|---|
| A pivot in every column of A | Exactly one solution | The system above |
| A row [0 0 … 0 | c] with c ≠ 0 | No solution (inconsistent) | x + 2y = 3, 2x + 4y = 7 |
| A column of A without a pivot, and no contradiction | Infinitely many | x + 2y = 3, 2x + 4y = 6 gives x = 3 − 2t, y = t |
Common mistakes
- Multiplying entry by entry. That is the Hadamard product, a different operation. The ordinary product uses rows times columns.
- Checking the wrong dimensions. It is the columns of the first and the rows of the second that must match, not the two row counts.
- Dividing by a matrix. There is no matrix division. To “divide” by A, multiply by A⁻¹, on the correct side: AX = B gives X = A⁻¹B, not BA⁻¹.
- Assuming (A + B)² = A² + 2AB + B². It equals A² + AB + BA + B², which is the same only when AB = BA.
Common questions
When can two matrices be multiplied?
AB exists when the number of columns of A equals the number of rows of B. Write the sizes side by side: (2×3)(3×2). The inner numbers must match, and the outer numbers give the size of the answer, here 2×2. A 2×3 matrix times a 2×3 matrix is undefined.
Is AB equal to BA?
Usually not. With the default matrices AB is 2×2 and BA is 3×3, so they are not even the same size. Even for square matrices the products generally differ: matrix multiplication is associative, (AB)C = A(BC), and distributive, but not commutative.
How do you calculate one entry of a matrix product?
Entry (i, j) of AB is row i of A dotted with column j of B: multiply the pairs of entries and add. For the default matrices, entry (2, 1) is 4×7 + 5×9 + 6×11 = 28 + 45 + 66 = 139. The calculator lists this working for every entry.
How do I solve a system of equations with matrices?
Write the system as AX = B, with the coefficients in A and the right-hand sides in B, and row-reduce [A | B]. If the left block becomes I, the right block is the unique solution. A row reading 0 = (non-zero) means no solution; a column without a pivot means a free variable and infinitely many solutions. Using A⁻¹B gives the same answer when A is invertible.
Can I add matrices of different sizes?
No. Addition and subtraction work entry by entry, so both matrices must have the same number of rows and the same number of columns. A scalar multiple kA works for any size.
Related calculators
-
Matrix calculator
Inverse, determinant, RREF, rank and eigenvalues of one matrix.
-
Determinant calculator
Check whether A is invertible before solving.
-
Vector calculator
Dot products, the building block of every matrix product.
-
Linear equation calculator
Solve single linear equations with the steps shown.