Calculators.Life Calculator
Math

Matrix Multiplication Calculator

Input Parameters

Scenarios
Number of rows in Matrix A
Number of columns in Matrix A
Number of rows in Matrix B (must match Matrix A columns)
Number of columns in Matrix B

Computed Results

Product Matrix (A · B)
[[55, 64], [12, 15]]
Result Dimensions2 × 2
C[1,1]55
C[1,2]64
C[2,1]12
C[2,2]15

The Matrix Multiplication Calculator determines the product of two matrices. By inputting the dimensions and elements of Matrix A and Matrix B, you can quickly find the resulting matrix and its dimensions, provided the number of columns in the first matrix matches the number of rows in the second.

Practical Use Cases

Matrix multiplication is a fundamental operation in linear algebra used across various fields. It is essential for solving systems of linear equations, transforming geometric coordinates in computer graphics, and processing data in machine learning algorithms. This calculator simplifies the process by handling the arithmetic required to multiply rows by columns.

How to Use the Calculator

Follow these steps to multiply two matrices:

  1. Enter the number of rows and columns for Matrix A.
  2. Input the individual elements for Matrix A.
  3. Enter the number of rows and columns for Matrix B. Note that the number of rows in Matrix B must exactly match the number of columns in Matrix A.
  4. Input the individual elements for Matrix B.
  5. Review the calculated Product Matrix and the Result Dimensions.

Matrix Multiplication Formula

To multiply Matrix A by Matrix B, the number of columns in A must equal the number of rows in B. If Matrix A is an m × n matrix and Matrix B is an n × p matrix, the resulting Matrix C will be an m × p matrix.

Each element in the resulting matrix is calculated by taking the dot product of a row from Matrix A and a column from Matrix B:

C[i,j] = (A[i,1] × B[1,j]) + (A[i,2] × B[2,j]) + ... + (A[i,n] × B[n,j])

Verified Scenario Walkthroughs

Simple 1x1 scalar multiplication

If Matrix A is a 1 × 1 matrix with the value 5, and Matrix B is a 1 × 1 matrix with the value 10, the resulting 1 × 1 matrix is [[50]].

Standard 2x2 matrix multiplication

Consider a 2 × 2 Matrix A with elements [[1, 2], [3, 4]] and a 2 × 2 Matrix B with elements [[5, 6], [7, 8]]. The resulting 2 × 2 matrix is [[19, 22], [43, 50]].

Rectangular matrix multiplication 3x2 by 2x3

Multiplying a 3 × 2 Matrix A by a 2 × 3 Matrix B yields a 3 × 3 matrix. Using the provided inputs, the result is [[1, 2, 0], [3, 4, 0], [0, 0, 0]].

Invalid dimension mismatch error check

If you attempt to multiply a 2 × 3 Matrix A by a 2 × 2 Matrix B, the calculator will return an error: "Error: Matrix A columns (3) must equal Matrix B rows (2)." The result dimensions will be undefined.

Inputs and Outputs

FieldTypeDescription
Matrix A RowsInputNumber of rows in Matrix A
Matrix A ColumnsInputNumber of columns in Matrix A
Matrix B RowsInputNumber of rows in Matrix B (must match Matrix A columns)
Matrix B ColumnsInputNumber of columns in Matrix B
Product Matrix (A · B)OutputThe resulting matrix after multiplication
Result DimensionsOutputThe dimensions (rows × columns) of the product matrix

Frequently Asked Questions

Why must the columns of Matrix A match the rows of Matrix B?

Matrix multiplication requires taking the dot product of rows from the first matrix and columns from the second. This operation is only mathematically possible if the number of elements in a row of Matrix A equals the number of elements in a column of Matrix B.

Is matrix multiplication commutative?

No, matrix multiplication is generally not commutative. Multiplying Matrix A by Matrix B (A · B) does not typically yield the same result as multiplying Matrix B by Matrix A (B · A), and in many cases, the reverse operation may not even be possible due to dimension mismatches.

Author portrait
About the Author
Arnab Biswas

Calculator developer and SEO strategist who builds practical online calculators and tests calculation logic, input handling, and expected results using real-world scenarios.