Chapter 02

Matrix Operations

00 · Symbol Glossary

$A$uppercase A — matrix

An uppercase letter denoting a matrix. Matrices extend vectors: a vector is a single column of numbers; a matrix is a rectangular grid. Bold uppercase is sometimes written A\mathbf{A}, but plain uppercase AA is equally standard — context makes it clear.

$a_{ij}$a sub i j — matrix entry

The entry of matrix AA in row ii, column jj. Read aloud as "a-i-j." The first subscript is always the row, the second is always the column — row then column, always. a23a_{23} is in row 2, column 3.

$m \times n$m by n — matrix dimensions

The dimensions of a matrix: mm rows and nn columns. An m×nm \times n matrix has mnmn entries total. Read aloud as "m by n." When dimensions appear in a product, the inner dimensions must match.

$\mathbb{R}^{m \times n}$R-m-by-n — matrix space

The set of all m×nm \times n matrices with real entries. Extends Rn\mathbb{R}^n from Chapter 1: a vector in Rn\mathbb{R}^n is an element of Rn×1\mathbb{R}^{n \times 1}. Addition and scalar multiplication on Rm×n\mathbb{R}^{m \times n} satisfy the same 8 vector space axioms.

$A^T$A transpose — matrix transpose

The matrix formed by flipping AA across its main diagonal: rows become columns, columns become rows. (AT)ij=aji(A^T)_{ij} = a_{ji}. Chapter 1 defined transpose for vectors; this is the same operation extended to full matrices.

$AB$A B — matrix product

The product of matrices AA and BB, computed via row-by-column dot products. Not component-wise multiplication. The entry (AB)ij(AB)_{ij} equals the dot product of row ii of AA with column jj of BB. Order matters — ABBAAB \neq BA in general.

$I_n$I sub n — identity matrix

The n×nn \times n identity matrix: ones on the main diagonal, zeros everywhere else. AIn=AAI_n = A and ImA=AI_m A = A for any m×nm \times n matrix AA — multiplication by II leaves the matrix unchanged, just as multiplication by 1 leaves a scalar unchanged.

$\text{tr}(A)$trace of A

The sum of the diagonal entries of a square matrix: tr(A)=a11+a22++ann\text{tr}(A) = a_{11} + a_{22} + \cdots + a_{nn}. Only defined for square matrices. In Chapter 6 it will reappear as the sum of the eigenvalues — a fundamental connection between entries and structure.


01 · What is a Matrix

A vector organises a list of numbers into one column. A matrix organises numbers into a rectangular grid — mm rows and nn columns. Every quant operation on multi-dimensional data eventually becomes a matrix operation: a portfolio of nn assets observed over mm days is an m×nm \times n matrix, each row a snapshot and each column an asset's history.

Definition — Matrix

An m×nm \times n matrix AA over R\mathbb{R} is a rectangular array of real numbers with mm rows and nn columns:

A=(a11a12a1na21a22a2nam1am2amn)Rm×nA = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{pmatrix} \in \mathbb{R}^{m \times n}

aija_{ij} — the entry in row ii, column jj. First index is row, second is column.

\ddots — diagonal dots meaning the pattern continues in both directions.

m×nm \times n — read "m by n." The number of rows comes first, always.

✓ Example — Portfolio Returns Matrix

A fund tracks 3 assets over 4 trading days. Returns (in percent) are stored as a 4×34 \times 3 matrix — 4 days (rows), 3 assets (columns):

R=(1.20.52.10.31.80.40.70.91.22.31.10.8)R4×3R = \begin{pmatrix} 1.2 & -0.5 & 2.1 \\ -0.3 & 1.8 & 0.4 \\ 0.7 & 0.9 & -1.2 \\ 2.3 & -1.1 & 0.8 \end{pmatrix} \in \mathbb{R}^{4 \times 3}

r13=2.1r_{13} = 2.1 — day 1, asset 3 returned 2.1%2.1\%. r42=1.1r_{42} = -1.1 — day 4, asset 2 returned 1.1%-1.1\%. The row index names the day, the column index names the asset.

❌ Confusion — Row Index vs Column Index

