Matrix Multiplication Calculator

📚 Confused about how this is calculated? Read the full Why Matrix Multiplication Works So Strangely →

Not Just Multiplying Matching Cells

Matrix multiplication trips people up precisely because it isn't element-by-element like addition or subtraction — each entry in the result is a full dot product between a row of the first matrix and a column of the second. That single difference is what lets matrices represent chained transformations, not just paired data.

The Formula

C = A × B, where Cij = Σ(Aik × Bkj)

Worked Example

For A = [1, 2; 3, 4] and B = [5, 6; 7, 8]:

Matrix multiplication, entry by entry
EntryCalculationResult
C11(1×5) + (2×7)19
C12(1×6) + (2×8)22
C21(3×5) + (4×7)43
C22(3×6) + (4×8)50

Result matrix: [19, 22; 43, 50].

Where This Matters

  • Chaining transformations — combining a rotation and a scaling into a single transformation matrix in computer graphics or robotics.
  • Neural networks — every layer of a neural network multiplies an input matrix by a weight matrix as its core operation.
  • Markov chains — multiplying a state vector by a transition matrix predicts the next state in probabilistic models.
Note: Matrix multiplication is not commutative — A × B generally does not equal B × A, even when both products are defined.

How to Use This Calculator

  1. Choose the matrix size: 2 x 2 Matrices or 3 x 3 Matrices.
  2. Enter each cell of Matrix A.
  3. Enter each cell of Matrix B.
  4. Select Calculate to get the product matrix.

Related Calculations

Undo a transformation with the Matrix Inverse Calculator, or combine matrices additively instead with the Matrix Addition Calculator.

Principles of Matrix Multiplication and Linear Transformations

In linear algebra, matrix multiplication is the foundational algebraic operation representing the composition of linear geometric transformations. Unlike simple scalar arithmetic or element-wise Hadamard multiplication, matrix multiplication computes the systematic inner dot products between the horizontal row vectors of the first matrix and the vertical column vectors of the second matrix.

Dimension Conformability Requirements

Two matrices A and B can be multiplied to form product C = A × B if and only if the number of columns in matrix A strictly equals the number of rows in matrix B:

Matrix A (m × p) × Matrix B (p × n) = Result Matrix C (m × n)

Each entry Cij in the resulting m×n product matrix is computed as:

Cij = ∑k=1p ( Aik × Bkj ) = Ai1B1j + Ai2B2j + … + AipBpj

Fundamental Algebraic Properties

  • Non-Commutative: Matrix multiplication is generally non-commutative: A × B ≠ B × A (order of operations matters).
  • Associativity: (A × B) × C = A × (B × C).
  • Distributivity: A × (B + C) = (A × B) + (A × C).
  • Transpose Identity: (A × B)T = BT × AT (note the reversed order).

Step-by-Step Worked Calculation Example

Example: Multiplying a 2x3 Matrix by a 3x2 Matrix

Problem: Calculate the matrix product C = A × B for:

Matrix A (2×3) = [ [1, 2, 3], [4, 5, 6] ]

Matrix B (3×2) = [ [7, 8], [9, 1], [2, 3] ]

Step 1: Verify conformability: (2×3) × (3×2) &implies; Valid! Result C is a 2×2 matrix.

Step 2: Calculate Row 1 entries:

C11 = (1 × 7) + (2 × 9) + (3 × 2) = 7 + 18 + 6 = 31

C12 = (1 × 8) + (2 × 1) + (3 × 3) = 8 + 2 + 9 = 19

Step 3: Calculate Row 2 entries:

C21 = (4 × 7) + (5 × 9) + (6 × 2) = 28 + 45 + 12 = 85

C22 = (4 × 8) + (5 × 1) + (6 × 3) = 32 + 5 + 18 = 55

Product Matrix C (2×2):
[ [31, 19],
  [85, 55] ]

Conclusion: C = [ [31, 19], [85, 55] ].

Computational Algorithms: Strassen's Matrix Multiplication

