MatricesTopic #8 of 30

Matrix Multiplication

Matrix product definition, properties, non-commutativity, and applications.

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×nm \times n matrix AA and an n×pn \times p matrix BB, the product ABAB is an m×pm \times p matrix where:

(AB)ij=k=1naikbkj=ai1b1j+ai2b2j++ainbnj(AB)_{ij} = \sum_{k=1}^{n} a_{ik}b_{kj} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj}

Entry (i,j)(i,j) is the dot product of row ii of AA and column jj of BB.

Dimension Requirements

Am×n×Bn×p=Cm×pA_{m \times n} \times B_{n \times p} = C_{m \times p}

  • Inner dimensions must match: columns of AA = rows of BB
  • Result has: rows of AA × columns of BB

Computation Method

[a11a12a21a22]×[b11b12b21b22]=[a11b11+a12b21a11b12+a12b22a21b11+a22b21a21b12+a22b22]\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}

Example

A=[1234],B=[5678]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \quad B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}

AB=[1×5+2×71×6+2×83×5+4×73×6+4×8]=[19224350]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}

Properties of Matrix Multiplication

PropertyFormula
Associative(AB)C=A(BC)(AB)C = A(BC)
Left DistributiveA(B+C)=AB+ACA(B + C) = AB + AC
Right Distributive(A+B)C=AC+BC(A + B)C = AC + BC
Scalarc(AB)=(cA)B=A(cB)c(AB) = (cA)B = A(cB)
IdentityAI=IA=AAI = IA = A

Non-Commutativity

Important: In general, ABBAAB \neq BA

Example

A=[1000],B=[0100]A = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}

AB=[0100],BA=[0000]AB = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}, \quad BA = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}

Zero Divisors

AB=OAB = O does not imply A=OA = O or B=OB = O.

Example

[1000]×[0010]=[0000]\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}

Powers of Matrices

For square matrix AA:

A2=AAA^2 = AA

A3=AAA=A2AA^3 = AAA = A^2 A

An=A×A××An timesA^n = \underbrace{A \times A \times \cdots \times A}_{n \text{ times}}

A0=IA^0 = I

Matrix-Vector Multiplication

For matrix AA and vector x\mathbf{x}:

Ax=x1(column 1)+x2(column 2)++xn(column n)A\mathbf{x} = x_1(\text{column 1}) + x_2(\text{column 2}) + \cdots + x_n(\text{column } n)

Example

[123456][x1x2x3]=[x1+2x2+3x34x1+5x2+6x3]\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}

Row-Column Interpretation

Row Picture

Each row of ABAB is a linear combination of rows of BB.

Column Picture

Each column of ABAB is a linear combination of columns of AA:

AB=[Ab1Ab2Abp]AB = \begin{bmatrix} A\mathbf{b}_1 & A\mathbf{b}_2 & \cdots & A\mathbf{b}_p \end{bmatrix}

Block Matrix Multiplication

Matrices can be partitioned into blocks:

[A11A12A21A22][B11B12B21B22]=[A11B11+A12B21A11B12+A12B22A21B11+A22B21A21B12+A22B22]\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}

Worked Example

Compute ABAB where:

A=[120312],B=[142301]A = \begin{bmatrix} 1 & 2 & 0 \\ 3 & 1 & 2 \end{bmatrix}, \quad B = \begin{bmatrix} 1 & 4 \\ 2 & 3 \\ 0 & 1 \end{bmatrix}

AA is 2×32 \times 3, BB is 3×23 \times 2, so ABAB is 2×22 \times 2:

AB=[1×1+2×2+0×01×4+2×3+0×13×1+1×2+2×03×4+1×3+2×1]=[510517]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}