Reading a32a_{32} as row 2, column 3 is wrong. The subscript order is row-then-column without exception. For the matrix A=(725914)A = \begin{pmatrix}7&2\\5&9\\1&4\end{pmatrix}: a32=4a_{32} = 4 (row 3, column 2), not a23=9a_{23} = 9 (row 2, column 3). Swapping the indices retrieves a completely different entry.


02 · Matrix Addition and Scalar Multiplication

Matrix addition and scalar multiplication work entry-by-entry — the same pattern as vector operations from Chapter 1, now applied to every slot in the grid.

Definition — Matrix Addition

For A,BRm×nA, B \in \mathbb{R}^{m \times n}, their sum A+BRm×nA + B \in \mathbb{R}^{m \times n} is defined entry-by-entry:

(A+B)ij=aij+bij(A + B)_{ij} = a_{ij} + b_{ij}

Both matrices must have identical dimensions. Adding an m×nm \times n matrix to a p×qp \times q matrix is undefined unless m=pm = p and n=qn = q.

Definition — Scalar Multiplication

For ARm×nA \in \mathbb{R}^{m \times n} and scalar cRc \in \mathbb{R}:

(cA)ij=caij(cA)_{ij} = c \cdot a_{ij}

Every entry is multiplied by cc. This preserves dimensions: cARm×ncA \in \mathbb{R}^{m \times n}.

Step-by-step — Computing $A + 2B$ where $A = \begin{pmatrix}3&-1\\0&4\end{pmatrix}$, $B = \begin{pmatrix}-2&5\\1&-3\end{pmatrix}$
1

Confirm dimensions match: AR2×2A \in \mathbb{R}^{2 \times 2} and BR2×2B \in \mathbb{R}^{2 \times 2}. Both 2×22 \times 2. ✓ Addition is defined.

2

Scale BB by 2: multiply every entry of BB by 2. 2B=(2×(2)2×52×12×(3))=(41026)2B = \begin{pmatrix}2 \times (-2) & 2 \times 5\\ 2 \times 1 & 2 \times (-3)\end{pmatrix} = \begin{pmatrix}-4&10\\2&-6\end{pmatrix}. Each of the four entries of BB is doubled individually.

3

Add entry (1,1)(1,1): a11+(2B)11=3+(4)=1a_{11} + (2B)_{11} = 3 + (-4) = -1. Adding a negative is subtraction.

4

Add entry (1,2)(1,2): a12+(2B)12=(1)+10=9a_{12} + (2B)_{12} = (-1) + 10 = 9.

5

Add entry (2,1)(2,1): a21+(2B)21=0+2=2a_{21} + (2B)_{21} = 0 + 2 = 2.

6

Add entry (2,2)(2,2): a22+(2B)22=4+(6)=2a_{22} + (2B)_{22} = 4 + (-6) = -2.

7

Assemble the result:

A+2B=(1922)A + 2B = \begin{pmatrix}-1 & 9 \\ 2 & -2\end{pmatrix}

❌ Failure — Adding Matrices of Different Dimensions

A=(1234)R2×2A = \begin{pmatrix}1&2\\3&4\end{pmatrix} \in \mathbb{R}^{2 \times 2} and B=(5678910)R2×3B = \begin{pmatrix}5&6&7\\8&9&10\end{pmatrix} \in \mathbb{R}^{2 \times 3}. Adding them fails at slot (1,3)(1,3): AA has no entry in column 3. The dimensions differ (2×22 \times 2 vs 2×32 \times 3). This is undefined — full stop. The number of columns (2 vs 3) must match, not just the number of rows.


03 · Matrix Multiplication

Matrix multiplication is the most important — and the most misunderstood — operation in linear algebra. It is not entry-by-entry. It is row-by-column dot products.

Definition — Matrix Multiplication

For ARm×nA \in \mathbb{R}^{m \times n} and BRn×pB \in \mathbb{R}^{n \times p}, the product ABRm×pAB \in \mathbb{R}^{m \times p} has entries:

(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}

(AB)ij(AB)_{ij} — the dot product of row ii of AA with column jj of BB.

kk — the shared index, stepping through 1,2,,n1, 2, \ldots, n.

The inner dimensions must match: AA must have nn columns and BB must have nn rows. The result has the outer dimensions: mm rows (from AA) and pp columns (from BB).

Dimension Check Before Multiplying

