Matrix Multiplication Calculator
Use this tool to multiply matrices of compatible dimensions. Enter your matrices and get instant results with step-by-step explanations.
Matrix A
Matrix B
Understanding Matrix Multiplication
What is Matrix Multiplication?
Matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication to be defined, the number of columns in the first matrix must equal the number of rows in the second matrix. If matrix A is an m×n matrix and matrix B is an n×p matrix, then their matrix product AB will be an m×p matrix.
How Matrix Multiplication Works
Matrix multiplication is not performed by simply multiplying corresponding entries. Instead, each entry in the product matrix is computed as the dot product of the corresponding row from the first matrix and the corresponding column from the second matrix.
Specifically, if A = [aᵢⱼ] is an m×n matrix and B = [bⱼₖ] is an n×p matrix, then the product C = AB is an m×p matrix where:
cᵢₖ = Σⱼ=₁→n aᵢⱼ × bⱼₖ
for i = 1, 2, ..., m and k = 1, 2, ..., p.
Properties of Matrix Multiplication
- Associativity: (AB)C = A(BC)
- Distributivity: A(B + C) = AB + AC and (A + B)C = AC + BC
- Compatibility with scalar multiplication: λ(AB) = (λA)B = A(λB)
- Non-commutativity: In general, AB ≠ BA
- Identity matrix multiplication: IA = A and AI = A
Step-by-Step Example
Let's multiply two 2×2 matrices:
Matrix A = \(\begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix}\) , Matrix B = \(\begin{bmatrix} 5 & 6 \\ 7 & 8 \\ \end{bmatrix}\)
Step 1: Check if multiplication is possible. A is 2×2, B is 2×2, so the product will be 2×2.
Step 2: Calculate each element of the result matrix:
- Element (1,1): (1×5) + (2×7) = 5 + 14 = 19
- Element (1,2): (1×6) + (2×8) = 6 + 16 = 22
- Element (2,1): (3×5) + (4×7) = 15 + 28 = 43
- Element (2,2): (3×6) + (4×8) = 18 + 32 = 50
Result: AB = \(\begin{bmatrix} 19 & 22 \\ 43 & 50 \\ \end{bmatrix}\)
Applications of Matrix Multiplication
Matrix multiplication has numerous applications across various fields:
- Computer Graphics: Transforming 2D and 3D objects (translation, rotation, scaling)
- Physics: Quantum mechanics, optics, and electrical circuits
- Economics: Input-output models in economics
- Statistics: Multivariate analysis and regression
- Engineering: Control systems, signal processing, and structural analysis
- Computer Science: Graph algorithms, data compression, and machine learning
Special Types of Matrix Multiplication
There are several specialized forms of matrix multiplication:
- Element-wise multiplication (Hadamard product): Cᵢⱼ = Aᵢⱼ × Bᵢⱼ
- Kronecker product (Tensor product): A block matrix where each block is a scaled copy of B
- Dot product: For vectors, results in a scalar
- Cross product: For 3D vectors, results in another vector
Frequently Asked Questions About Matrix Multiplication Calculator
Why can't we multiply matrices of any dimensions?
Matrix multiplication is only defined when the number of columns in the first matrix equals the number of rows in the second matrix. This is because each element in the product matrix is calculated as the dot product of a row from the first matrix and a column from the second matrix, which requires that they have the same number of elements.
Is matrix multiplication commutative?
No, matrix multiplication is not commutative. In general, AB ≠ BA. This is one of the most important differences between matrix multiplication and multiplication of real numbers.
What is the identity matrix in matrix multiplication?
The identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere. When any matrix is multiplied by the identity matrix (of appropriate size), the result is the original matrix. For example, if A is an m×n matrix, then IₘA = A and AIₙ = A.
Can I multiply more than two matrices together?
Yes, you can multiply multiple matrices together as long as their dimensions are compatible. Matrix multiplication is associative, meaning (AB)C = A(BC), so the order of multiplication doesn't change the result (though the actual computation might be more efficient in one order than another).
What is the computational complexity of matrix multiplication?
The standard matrix multiplication algorithm for two n×n matrices has a time complexity of O(n³). However, more efficient algorithms like Strassen's algorithm (O(n²·⁸¹)) and Coppersmith-Winograd algorithm (O(n²·³⁷⁶)) exist, though they are rarely used in practice due to large constant factors.
How is matrix multiplication used in machine learning?
In machine learning, matrix multiplication is fundamental to many algorithms. Neural networks use matrix multiplication to propagate values through layers, with weights stored in matrices. Other applications include principal component analysis (PCA), linear regression, and support vector machines (SVMs).