Matrix Multiplication Calculator - 2x2 Row-by-Column Product

Use this matrix multiplication calculator to multiply two 2x2 matrices with the row-by-column dot product rule, then read both AB and BA.

Updated: June 16, 2026 • Free Tool

Matrix Multiplication Calculator

First entry of matrix A. Real number, decimals and negatives allowed.

Second entry of the first row of matrix A.

First entry of the second row of matrix A.

Second entry of the second row of matrix A.

First entry of matrix B. Real number, decimals and negatives allowed.

Second entry of the first row of matrix B.

First entry of the second row of matrix B.

Second entry of the second row of matrix B.

Results

AB row 1, col 1 (A row 1 · B col 1)
0
AB row 1, col 2 (A row 1 · B col 2) 0
AB row 2, col 1 (A row 2 · B col 1) 0
AB row 2, col 2 (A row 2 · B col 2) 0
BA row 1, col 1 (B row 1 · A col 1) 0
BA row 1, col 2 (B row 1 · A col 2) 0
BA row 2, col 1 (B row 2 · A col 1) 0
BA row 2, col 2 (B row 2 · A col 2) 0

What Is a Matrix Multiplication Calculator?

A matrix multiplication calculator multiplies two compatible matrices using the row-by-column dot product rule. Enter the four entries of a 2x2 input matrix A and the four entries of a 2x2 input matrix B, and the result panel gives you the four cells of the product AB, with each cell equal to the dot product of the matching row of A and column of B. The page also shows BA so you can see that A*B and B*A are usually different.

  • Linear algebra homework: Confirm the product of two small matrices by hand, then check each cell against the row-by-column rule.
  • Computer graphics transforms: Compose two 2D affine or rotation matrices and read the combined transform cell by cell.
  • Statistics and covariance: Multiply two 2x2 data tables or covariance slices and read the combined table row by row.
  • Robotics and kinematics: Work through 2x2 coordinate-transform products in introductory robotics or statics problems.

Matrix multiplication is one of the defining operations in linear algebra, and it usually follows matrix addition in any introductory course. The product is built by taking a row of the left matrix and a column of the right matrix, multiplying the matching pairs, and adding the products to land in a single cell. The number of columns of the left matrix has to equal the number of rows of the right matrix.

This calculator focuses on the 2x2 by 2x2 case, the most common size in homework.

For the element-wise sum on the same 2x2 inputs, the matrix addition calculator walks through the same cell-by-cell rule on A and B.

How the Matrix Multiplication Calculator Works

The calculator reads the eight input cells, builds 2x2 matrix A and 2x2 matrix B, and returns two 2x2 product matrices: AB (rows of A against columns of B) and BA (rows of B against columns of A) so you can see the order matters in general.

C[i][j] = sum over k of A[i][k] * B[k][j], with C of shape m x p when A is m x n and B is n x p
  • A[i][k]: Entry in row i, column k of the left input matrix A. The index k runs across the shared inner dimension.
  • B[k][j]: Entry in row k, column j of the right input matrix B. The same index k matches the column index of A.
  • C[i][j]: Entry in row i, column j of the product matrix C = A * B, equal to the dot product of row i of A with column j of B.
  • m x n times n x p: The shared inner dimension n must match. For this calculator m = n = p = 2, so the product is also 2x2.

The same row-by-column rule extends to a 3x3 system or to a non-square pair like 2x3 times 3x2, where the inner dimension still has to match and each output cell is a sum of products whose length equals the shared inner dimension.

Worked 2x2 example for AB

A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]].

Row 1 vs col 1: 1*5 + 2*7 = 19. Row 1 vs col 2: 1*6 + 2*8 = 22. Row 2 vs col 1: 3*5 + 4*7 = 43. Row 2 vs col 2: 3*6 + 4*8 = 50.

AB = [[19, 22], [43, 50]].

Each output cell is the dot product of one row of A with one column of B.

Worked example showing BA differs from AB

Same A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]].

BA r1c1 = 5*1 + 6*3 = 23. BA r1c2 = 5*2 + 6*4 = 34. BA r2c1 = 7*1 + 8*3 = 31. BA r2c2 = 7*2 + 8*4 = 46.

BA = [[23, 34], [31, 46]].

AB and BA are different products. Matrix multiplication is not commutative in general.

According to Wikipedia, the product of an m x n matrix A and an n x p matrix B is the m x p matrix C whose entry in row i, column j is the sum over k of A[i][k] * B[k][j].

Each cell of the product is a single dot product, and the dot product calculator covers the same operation for 2D and 3D vectors.

Key Concepts Behind Matrix Multiplication

Four short ideas cover the row-by-column rule and the algebraic properties that make matrix multiplication behave differently from scalar multiplication.

Inner dimension must match

Two matrices can be multiplied only when the number of columns of the left matrix equals the number of rows of the right matrix. A 2x2 by 2x2 product is allowed, and a 2x2 by 2x3 product is also allowed because the inner dimensions (2 = 2) match, producing a 2x3 product.

Row-by-column dot product

Each cell of the product is the dot product of one row of the left matrix with one column of the right matrix: multiply the matching pairs and add them up.

Non-commutativity: AB != BA

Swapping the order generally changes the product. The result panel returns AB and BA on the same screen so the difference is visible at a glance.

Identity and zero matrix roles

Multiplying by the identity matrix I leaves a matrix unchanged, while multiplying by the zero matrix produces the zero matrix.

How to Use This Matrix Multiplication Calculator

