Math
Matrix Multiplication Calculator
Enter matrix A and matrix B to compute the product AB.
The calculator checks the dimension rule (columns of A must equal rows of B), writes out the row-times-column dot product for each entry, keeps fractions exact, and shows BA next to AB when both exist so you can see that matrix multiplication is not commutative.
The left factor. Its number of columns must match the number of rows of B.
The right factor. A column vector works too: type one entry per line.
Try an example
Result
Product AB
—
- Size of AB
- —
- Is BA defined?
- —
- AB vs BA
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
How matrix multiplication works
To multiply A (m x n) by B (n x p), take each row of A and each column of B, multiply the matching entries, and add. The result is an m x p A rectangular grid of numbers arranged in rows and columns.. The inner dimensions (n and n) must match; the outer dimensions (m and p) give the size of the product.
Dimension rule at a glance
| A | B | AB defined? | Size of AB |
|---|---|---|---|
| 2 x 3 | 3 x 2 | Yes | 2 x 2 |
| 3 x 2 | 2 x 3 | Yes | 3 x 3 |
| 2 x 2 | 2 x 2 | Yes | 2 x 2 |
| 2 x 3 | 2 x 3 | No | columns of A (3) ≠ rows of B (2) |
| 3 x 3 | 3 x 1 (vector) | Yes | 3 x 1 |
How to use it
- Enter A in the first box and B in the second, one row per line.
- Check the header: it tells you the size of AB, or explains the mismatch if the product is undefined.
- Open Show the work to see the Multiply two vectors piece by piece and add the results to get one number. for every entry, written as products then sums.
- Compare AB with BA in the panel when both are square: they are usually different.
How to read the answer
- Entry c_ij sits in row i, column j of AB and comes from row i of A and column j of B.
- Multiplying by the identity matrix returns the same matrix: AI = IA = A.
- A matrix times a column A quantity with both a size and a direction, often drawn as an arrow. is a column vector; this is how linear systems Ax = b are written.
Common mistakes
- Multiplying entry by entry (a_ij·b_ij). That is the Hadamard product, not matrix multiplication.
- Assuming AB = BA. Matrix multiplication is not commutative; the calculator shows both when they exist.
- Forgetting the dimension rule: a 2 x 3 times a 2 x 3 is undefined, but a 2 x 3 times a 3 x 2 is fine.
- Mixing up rows and columns: use rows of the left matrix and columns of the right matrix.
How to type a matrix into this calculator
- Put each row on its own line. Separate the entries in a row with spaces or commas: 2 1 1 or 2, 1, 1.
- Fractions such as 1/3 and decimals such as 0.25 are accepted and kept exact, so 1/3 stays 1/3 instead of becoming 0.3333.
- Every row must have the same number of entries. A row with a missing entry produces a clear error instead of a wrong answer.
- The largest size supported is 8 x 8. Brackets and semicolons are ignored, so [1 2; 3 4] works too.
Worked examples
2 x 3 times 3 x 2
A = [1 2 3; 4 5 6], B = [7 8; 9 10; 11 12]
Product AB
[58, 64; 139, 154]
Square matrices that do not commute
A = [1 2; 3 4], B = [0 1; 1 0]
Product AB
[2, 1; 4, 3]
Matrix times a column vector
A = [2 -1; 1 3], v = (4, 5)
Product AB
[3; 19]
Fractions and negatives
A = [1/2 -1; 0 3], B = [4 2; 1/3 -2]
Product AB
[5/3, 3; 1, -6]
Multiplying by the identity
AI = A
Product AB
[5, 6; 7, 8]
Dimension mismatch
A 2 x 3 times a 2 x 3 is undefined
Product AB
Error
Frequently asked questions
Can you multiply a 2 x 3 matrix by a 3 x 2 matrix?+
Yes. The inner dimensions match (3 and 3), so the product exists and is 2 x 2. The reverse product, 3 x 2 times 2 x 3, also exists and is 3 x 3.
Why is matrix multiplication not commutative?+
AB uses rows of A against columns of B, while BA uses rows of B against columns of A. Those are different sums, and often the sizes do not even match. Only special pairs, such as powers of the same matrix, commute.
What is the dimension rule for matrix multiplication?+
For AB to exist, the number of columns of A must equal the number of rows of B. The product has as many rows as A and as many columns as B.
How do I multiply a matrix by a vector?+
Treat the vector as a column matrix (n x 1). Each entry of the result is the dot product of a row of the matrix with the vector. Enter the vector with one entry per line in Matrix B.
How many multiplications does it take?+
Each entry needs n multiplications where n is the inner dimension, and there are m·p entries, so m·n·p total. A 3 x 3 times 3 x 3 takes 27 multiplications.
Is multiplying by a scalar the same thing?+
No. Scalar multiplication multiplies every entry by one number and always works. Use the scalar multiplication calculator for that.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Scalar Matrix Multiplication Calculator
Multiply a matrix up to 8 x 8 by a scalar (integer, decimal, or fraction) with every entry shown. Explains why det(kA) = kⁿ·det(A) and how scalar multiplication differs from matrix multiplication.
Matrix Addition and Subtraction Calculator
Add or subtract two matrices of the same size up to 8 x 8 with exact fractions. Shows the entry-by-entry work, checks that the dimensions match, and displays the other operation for comparison.
Matrix Transpose Calculator
Transpose any matrix up to 8 x 8 and check whether it is symmetric, skew-symmetric, or orthogonal. Shows AᵀA and AAᵀ, the row-to-column steps, and the transpose rules for products, determinants, and traces.
Matrix Power Calculator
Raise a square matrix up to 8 x 8 to any integer power from -30 to 30 with exact fractions. Shows each intermediate power, handles A^0 = I and negative powers through the inverse, and checks det(A^k) = det(A)^k.
Matrix Inverse Calculator
Invert any square matrix up to 8 x 8 with exact fractions. Gauss-Jordan elimination on [A | I] with every row operation shown, the adjugate route for small matrices, a singular-matrix explanation, and an A·A⁻¹ = I check.
Matrix Determinant Calculator
Find the determinant of any square matrix up to 8 x 8 with exact fractions. Shows cofactor expansion along any row or column for 3 x 3 (with a rule-of-Sarrus check), row-reduction steps for larger matrices, and tells you whether the matrix is invertible.
Last updated: September 4, 2026