Skip to content
Math

Matrix Multiplication Calculator

Enter the dimensions of Matrix A and Matrix B, fill in the entries, and get the product A x B instantly. The calculator checks that the inner dimensions match, then shows every dot-product calculation so you can follow the arithmetic. You also get the trace and determinant of the result when it is a square matrix.

Your details

Number of rows then columns of Matrix A (rows x columns).
Number of rows then columns of Matrix B. Columns of A must equal rows of B.
Result matrix A x B
Row 1: [19, 22] | Row 2: [43, 50]

The product of Matrix A and Matrix B written row by row.

Result dimensions2 x 2
Trace of result69
Determinant of result4
C[1,1]19
C[1,2]22
C[2,1]43
C[2,2]50
C[1,1]19
C[1,2]22
C[2,1]43
C[2,2]50

Product computed: 2 x 2 result matrix.

  • A (2x2) multiplied by B (2x2) produces a 2x2 matrix.
  • The trace (sum of the diagonal) of the result is 69.
  • The determinant is 4, confirming the result matrix is invertible.
  • Note: matrix multiplication is generally not commutative - A x B and B x A can differ even for square matrices of the same size.

Next stepTo multiply three matrices, compute A x B first, then multiply the result by C.

Formula

Cij=k=1nAikBkj,where ARm×n,  BRn×p,  CRm×pC_{ij} = \sum_{k=1}^{n} A_{ik} \, B_{kj}, \quad \text{where } A \in \mathbb{R}^{m \times n},\; B \in \mathbb{R}^{n \times p},\; C \in \mathbb{R}^{m \times p}

Worked example

A = [[1,2],[3,4]], B = [[5,6],[7,8]]. C[1,1] = 1x5 + 2x7 = 19. C[1,2] = 1x6 + 2x8 = 22. C[2,1] = 3x5 + 4x7 = 43. C[2,2] = 3x6 + 4x8 = 50. Result: [[19,22],[43,50]].

How matrix multiplication works

Matrix multiplication computes the product of two matrices A and B to produce a new matrix C. The rule is: each entry C[i,j] equals the dot product of the i-th row of A with the j-th column of B. Concretely, you multiply corresponding entries and sum them up. The most important constraint is dimensional compatibility: if A has m rows and n columns, B must have exactly n rows (its columns can be anything). The result C will have m rows and as many columns as B. For example, a 2x3 matrix times a 3x4 matrix produces a 2x4 matrix. A 2x2 times a 3x3 is undefined because the inner dimensions (2 and 3) do not match.

Step-by-step dot product method

To compute C[i,j], take row i of A and column j of B, multiply the matching entries, and add the products. For a 2x2 example with A = [[1,2],[3,4]] and B = [[5,6],[7,8]]: C[1,1] = (1)(5) + (2)(7) = 5 + 14 = 19. C[1,2] = (1)(6) + (2)(8) = 6 + 16 = 22. C[2,1] = (3)(5) + (4)(7) = 15 + 28 = 43. C[2,2] = (3)(6) + (4)(8) = 18 + 32 = 50. This calculator shows that working for every entry in the result.

Key properties of matrix multiplication

Matrix multiplication is associative: (AB)C = A(BC), so you can group multiplications freely. It is also distributive over addition: A(B + C) = AB + AC. However, it is NOT commutative in general: AB does not equal BA for most matrices, and BA may not even be defined if the dimensions differ. The identity matrix I acts like the number 1: AI = IA = A. If the result is a square matrix, this calculator also reports its trace (the sum of diagonal entries) and its determinant (for up to 4x4), which together describe important algebraic properties like invertibility.

Trace, determinant, and invertibility

When the product C = AB is a square matrix, two special numbers give you further insight. The trace is the sum of the entries along the main diagonal. It equals the sum of eigenvalues and is preserved under cyclic permutation of factors (trace(AB) = trace(BA) even when AB and BA differ as matrices). The determinant collapses the entire matrix to a single number. A non-zero determinant means the matrix is invertible; a zero determinant means it is singular. Computationally, det(AB) = det(A) x det(B), so if either input matrix is singular, the product will be too. This calculator computes both automatically for square result matrices up to 4x4.

Matrix multiplication dimension rules

A dimensionsB dimensionsResult dimensionsCompatible?
2 x 22 x 22 x 2 Yes
2 x 33 x 22 x 2 Yes
3 x 33 x 33 x 3 Yes
2 x 23 x 3- No (2 cols != 3 rows)
1 x 44 x 11 x 1 (scalar) Yes (dot product)
m x nn x pm x p Yes

A x B is only defined when columns of A equal rows of B. The result has rows of A and columns of B.

Frequently asked questions

Can you multiply any two matrices together?

Only if their inner dimensions match. If A is m x n and B is p x q, you can form A x B only when n equals p. The result is m x q. If n and p differ, the product is undefined. The calculator flags this instantly with the exact dimension mismatch.

Is matrix multiplication commutative?

Generally no. For most matrices AB and BA are different, and in many cases one direction is not even defined. Even for square matrices of the same size, swapping the order typically changes the result. The identity matrix is a rare exception: IA = AI = A for any compatible A.

What is the dot product and how does it relate to matrix multiplication?

Each entry in the product matrix is a dot product: you take a row from A and a column from B, multiply corresponding elements, and sum. A 1 x n matrix multiplied by an n x 1 matrix is exactly a dot product and returns a 1 x 1 scalar. Matrix multiplication extends this operation across all row-column pairs of the two matrices.

How do I multiply a 2x3 matrix by a 3x2 matrix?

A 2x3 matrix has 3 columns and a 3x2 matrix has 3 rows, so the inner dimensions match. The result is 2x2. For each of the four entries in the 2x2 result, take the corresponding row of the first matrix and column of the second, multiply the three pairs, and sum them. Select 2x3 for Matrix A and 3x2 for Matrix B in this calculator to see every step.

What does the determinant of the result tell me?

The determinant is a single number that captures how the matrix scales areas (in 2D) or volumes (in higher dimensions). If the determinant is zero the matrix is singular and cannot be inverted. For a product AB the determinant equals det(A) multiplied by det(B), so if either factor is singular the product will be too. This calculator shows the determinant for square result matrices up to 4x4.

Can I multiply a matrix by itself?

Yes, as long as it is square (same number of rows and columns). Multiplying a matrix by itself is called squaring it and is written A squared. You can compute this by setting both Matrix A and Matrix B to the same square dimensions and entering the same values in both grids.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…