Standard matrix multiplication requires O(n³) arithmetic operations. In 1969, Volker Strassen published Strassen's Algorithm, which computes 2×2 block matrix products using only 7 multiplications instead of 8, reducing computational complexity to O(nlog2 7) ≈ O(n2.807), accelerating deep learning transformer models on modern GPUs.

Homogeneous Coordinates and 3D Graphics Transformations

In 3D computer graphics engines (such as Unreal Engine, Unity, and OpenGL/DirectX APIs), geometric operations on 3D vertices (translation, rotation, scaling, and perspective projection) are unified into single matrix multiplications by using 4×4 Homogeneous Transformation Matrices:

Vertex' = MPerspective × MView × MModel × Vertex4×1

By chaining transformations via matrix multiplication (MVP Matrix), the GPU transforms millions of 3D polygon vertices per frame into 2D screen pixels through a single composite matrix multiplication.

Markov Chain State Transition Matrix Powers (Pn)

In stochastic modeling and probability theory, a discrete Markov Chain is represented by an n×n Transition Probability Matrix P (where entry Pij is the probability of transitioning from state i to state j).

The probability distribution of states after n discrete time steps is computed by taking the n-th matrix power of matrix P:

State Vector πn = π0 × Pn

As n → ∞, for an ergodic Markov chain, Pn converges to a stationary equilibrium matrix (π × P = π), used by Google's PageRank algorithm to rank the relevance of billions of web pages.

Tensor Contractions and Einstein Summation Convention

In theoretical physics and deep learning tensor processing (such as PyTorch and TensorFlow), matrix multiplication generalizes into Tensor Contractions expressed via Einstein summation notation: Cij = Aik Bkj, contracting over matching indices in multi-dimensional convolutional layers.

Graph Adjacency Paths and Matrix Powers (Ak)

In graph theory and network routing analysis, let A be the n×n binary adjacency matrix of an unweighted network graph. Raising the adjacency matrix to the k-th power via repeated matrix multiplication (M = Ak) yields a matrix where entry Mij equals the exact total number of distinct paths of length k connecting node i to node j. This mathematical property allows telecommunications routing algorithms to calculate network connectivity and multi-hop paths instantaneously.

Covariance Matrix Computation in Data Analytics

In machine learning and statistics, if data matrix X (n observations × p features) is mean-centered, the complete p×p feature covariance matrix is computed via a single matrix multiplication:

Σ = [ 1 / (n - 1) ] × ( XT × X )

This matrix product serves as the direct mathematical input for Principal Component Analysis (PCA) dimensionality reduction algorithms.

Quantum Computing: Unitary Matrix Gate Operations

In quantum information science, the state of an n-qubit quantum register is represented as a complex state vector ψ inhabiting a 2n-dimensional complex Hilbert space. Quantum computation is executed by multiplying the state vector by a sequence of 2n × 2n Unitary Transformation Matrices (Quantum Gates, U):

final〉 = ( Uk × … × U2 × U1 ) × |ψinitial

Because quantum gates are unitary (U × U = I), composite quantum gate algorithms preserve total quantum probability amplitude across universal quantum algorithms.

Co-Occurrence Matrices in Texture Analysis

In digital medical image pathology, Gray-Level Co-Occurrence Matrices (GLCM) are multiplied with spatial spatial offset filters to compute statistical Haralick texture features (contrast, energy, homogeneity, and entropy), assisting oncologists in automated cancerous tissue classification.

Fast Fourier Transform (FFT) Matrix Factorization

The Cooley-Tukey FFT algorithm factors the dense n×n Discrete Fourier Transform matrix into log2(n) sparse butterfly matrix multiplications, reducing signal processing algorithmic complexity from O(n²) down to O(n log n).

Systolic Array Hardware Acceleration

Modern AI hardware accelerators (such as Google Tensor Processing Units TPUs) execute massive 2D matrix multiplications using hardware systolic arrays with thousands of parallel multiply-accumulate (MAC) execution units.