Write the dimensions side by side: (m×n)(n×p)(m \times n)(n \times p). The inner two numbers must match — both must equal nn. The result takes the outer two: m×pm \times p. Example: (3×4)(4×2)3×2(3 \times 4)(4 \times 2) \to 3 \times 2 ✓. Example: (3×4)(3×2)(3 \times 4)(3 \times 2) — inner pair is 4,34, 3 — mismatch. ✗ Undefined.

Step-by-step — Computing $AB$ where $A = \begin{pmatrix}1&2&3\\4&5&6\end{pmatrix}$, $B = \begin{pmatrix}7&8\\9&10\\11&12\end{pmatrix}$
1

Check dimensions: AR2×3A \in \mathbb{R}^{2 \times 3}, BR3×2B \in \mathbb{R}^{3 \times 2}. Inner dimensions both 33. ✓ Result will be 2×22 \times 2.

2

Compute entry (1,1)(1,1): dot product of row 1 of AA with column 1 of BB.

Row 1 of AA: (1,2,3)(1, 2, 3). Column 1 of BB: (7,9,11)(7, 9, 11).

(1)(7)+(2)(9)+(3)(11)=7+18+33=58(1)(7) + (2)(9) + (3)(11) = 7 + 18 + 33 = 58. The 77 comes from a11b11=1×7a_{11}b_{11} = 1 \times 7, the 1818 from a12b21=2×9a_{12}b_{21} = 2 \times 9, the 3333 from a13b31=3×11a_{13}b_{31} = 3 \times 11.

3

Compute entry (1,2)(1,2): dot product of row 1 of AA with column 2 of BB.

Column 2 of BB: (8,10,12)(8, 10, 12).

(1)(8)+(2)(10)+(3)(12)=8+20+36=64(1)(8) + (2)(10) + (3)(12) = 8 + 20 + 36 = 64. The 88 from 1×81 \times 8, the 2020 from 2×102 \times 10, the 3636 from 3×123 \times 12.

4

Compute entry (2,1)(2,1): dot product of row 2 of AA with column 1 of BB.

Row 2 of AA: (4,5,6)(4, 5, 6). Column 1 of BB: (7,9,11)(7, 9, 11).

(4)(7)+(5)(9)+(6)(11)=28+45+66=139(4)(7) + (5)(9) + (6)(11) = 28 + 45 + 66 = 139. The 2828 from 4×74 \times 7, the 4545 from 5×95 \times 9, the 6666 from 6×116 \times 11.

5

Compute entry (2,2)(2,2): dot product of row 2 of AA with column 2 of BB.

(4)(8)+(5)(10)+(6)(12)=32+50+72=154(4)(8) + (5)(10) + (6)(12) = 32 + 50 + 72 = 154. The 3232 from 4×84 \times 8, the 5050 from 5×105 \times 10, the 7272 from 6×126 \times 12.

6

Assemble the result:

AB=(5864139154)R2×2AB = \begin{pmatrix}58 & 64 \\ 139 & 154\end{pmatrix} \in \mathbb{R}^{2 \times 2}

❌ Failure — Matrix Multiplication Is Not Commutative

For A=(1234)A = \begin{pmatrix}1&2\\3&4\end{pmatrix} and B=(0110)B = \begin{pmatrix}0&1\\1&0\end{pmatrix}:

AB=(10+2111+2030+4131+40)=(2143)AB = \begin{pmatrix}1\cdot0+2\cdot1 & 1\cdot1+2\cdot0\\ 3\cdot0+4\cdot1 & 3\cdot1+4\cdot0\end{pmatrix} = \begin{pmatrix}2&1\\4&3\end{pmatrix}.

BA=(01+1302+1411+0312+04)=(3412)BA = \begin{pmatrix}0\cdot1+1\cdot3 & 0\cdot2+1\cdot4\\ 1\cdot1+0\cdot3 & 1\cdot2+0\cdot4\end{pmatrix} = \begin{pmatrix}3&4\\1&2\end{pmatrix}.

ABBAAB \neq BA. Swapping the order gives a different matrix. This is not a quirk of this specific pair — matrix multiplication is non-commutative in general. Never assume AB=BAAB = BA.

✓ Example — Portfolio Weights Applied to Returns

