Matrix multiplication is an operation that combines two matrices when the number of columns in the first matrix equals the number of rows in the second. If matrix A has dimensions m × n and matrix B has dimensions n × p, their product AB has dimensions m × p. Each element of the resulting matrix is calculated by taking the dot product of a row from the first matrix and a column from the second. Matrix multiplication is generally not commutative, meaning AB is not necessarily equal to BA. In linear algebra, a matrix can also represent a linear transformation that maps an input vector to an output vector. Such transformations can perform operations such as rotation, reflection, scaling, and projection. In machine learning, matrices transform feature vectors and intermediate representations. Neural network layers use weight matrices to combine input features and generate new representations. The order of transformations matters because applying one transformation before another can produce a different result. Understanding dimensions, multiplication order, and transformation properties is therefore essential for implementing mathematical models correctly.
Matrix Multiplication and Transformations
An explanation of matrix multiplication and how matrices represent transformations that change vectors and other numerical data.
Cᵢⱼ = Σₖ AᵢₖBₖⱼ
Explanation
Variables
| Symbol | Meaning |
|---|---|
A | The first matrix in the multiplication. |
B | The second matrix in the multiplication. |
C | The product matrix AB. |
Cᵢⱼ | The element in row i and column j of the product matrix. |
Aᵢₖ | The element in row i and column k of matrix A. |
Bₖⱼ | The element in row k and column j of matrix B. |
Σₖ | Summation over the shared dimension k. |
Example or application
Let A = [[1, 2], [3, 4]] and B = [[2, 0], [1, 2]]. Their product AB is [[4, 4], [10, 8]]. The first element is calculated as (1 × 2) + (2 × 1) = 4.
Text
Matrix multiplication combines compatible matrices through row-by-column calculations. The inner dimensions must match, and the resulting matrix takes its outer dimensions. A matrix can also represent a linear transformation that changes a vector's representation through operations such as rotation, scaling, reflection, or projection. These operations are widely used in neural networks, computer graphics, and machine learning data processing.
Key Points
Matrix multiplication uses row-by-column calculations.
The number of columns in the first matrix must equal the number of rows in the second.
An m × n matrix multiplied by an n × p matrix produces an m × p matrix.
Matrix multiplication is generally not commutative.
Matrices can represent linear transformations.
Common transformations include rotation, scaling, reflection, and projection.
The order of transformations can affect the final result.
Neural network layers use matrix multiplication to transform feature representations.
Applications
Neural network forward propagation
Computer graphics and geometric transformations
Image processing
Feature transformation in machine learning
Dimensionality reduction
Robotics and coordinate transformations
Scientific computing
Learning Outcomes
Determine whether two matrices can be multiplied.
Calculate the dimensions of a matrix product.
Perform row-by-column matrix multiplication.
Explain why multiplication order matters.
Describe how matrices represent linear transformations.
Practice Questions
What condition is required for matrix multiplication?
What are the dimensions of the product of an m × n matrix and an n × p matrix?
Why is matrix multiplication generally not commutative?
How can a matrix represent a geometric transformation?
How is matrix multiplication used in a neural network?
Related Concepts
Matrices and Matrix Operations
Linear Transformations
Vectors and Vector Operations
Neural Network Forward Propagation
Coordinate Systems
Common Mistakes
Multiplying matrices with incompatible dimensions.
Using element-wise multiplication when standard matrix multiplication is required.
Assuming AB always equals BA.
Ignoring the order of transformations.
Confusing the dimensions of the input matrices with the dimensions of their product.
Sources and verification
Sources are shown as provided in the project data. Not every source has yet been independently verified. Please report errors or missing citations.
- Strang, G. Introduction to Linear Algebra.
- Deisenroth, M. P., Faisal, A. A., and Ong, C. S. Mathematics for Machine Learning.
Suggest a correction or source · More in Artificial Intelligence & Machine Learning