Overview
Matrix multiplication is a fundamental operation that combines two matrices to produce a new matrix. Unlike addition, matrix multiplication has specific dimension requirements and is not commutative.
Definition
For an m × n m \times n m × n matrix A A A and an n × p n \times p n × p matrix B B B , the product A B AB A B is an m × p m \times p m × p matrix where:
( A B ) i j = ∑ k = 1 n a i k b k j = a i 1 b 1 j + a i 2 b 2 j + ⋯ + a i n b n j (AB)_{ij} = \sum_{k=1}^{n} a_{ik}b_{kj} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj} ( A B ) ij = ∑ k = 1 n a ik b kj = a i 1 b 1 j + a i 2 b 2 j + ⋯ + a in b nj
Entry ( i , j ) (i,j) ( i , j ) is the dot product of row i i i of A A A and column j j j of B B B .
Dimension Requirements
A m × n × B n × p = C m × p A_{m \times n} \times B_{n \times p} = C_{m \times p} A m × n × B n × p = C m × p
Inner dimensions must match: columns of A A A = rows of B B B
Result has: rows of A A A × columns of B B B
Computation Method
[ a 11 a 12 a 21 a 22 ] × [ b 11 b 12 b 21 b 22 ] = [ a 11 b 11 + a 12 b 21 a 11 b 12 + a 12 b 22 a 21 b 11 + a 22 b 21 a 21 b 12 + a 22 b 22 ] \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \times \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix} = \begin{bmatrix} a_{11}b_{11}+a_{12}b_{21} & a_{11}b_{12}+a_{12}b_{22} \\ a_{21}b_{11}+a_{22}b_{21} & a_{21}b_{12}+a_{22}b_{22} \end{bmatrix} [ a 11 a 21 a 12 a 22 ] × [ b 11 b 21 b 12 b 22 ] = [ a 11 b 11 + a 12 b 21 a 21 b 11 + a 22 b 21 a 11 b 12 + a 12 b 22 a 21 b 12 + a 22 b 22 ]
Example
A = [ 1 2 3 4 ] , B = [ 5 6 7 8 ] A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \quad B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} A = [ 1 3 2 4 ] , B = [ 5 7 6 8 ]
A B = [ 1 × 5 + 2 × 7 1 × 6 + 2 × 8 3 × 5 + 4 × 7 3 × 6 + 4 × 8 ] = [ 19 22 43 50 ] AB = \begin{bmatrix} 1 \times 5 + 2 \times 7 & 1 \times 6 + 2 \times 8 \\ 3 \times 5 + 4 \times 7 & 3 \times 6 + 4 \times 8 \end{bmatrix} = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} A B = [ 1 × 5 + 2 × 7 3 × 5 + 4 × 7 1 × 6 + 2 × 8 3 × 6 + 4 × 8 ] = [ 19 43 22 50 ]
Properties of Matrix Multiplication
Property Formula Associative ( A B ) C = A ( B C ) (AB)C = A(BC) ( A B ) C = A ( BC ) Left Distributive A ( B + C ) = A B + A C A(B + C) = AB + AC A ( B + C ) = A B + A C Right Distributive ( A + B ) C = A C + B C (A + B)C = AC + BC ( A + B ) C = A C + BC Scalar c ( A B ) = ( c A ) B = A ( c B ) c(AB) = (cA)B = A(cB) c ( A B ) = ( c A ) B = A ( c B ) Identity A I = I A = A AI = IA = A A I = I A = A
Non-Commutativity
Important : In general, A B ≠ B A AB \neq BA A B = B A
Example
A = [ 1 0 0 0 ] , B = [ 0 1 0 0 ] A = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} A = [ 1 0 0 0 ] , B = [ 0 0 1 0 ]
A B = [ 0 1 0 0 ] , B A = [ 0 0 0 0 ] AB = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}, \quad BA = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} A B = [ 0 0 1 0 ] , B A = [ 0 0 0 0 ]
Zero Divisors
A B = O AB = O A B = O does not imply A = O A = O A = O or B = O B = O B = O .
Example
[ 1 0 0 0 ] × [ 0 0 1 0 ] = [ 0 0 0 0 ] \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} [ 1 0 0 0 ] × [ 0 1 0 0 ] = [ 0 0 0 0 ]
Powers of Matrices
For square matrix A A A :
A 2 = A A A^2 = AA A 2 = AA
A 3 = A A A = A 2 A A^3 = AAA = A^2 A A 3 = AAA = A 2 A
A n = A × A × ⋯ × A ⏟ n times A^n = \underbrace{A \times A \times \cdots \times A}_{n \text{ times}} A n = n times A × A × ⋯ × A
A 0 = I A^0 = I A 0 = I
Matrix-Vector Multiplication
For matrix A A A and vector x \mathbf{x} x :
A x = x 1 ( column 1 ) + x 2 ( column 2 ) + ⋯ + x n ( column n ) A\mathbf{x} = x_1(\text{column 1}) + x_2(\text{column 2}) + \cdots + x_n(\text{column } n) A x = x 1 ( column 1 ) + x 2 ( column 2 ) + ⋯ + x n ( column n )
Example
[ 1 2 3 4 5 6 ] [ x 1 x 2 x 3 ] = [ x 1 + 2 x 2 + 3 x 3 4 x 1 + 5 x 2 + 6 x 3 ] \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} x_1 + 2x_2 + 3x_3 \\ 4x_1 + 5x_2 + 6x_3 \end{bmatrix} [ 1 4 2 5 3 6 ] x 1 x 2 x 3 = [ x 1 + 2 x 2 + 3 x 3 4 x 1 + 5 x 2 + 6 x 3 ]
Row-Column Interpretation
Row Picture
Each row of A B AB A B is a linear combination of rows of B B B .
Column Picture
Each column of A B AB A B is a linear combination of columns of A A A :
A B = [ A b 1 A b 2 ⋯ A b p ] AB = \begin{bmatrix} A\mathbf{b}_1 & A\mathbf{b}_2 & \cdots & A\mathbf{b}_p \end{bmatrix} A B = [ A b 1 A b 2 ⋯ A b p ]
Block Matrix Multiplication
Matrices can be partitioned into blocks:
[ A 11 A 12 A 21 A 22 ] [ B 11 B 12 B 21 B 22 ] = [ A 11 B 11 + A 12 B 21 A 11 B 12 + A 12 B 22 A 21 B 11 + A 22 B 21 A 21 B 12 + A 22 B 22 ] \begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22} \end{bmatrix} \begin{bmatrix} B_{11} & B_{12} \\ B_{21} & B_{22} \end{bmatrix} = \begin{bmatrix} A_{11}B_{11}+A_{12}B_{21} & A_{11}B_{12}+A_{12}B_{22} \\ A_{21}B_{11}+A_{22}B_{21} & A_{21}B_{12}+A_{22}B_{22} \end{bmatrix} [ A 11 A 21 A 12 A 22 ] [ B 11 B 21 B 12 B 22 ] = [ A 11 B 11 + A 12 B 21 A 21 B 11 + A 22 B 21 A 11 B 12 + A 12 B 22 A 21 B 12 + A 22 B 22 ]
Worked Example
Compute A B AB A B where:
A = [ 1 2 0 3 1 2 ] , B = [ 1 4 2 3 0 1 ] A = \begin{bmatrix} 1 & 2 & 0 \\ 3 & 1 & 2 \end{bmatrix}, \quad B = \begin{bmatrix} 1 & 4 \\ 2 & 3 \\ 0 & 1 \end{bmatrix} A = [ 1 3 2 1 0 2 ] , B = 1 2 0 4 3 1
A A A is 2 × 3 2 \times 3 2 × 3 , B B B is 3 × 2 3 \times 2 3 × 2 , so A B AB A B is 2 × 2 2 \times 2 2 × 2 :
A B = [ 1 × 1 + 2 × 2 + 0 × 0 1 × 4 + 2 × 3 + 0 × 1 3 × 1 + 1 × 2 + 2 × 0 3 × 4 + 1 × 3 + 2 × 1 ] = [ 5 10 5 17 ] AB = \begin{bmatrix} 1 \times 1 + 2 \times 2 + 0 \times 0 & 1 \times 4 + 2 \times 3 + 0 \times 1 \\ 3 \times 1 + 1 \times 2 + 2 \times 0 & 3 \times 4 + 1 \times 3 + 2 \times 1 \end{bmatrix} = \begin{bmatrix} 5 & 10 \\ 5 & 17 \end{bmatrix} A B = [ 1 × 1 + 2 × 2 + 0 × 0 3 × 1 + 1 × 2 + 2 × 0 1 × 4 + 2 × 3 + 0 × 1 3 × 4 + 1 × 3 + 2 × 1 ] = [ 5 5 10 17 ]