A 2×32 \times 3 matrix RR holds daily returns for 3 assets (columns) over 2 days (rows). A 3×13 \times 1 weight vector w\mathbf{w} holds the portfolio allocation for each asset. The product RwR\mathbf{w} gives the portfolio return on each day:

(0.80.31.21.50.60.4)(0.50.30.2)=(0.8(0.5)+(0.3)(0.3)+1.2(0.2)1.5(0.5)+0.6(0.3)+(0.4)(0.2))=(0.40.09+0.240.75+0.180.08)=(0.550.85)\begin{pmatrix}0.8 & -0.3 & 1.2 \\ 1.5 & 0.6 & -0.4\end{pmatrix} \begin{pmatrix}0.5\\0.3\\0.2\end{pmatrix} = \begin{pmatrix}0.8(0.5)+(-0.3)(0.3)+1.2(0.2)\\ 1.5(0.5)+0.6(0.3)+(-0.4)(0.2)\end{pmatrix} = \begin{pmatrix}0.4-0.09+0.24\\ 0.75+0.18-0.08\end{pmatrix} = \begin{pmatrix}0.55\\0.85\end{pmatrix}

Day 1 portfolio return: 0.55%0.55\%. Day 2: 0.85%0.85\%. Each row of RR is dotted with w\mathbf{w} — exactly the row-by-column pattern of matrix-vector multiplication.


04 · The Transpose

The transpose ATA^T of a matrix AA is formed by reflecting it across the main diagonal: row ii of AA becomes column ii of ATA^T, and column jj of AA becomes row jj of ATA^T.

Definition — Matrix Transpose

For ARm×nA \in \mathbb{R}^{m \times n}, the transpose ATRn×mA^T \in \mathbb{R}^{n \times m} is defined by:

(AT)ij=aji(A^T)_{ij} = a_{ji}

The row and column indices swap. An m×nm \times n matrix transposes to an n×mn \times m matrix — dimensions flip too.

Step-by-step — Transposing $A = \begin{pmatrix}1&2&3\\4&5&6\end{pmatrix}$
1

Identify dimensions: AR2×3A \in \mathbb{R}^{2 \times 3}. The transpose will be R3×2\mathbb{R}^{3 \times 2} — dimensions flip.

2

Write row 1 of AA as column 1 of ATA^T: row 1 is (1,2,3)(1, 2, 3), so column 1 of ATA^T is (123)\begin{pmatrix}1\\2\\3\end{pmatrix}.

3

Write row 2 of AA as column 2 of ATA^T: row 2 is (4,5,6)(4, 5, 6), so column 2 of ATA^T is (456)\begin{pmatrix}4\\5\\6\end{pmatrix}.

4

Assemble:

AT=(142536)R3×2A^T = \begin{pmatrix}1&4\\2&5\\3&6\end{pmatrix} \in \mathbb{R}^{3 \times 2}
Verify: (AT)12=a21=4(A^T)_{12} = a_{21} = 4 ✓. (AT)31=a13=3(A^T)_{31} = a_{13} = 3 ✓.

Two transpose properties are critical — one is obvious, one trips people up:

Properties of the Transpose
(AT)T=A(AB)T=BTAT(A^T)^T = A \qquad (AB)^T = B^T A^T

(AT)T=A(A^T)^T = A — transposing twice returns the original matrix.

(AB)T=BTAT(AB)^T = B^T A^T — the order reverses when transposing a product. The reversed order is not optional; it is forced by the dimension math.

❌ Failure — Wrong Order in Product Transpose

(AB)TATBT(AB)^T \neq A^T B^T. For AR2×3A \in \mathbb{R}^{2 \times 3} and BR3×4B \in \mathbb{R}^{3 \times 4}: ABR2×4AB \in \mathbb{R}^{2 \times 4}, so (AB)TR4×2(AB)^T \in \mathbb{R}^{4 \times 2}.

ATR3×2A^T \in \mathbb{R}^{3 \times 2} and BTR4×3B^T \in \mathbb{R}^{4 \times 3}. The product ATBTA^T B^T would need the inner dimensions to match: 3×23 \times 2 times 4×34 \times 3 — inner pair is 2,42, 4. Mismatch. ATBTA^T B^T is not even defined here.

BTATB^T A^T: 4×34 \times 3 times 3×23 \times 2 — inner pair is 3,33, 3 ✓ — gives 4×24 \times 2. Correct.