Enter the four cells of matrix A and the four cells of matrix B in row order, then read the four cells of the product AB and the four cells of BA in the result panel. The output updates as you type.

  1. 1 Type the first row of matrix A: Fill in the A row 1, col 1 and A row 1, col 2 cells with the top row of your first matrix.
  2. 2 Type the second row of matrix A: Fill in the A row 2, col 1 and A row 2, col 2 cells with the bottom row of matrix A.
  3. 3 Type the first row of matrix B: Fill in the B row 1, col 1 and B row 1, col 2 cells with the top row of the second matrix.
  4. 4 Type the second row of matrix B: Fill in the B row 2, col 1 and B row 2, col 2 cells with the bottom row of matrix B.
  5. 5 Read the product AB: Each of the four AB cells is the dot product of the matching row of A and column of B.
  6. 6 Compare with BA: The four BA cells in the result panel show the product in the other order. Use them to check that AB and BA are not always equal.

Suppose you are checking a 2D graphics pipeline that composes a stretch and a shear. Take A = [[2, 0], [0, 1]] (stretch x by 2) and B = [[1, 1], [0, 1]] (shear x by the y value). Type those into the form and the result panel returns AB = [[2, 2], [0, 1]] and BA = [[2, 1], [0, 1]]: same diagonal, different off-diagonal. Planar rotations commute, but a stretch and a shear generally do not, and the calculator exposes that gap directly.

When the second factor is a single number rather than a 2x2 matrix, the matrix scalar multiplication calculator walks through the cell-by-cell scaling of one matrix by a real number.

Benefits of This Matrix Multiplication Calculator

The row-by-column rule is short, but mixing up the row-column order is the most common source of errors. The calculator keeps both input matrices and both products on screen.

  • Row-by-column dot products without redoing the arithmetic: Each of the four AB cells is the dot product of the matching row of A and column of B, so you read the result directly without expanding each sum by hand.
  • Both AB and BA shown side by side: The result panel renders AB and BA on the same screen, so the non-commutativity of matrix multiplication is visible at a glance.
  • Matches the textbook dot product rule exactly: C[i][j] = sum over k of A[i][k] * B[k][j] is the rule from the first chapter of any linear algebra text.
  • Works for positive, negative, and decimal entries: Cells can be 0.25, 1.5, -3, or any other real number; the calculation keeps full double precision internally.
  • Quick sanity check before composing with other operations: Use it as a stepping stone to confirm the product of two 2x2 matrices before you plug it into the matrix inverse or a Cramer's rule solution.

If you need the matrix I such that A * I = A and A * A^{-1} = I, the matrix inverse calculator applies the same row-by-column rule to the inverse and the cofactor expansion.

Factors That Affect Your Matrix Product

A handful of input choices and structural facts decide whether the product matrices AB and BA really represent the products of A and B.

Inner dimension match

For a 2x2 by 2x2 product, the inner dimension is 2 in both matrices and the product is also 2x2. With non-square pairs the output shape becomes (rows of A) x (columns of B).

Order of the product

AB and BA are not the same in general. The result panel shows both so you can see whether the two orders differ for your inputs.

Entry signs and magnitudes

Each cell is a sum of signed products, so a row of large positive entries against a column of large negative entries can produce a zero cell.

Decimal precision

Inputs can be decimals like 0.25 or 1.5, and the calculation keeps full double precision internally.

Shape of the outputs

Both the AB and BA panels always show a 2x2 product matrix in the same row and column order as the inputs.

  • The calculator is limited to 2x2 by 2x2 products. For 2x3 times 3x2, 3x3 times 3x3, or other rectangular pairs, the same row-by-column rule applies but you would need a 3x3 or rectangular-shape tool to enter them all.
  • Output values are rounded to four decimal places for display, so a true fraction like 1/3 will appear as 0.3333 in the cell.

According to Wolfram MathWorld, matrix multiplication takes a row of the first matrix and a column of the second matrix as a dot product.

Matrix multiplication calculator showing two 2x2 matrices and the AB and BA products
Matrix multiplication calculator showing two 2x2 matrices and the AB and BA products

Frequently Asked Questions

Q: How do you multiply two matrices?

A: Confirm that the number of columns of the left matrix equals the number of rows of the right matrix. Each cell of the product is the dot product of one row of the left matrix with one column of the right matrix.

Q: What is the rule for matrix multiplication?

A: The rule is C[i][j] = sum over k of A[i][k] * B[k][j], with C of shape m x p when A is m x n and B is n x p. The operation is associative and distributive.

Q: When can two matrices be multiplied together?

A: Two matrices can be multiplied together only when the number of columns of the left matrix equals the number of rows of the right matrix. A 2x2 by 2x2 pair is allowed, and a 2x2 by 2x3 pair is also allowed because the inner dimensions (2 = 2) match, producing a 2x3 product.

Q: Is matrix multiplication commutative?

A: No, matrix multiplication is not commutative in general, so AB and BA can be different. Swapping the order is allowed when both inner dimensions match, but the two products are usually not equal.

Q: What is the size of the product of an m x n matrix and an n x p matrix?

A: The product is an m x p matrix. The shared inner dimension n cancels out, and the output takes the row count of the left matrix and the column count of the right matrix.

Q: Can you multiply a 2x3 matrix by a 3x2 matrix?

A: Yes. The left matrix has 3 columns and the right matrix has 3 rows, so the inner dimension matches, and the product is a 2x2 matrix where each of the four cells is a 3-term dot product of one row of A with one column of B.