How to multiply matrices
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- Matrix multiplication requires the inner dimensions to match: columns of the first matrix must equal rows of the second.
- If matrix A is m x n and matrix B is n x p, the product matrix C will be m x p.
- Each element C_ij of the product matrix is the sum of the products of corresponding elements from the i-th row of A and the j-th column of B.
- Matrix multiplication is not commutative, meaning AB is generally not equal to BA.
- The process involves row-by-column multiplication and summation.
Overview
Matrix multiplication is a fundamental operation in linear algebra with applications ranging from computer graphics and data analysis to physics and engineering. Unlike scalar multiplication (multiplying a matrix by a single number), matrix multiplication involves combining two matrices to produce a third. This operation is not as straightforward as adding or subtracting matrices; it follows a specific set of rules that dictate which matrices can be multiplied and how the resulting matrix is formed.
The core concept revolves around the compatibility of dimensions and a systematic process of calculation. Understanding this process is crucial for anyone working with mathematical models, transformations, or large datasets where matrices are commonly used to represent complex relationships.
What are Matrices?
Before diving into multiplication, it's essential to understand what a matrix is. A matrix is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. For example:
$$ A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \quad B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} $$
The dimensions of a matrix are described by the number of rows and columns it has. The matrix A above is a 2x2 matrix (2 rows, 2 columns). The matrix B above is also a 2x2 matrix.
Conditions for Matrix Multiplication
The most critical rule for multiplying two matrices, say matrix A and matrix B, is that the number of columns in the first matrix (A) must be equal to the number of rows in the second matrix (B). If A has dimensions $m \times n$ (m rows, n columns) and B has dimensions $p \times q$ (p rows, q columns), then multiplication $A \times B$ is only possible if $n = p$.
If this condition is met, the resulting matrix, let's call it C, will have dimensions corresponding to the outer dimensions of A and B: $m \times q$.
For example:
- If A is $2 \times 3$ and B is $3 \times 4$, then $A \times B$ is possible. The resulting matrix C will be $2 \times 4$.
- If A is $3 \times 2$ and B is $3 \times 4$, then $A \times B$ is NOT possible because the number of columns in A (2) does not equal the number of rows in B (3).
How to Perform Matrix Multiplication (The Process)
Once you've confirmed that the matrices can be multiplied, the calculation of each element in the resulting matrix C involves a specific procedure. To find the element in the i-th row and j-th column of C (denoted as $C_{ij}$), you perform the following steps:
- Take the i-th row of matrix A.
- Take the j-th column of matrix B.
- Multiply the first element of the i-th row of A by the first element of the j-th column of B.
- Multiply the second element of the i-th row of A by the second element of the j-th column of B.
- Continue this for all corresponding elements in the row and column.
- Sum up all these products. This sum is the value of $C_{ij}$.
This process is repeated for every element in the resulting matrix C.
Example Calculation
Let's multiply the matrices A and B from our earlier example:
$$ A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \quad B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} $$
Both are 2x2 matrices, so the number of columns in A (2) equals the number of rows in B (2). The resulting matrix C will be 2x2.
Let's find $C_{11}$ (the element in the 1st row, 1st column):
- 1st row of A: (1, 2)
- 1st column of B: (5, 7)
- Calculation: $(1 \times 5) + (2 \times 7) = 5 + 14 = 19$. So, $C_{11} = 19$.
Let's find $C_{12}$ (the element in the 1st row, 2nd column):
- 1st row of A: (1, 2)
- 2nd column of B: (6, 8)
- Calculation: $(1 \times 6) + (2 \times 8) = 6 + 16 = 22$. So, $C_{12} = 22$.
Let's find $C_{21}$ (the element in the 2nd row, 1st column):
- 2nd row of A: (3, 4)
- 1st column of B: (5, 7)
- Calculation: $(3 \times 5) + (4 \times 7) = 15 + 28 = 43$. So, $C_{21} = 43$.
Let's find $C_{22}$ (the element in the 2nd row, 2nd column):
- 2nd row of A: (3, 4)
- 2nd column of B: (6, 8)
- Calculation: $(3 \times 6) + (4 \times 8) = 18 + 32 = 50$. So, $C_{22} = 50$.
Therefore, the resulting matrix C is:
$$ C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix} $$
Important Properties of Matrix Multiplication
Matrix multiplication has several key properties that are important to remember:
- Associative Property: For matrices A, B, and C, if the multiplications are defined, then $(AB)C = A(BC)$.
- Distributive Property: If A, B, and C are matrices such that the operations are defined, then $A(B+C) = AB + AC$ and $(A+B)C = AC + BC$.
- Non-Commutative Property: This is a crucial distinction from scalar multiplication. In general, $AB \neq BA$. Even if both $AB$ and $BA$ are defined (which happens when A and B are square matrices of the same size), the results are usually different.
- Multiplication by Identity Matrix: The identity matrix (denoted by I) is a square matrix with ones on the main diagonal and zeros elsewhere. For any matrix A, $AI = IA = A$, provided the dimensions are compatible.
- Multiplication by Zero Matrix: If O is a zero matrix (all entries are zero), then $AO = OA = O$.
Applications in Daily Life
While matrix multiplication might seem abstract, it underpins many technologies we use daily:
- Computer Graphics: Transformations like rotation, scaling, and translation of 3D models in video games and animation software rely heavily on matrix multiplication.
- Image Processing: Applying filters, adjusting brightness or contrast, and performing other image manipulations often use matrix operations.
- Data Analysis and Machine Learning: Algorithms for recommendation systems (like those used by Netflix or Amazon), natural language processing, and various machine learning models extensively use matrix multiplication for calculations involving large datasets.
- Economics and Finance: Modeling economic systems, portfolio management, and risk analysis often involve matrix operations.
- Cryptography: Certain encryption and decryption methods utilize matrix transformations.
Understanding how to multiply matrices provides a foundational skill for comprehending these advanced applications and for tackling problems involving transformations and data representation.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- Matrix multiplication - WikipediaCC-BY-SA-4.0
- 3.02: Matrix Multiplication - LibreTextsCC BY-NC-SA 3.0
- Matrix multiplication (article) | Khan Academyfair-use
Missing an answer?
Suggest a question and we'll generate an answer for it.