A symmetric matrix satisfies A=ATA = A^T — it is unchanged by transpose. Covariance matrices in finance are always symmetric, which makes them tractable for eigenvalue analysis in Chapter 6.


05 · Special Matrices

Four matrices appear so often they have names. Recognising them on sight saves work.

Definition — Identity Matrix $I_n$

The n×nn \times n identity matrix InI_n has ones on the main diagonal and zeros elsewhere:

In=(100010001)I_n = \begin{pmatrix}1&0&\cdots&0\\0&1&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&1\end{pmatrix}

For any ARm×nA \in \mathbb{R}^{m \times n}: AIn=AAI_n = A and ImA=AI_m A = A. Multiplying by II is the matrix analogue of multiplying a number by 1.

Definition — Diagonal Matrix

A square matrix DRn×nD \in \mathbb{R}^{n \times n} is diagonal if dij=0d_{ij} = 0 whenever iji \neq j — all entries off the main diagonal are zero:

D=(d1000d2000dn)D = \begin{pmatrix}d_1&0&\cdots&0\\0&d_2&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&d_n\end{pmatrix}

Products of diagonal matrices are easy: (D1D2)ii=(d1)i(d2)i(D_1 D_2)_{ii} = (d_1)_i (d_2)_i — just multiply the diagonal entries. No row-by-column calculation needed.

Definition — Symmetric Matrix

A square matrix ARn×nA \in \mathbb{R}^{n \times n} is symmetric if A=ATA = A^T, i.e., aij=ajia_{ij} = a_{ji} for all i,ji, j.

Symmetric    aij=aji for all i,j\text{Symmetric} \iff a_{ij} = a_{ji} \text{ for all } i, j

Symmetric matrices are their own transpose. Every covariance matrix is symmetric because Cov(Xi,Xj)=Cov(Xj,Xi)\text{Cov}(X_i, X_j) = \text{Cov}(X_j, X_i).

✓ Example — Symmetric Covariance Matrix

For two assets with variances σ12=4\sigma_1^2 = 4, σ22=9\sigma_2^2 = 9, and covariance σ12=3\sigma_{12} = 3:

Σ=(4339)\Sigma = \begin{pmatrix}4 & 3 \\ 3 & 9\end{pmatrix}

Σ=ΣT\Sigma = \Sigma^T ✓ — the off-diagonal entries are equal. This symmetry is not accidental; it holds for every covariance matrix by definition of covariance.


06 · The Trace

The trace of a square matrix is the sum of its diagonal entries. It is the first of several invariants — numbers that capture something essential about the matrix regardless of how it is written.

Definition — Trace

For ARn×nA \in \mathbb{R}^{n \times n}:

tr(A)=i=1naii=a11+a22++ann\text{tr}(A) = \sum_{i=1}^{n} a_{ii} = a_{11} + a_{22} + \cdots + a_{nn}

Only defined for square matrices. The trace is a single real number.

Step-by-step — Computing $\text{tr}(A)$ for $A = \begin{pmatrix}5&-2&1\\3&8&0\\-1&4&-3\end{pmatrix}$
1

Identify the main diagonal entries: a11=5a_{11} = 5, a22=8a_{22} = 8, a33=3a_{33} = -3. The main diagonal runs from top-left to bottom-right.

2

Sum the diagonal entries: tr(A)=5+8+(3)=10\text{tr}(A) = 5 + 8 + (-3) = 10. The 55 is from position (1,1)(1,1), the 88 from (2,2)(2,2), the 3-3 from (3,3)(3,3).

Two trace properties are useful:

Properties of the Trace
tr(A+B)=tr(A)+tr(B)tr(AB)=tr(BA)\text{tr}(A + B) = \text{tr}(A) + \text{tr}(B) \qquad \text{tr}(AB) = \text{tr}(BA)

tr(AB)=tr(BA)\text{tr}(AB) = \text{tr}(BA) — trace is cyclic under products. Note: this does not mean AB=BAAB = BA. The matrices may be completely different while their traces of products coincide.

✓ Example — Total Variance via Trace

For a covariance matrix Σ=(4339)\Sigma = \begin{pmatrix}4&3\\3&9\end{pmatrix}, the total variance across all assets equals the trace:

tr(Σ)=4+9=13\text{tr}(\Sigma) = 4 + 9 = 13

The 44 is the variance of asset 1, the 99 is the variance of asset 2. In PCA, the trace of the covariance matrix equals the total variance to be explained across all principal components.


07 · Practice Exercises

EXERCISE 2.1

Add entry by entry in the same position. Confirm both matrices have the same dimensions before starting.

A+BA + B: add each entry at the same position.

(1,1)(1,1): 2+(1)=12 + (-1) = 1. (1,2)(1,2): 3+4=1-3 + 4 = 1. (2,1)(2,1): 5+2=75 + 2 = 7. (2,2)(2,2): 0+(6)=60 + (-6) = -6. (3,1)(3,1): 1+3=2-1 + 3 = 2. (3,2)(3,2): 4+0=44 + 0 = 4.

A+B=(117624)A + B = \begin{pmatrix}1 & 1 \\ 7 & -6 \\ 2 & 4\end{pmatrix}.

3A3A: multiply every entry of AA by 3. (1,1)(1,1): 3×2=63 \times 2 = 6. (1,2)(1,2): 3×(3)=93 \times (-3) = -9. (2,1)(2,1): 3×5=153 \times 5 = 15. (2,2)(2,2): 3×0=03 \times 0 = 0. (3,1)(3,1): 3×(1)=33 \times (-1) = -3. (3,2)(3,2): 3×4=123 \times 4 = 12. Therefore 3A=(69150312)3A = \begin{pmatrix}6&-9\\15&0\\-3&12\end{pmatrix}.

Let A=(235014)A = \begin{pmatrix}2&-3\\5&0\\-1&4\end{pmatrix} and B=(142630)B = \begin{pmatrix}-1&4\\2&-6\\3&0\end{pmatrix}, both in R3×2\mathbb{R}^{3 \times 2}. Compute A+BA + B and 3A3A, showing every entry.

EXERCISE 2.2

Check inner dimensions first: (2×3)(3×2)(2 \times 3)(3 \times 2) gives a 2×22 \times 2 result. Each entry (i,j)(i,j) is the dot product of row ii of AA with column jj of BB.

AR2×3A \in \mathbb{R}^{2 \times 3}, BR3×2B \in \mathbb{R}^{3 \times 2}. Inner dimensions both 3. Result is 2×22 \times 2.

(AB)11(AB)_{11}: row 1 of AA = (2,0,1)(2, 0, -1), col 1 of BB = (1,3,2)(1, 3, -2). 2(1)+0(3)+(1)(2)=2+0+2=42(1) + 0(3) + (-1)(-2) = 2 + 0 + 2 = 4.

(AB)12(AB)_{12}: row 1 of AA = (2,0,1)(2, 0, -1), col 2 of BB = (1,4,5)(-1, 4, 5). 2(1)+0(4)+(1)(5)=2+05=72(-1) + 0(4) + (-1)(5) = -2 + 0 - 5 = -7.

(AB)21(AB)_{21}: row 2 of AA = (1,2,3)(1, -2, 3), col 1 of BB = (1,3,2)(1, 3, -2). 1(1)+(2)(3)+3(2)=166=111(1) + (-2)(3) + 3(-2) = 1 - 6 - 6 = -11.

(AB)22(AB)_{22}: row 2 of AA = (1,2,3)(1, -2, 3), col 2 of BB = (1,4,5)(-1, 4, 5). 1(1)+(2)(4)+3(5)=18+15=61(-1) + (-2)(4) + 3(5) = -1 - 8 + 15 = 6.

Therefore AB=(47116)AB = \begin{pmatrix}4 & -7 \\ -11 & 6\end{pmatrix}.

Compute ABAB where A=(201123)A = \begin{pmatrix}2&0&-1\\1&-2&3\end{pmatrix} and B=(113425)B = \begin{pmatrix}1&-1\\3&4\\-2&5\end{pmatrix}. Show every entry computation in full.

EXERCISE 2.3

Transpose by writing each row of AA as the corresponding column of ATA^T. Then check (AB)T=BTAT(AB)^T = B^T A^T by computing both sides.

A=(123456)R3×2A = \begin{pmatrix}1&2\\3&4\\5&6\end{pmatrix} \in \mathbb{R}^{3 \times 2}, so ATR2×3A^T \in \mathbb{R}^{2 \times 3}: row 1 of AA becomes col 1 of ATA^T, row 2 becomes col 2, row 3 becomes col 3. AT=(135246)A^T = \begin{pmatrix}1&3&5\\2&4&6\end{pmatrix}.

B=(012311)R3×2B = \begin{pmatrix}0&-1\\2&3\\-1&1\end{pmatrix} \in \mathbb{R}^{3 \times 2}. BT=(021131)B^T = \begin{pmatrix}0&2&-1\\-1&3&1\end{pmatrix}.

ABAB: dimensions (3×2)(3×2)(3 \times 2)(3 \times 2) — inner pair is 2,32, 3. Mismatch. ABAB is not defined. The product ATBA^T B is defined: (2×3)(3×2)=2×2(2 \times 3)(3 \times 2) = 2 \times 2.

(ATB)11=1(0)+3(2)+5(1)=0+65=1(A^T B)_{11} = 1(0)+3(2)+5(-1) = 0+6-5 = 1. (ATB)12=1(1)+3(3)+5(1)=1+9+5=13(A^T B)_{12} = 1(-1)+3(3)+5(1) = -1+9+5 = 13. (ATB)21=2(0)+4(2)+6(1)=0+86=2(A^T B)_{21} = 2(0)+4(2)+6(-1) = 0+8-6 = 2. (ATB)22=2(1)+4(3)+6(1)=2+12+6=16(A^T B)_{22} = 2(-1)+4(3)+6(1) = -2+12+6 = 16. ATB=(113216)A^T B = \begin{pmatrix}1&13\\2&16\end{pmatrix}.

For A=(123456)A = \begin{pmatrix}1&2\\3&4\\5&6\end{pmatrix} and B=(012311)B = \begin{pmatrix}0&-1\\2&3\\-1&1\end{pmatrix}: (a) Write down ATA^T and BTB^T. (b) Determine whether ABAB is defined. (c) Compute ATBA^T B, showing all four entries.

EXERCISE 2.4

Compute both ABAB and BABA explicitly. If they differ in even one entry, that proves non-commutativity for these matrices.

A=(1101)A = \begin{pmatrix}1&1\\0&1\end{pmatrix}, B=(1011)B = \begin{pmatrix}1&0\\1&1\end{pmatrix}.

ABAB: (1,1)(1,1): 1(1)+1(1)=21(1)+1(1)=2. (1,2)(1,2): 1(0)+1(1)=11(0)+1(1)=1. (2,1)(2,1): 0(1)+1(1)=10(1)+1(1)=1. (2,2)(2,2): 0(0)+1(1)=10(0)+1(1)=1. AB=(2111)AB = \begin{pmatrix}2&1\\1&1\end{pmatrix}.

BABA: (1,1)(1,1): 1(1)+0(0)=11(1)+0(0)=1. (1,2)(1,2): 1(1)+0(1)=11(1)+0(1)=1. (2,1)(2,1): 1(1)+1(0)=11(1)+1(0)=1. (2,2)(2,2): 1(1)+1(1)=21(1)+1(1)=2. BA=(1112)BA = \begin{pmatrix}1&1\\1&2\end{pmatrix}.

AB=(2111)(1112)=BAAB = \begin{pmatrix}2&1\\1&1\end{pmatrix} \neq \begin{pmatrix}1&1\\1&2\end{pmatrix} = BA. Therefore ABBAAB \neq BA — matrix multiplication is not commutative for these matrices.

For A=(1101)A = \begin{pmatrix}1&1\\0&1\end{pmatrix} and B=(1011)B = \begin{pmatrix}1&0\\1&1\end{pmatrix}, compute both ABAB and BABA. Confirm or refute: AB=BAAB = BA.

EXERCISE 2.5

The trace is the sum of diagonal entries. For a symmetric matrix, check that aij=ajia_{ij} = a_{ji} for every off-diagonal pair.

A=(312154247)A = \begin{pmatrix}3&1&-2\\1&5&4\\-2&4&7\end{pmatrix}.

tr(A)=a11+a22+a33=3+5+7=15\text{tr}(A) = a_{11} + a_{22} + a_{33} = 3 + 5 + 7 = 15. The 3 comes from position (1,1)(1,1), the 5 from (2,2)(2,2), the 7 from (3,3)(3,3).

Symmetry check: a12=1=a21a_{12} = 1 = a_{21} ✓. a13=2=a31a_{13} = -2 = a_{31} ✓. a23=4=a32a_{23} = 4 = a_{32} ✓. All off-diagonal pairs match. Therefore AA is symmetric.

tr(A)=15\text{tr}(A) = 15 and AA is symmetric.

For A=(312154247)A = \begin{pmatrix}3&1&-2\\1&5&4\\-2&4&7\end{pmatrix}: (a) Compute tr(A)\text{tr}(A). (b) Determine whether AA is symmetric. Check every off-diagonal pair.

EXERCISE 2.6

The portfolio variance is wTΣw\mathbf{w}^T \Sigma \mathbf{w}. Compute Σw\Sigma \mathbf{w} first (matrix-vector product), then take the dot product with w\mathbf{w}.

Σ=(96616)\Sigma = \begin{pmatrix}9&6\\6&16\end{pmatrix}, w=(0.60.4)\mathbf{w} = \begin{pmatrix}0.6\\0.4\end{pmatrix}.

Step 1 — Compute Σw\Sigma\mathbf{w}: row 1: 9(0.6)+6(0.4)=5.4+2.4=7.89(0.6)+6(0.4) = 5.4+2.4 = 7.8. Row 2: 6(0.6)+16(0.4)=3.6+6.4=10.06(0.6)+16(0.4) = 3.6+6.4 = 10.0. So Σw=(7.810.0)\Sigma\mathbf{w} = \begin{pmatrix}7.8\\10.0\end{pmatrix}.

Step 2 — Compute wT(Σw)=0.6(7.8)+0.4(10.0)=4.68+4.0=8.68\mathbf{w}^T(\Sigma\mathbf{w}) = 0.6(7.8) + 0.4(10.0) = 4.68 + 4.0 = 8.68.

Portfolio variance =8.68= 8.68. Portfolio standard deviation =8.682.946%= \sqrt{8.68} \approx 2.946\%. The total variance of 9+16=259 + 16 = 25 is reduced to 8.688.68 because the assets are positively correlated (σ12=6>0\sigma_{12} = 6 > 0) — but the weights concentrate less than 50%50\% in the high-variance asset.

A two-asset portfolio has covariance matrix Σ=(96616)\Sigma = \begin{pmatrix}9&6\\6&16\end{pmatrix} (variances in %2\%^2) and weight vector w=(0.60.4)\mathbf{w} = \begin{pmatrix}0.6\\0.4\end{pmatrix}. Compute the portfolio variance σp2=wTΣw\sigma_p^2 = \mathbf{w}^T \Sigma \mathbf{w}. Show the matrix-vector product Σw\Sigma\mathbf{w} first, then the scalar product with wT\mathbf{w}^T.


08 · Summary

TermDefinition
MatrixRectangular array ARm×nA \in \mathbb{R}^{m \times n} with mm rows, nn columns. Entry aija_{ij}: row ii, column jj.
Addition(A+B)ij=aij+bij(A+B)_{ij} = a_{ij}+b_{ij}. Requires identical dimensions.
Scalar mult.(cA)ij=caij(cA)_{ij} = c\,a_{ij}. Every entry scaled.
Matrix product(AB)ij=kaikbkj(AB)_{ij} = \sum_k a_{ik}b_{kj}. Row-by-column dot products. Inner dimensions must match.
Non-commutativityABBAAB \neq BA in general. Order matters in every matrix product.
Transpose(AT)ij=aji(A^T)_{ij} = a_{ji}. Dimensions flip. (AB)T=BTAT(AB)^T = B^TA^T — order reverses.
Identity InI_nOnes on diagonal, zeros elsewhere. AIn=ImA=AAI_n = I_mA = A.
SymmetricA=ATA = A^T. Off-diagonal entries satisfy aij=ajia_{ij} = a_{ji}.
Tracetr(A)=iaii\text{tr}(A) = \sum_i a_{ii}. Square matrices only. Equals total variance for covariance matrices.

Next: Systems of Linear Equations — how the equation Ax=bA\mathbf{x} = \mathbf{b} organises multiple unknowns, and what the solution set looks like geometrically.