Skip to content

Chapter 4 Formula Sheet

Reference, not teaching. Each entry names the book’s number, states the result, gives the condition it needs, and names the call that computes it. Read the concept pages first; come back here when you are working.

Every decomposition in this chapter trades a condition for a capability:

SPDCholesky    symmetricPDP    non-defective squarePDP1    any matrix at allUΣV\underbrace{\text{SPD}}_{\text{Cholesky}} \;\subset\; \underbrace{\text{symmetric}}_{\mathbf{P}\mathbf{D}\mathbf{P}^\top} \;\subset\; \underbrace{\text{non-defective square}}_{\mathbf{P}\mathbf{D}\mathbf{P}^{-1}} \;\subset\; \underbrace{\text{any matrix at all}}_{\mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top}

Read it right to left and the SVD is the one with no entry fee. Read it left to right and each step buys something cheaper: Cholesky costs 13n3\tfrac13n^3 where an SVD costs about 20n320n^3.

#resultconditionNumPy
Thm 4.1A\mathbf{A} is invertible     detA0\iff \det\mathbf{A} \neq 0squarenp.linalg.det
Eq 4.52×22\times2: det=a11a22a12a21\det = a_{11}a_{22} - a_{12}a_{21}
Eq 4.6Sarrus for 3×33\times3: three down-right products minus three down-left3×33\times3 only
Thm 4.2Laplace expansion along row or column jj: detA=k(1)k+jakjdetAk,j\det\mathbf{A} = \sum_k (-1)^{k+j}a_{kj}\det\mathbf{A}_{k,j}square
Eq 4.8triangular matrix: detA=iaii\det\mathbf{A} = \prod_i a_{ii}triangular
Thm 4.3det(AB)=detAdetB\det(\mathbf{A}\mathbf{B}) = \det\mathbf{A}\det\mathbf{B}; detA=detA\det\mathbf{A}^\top = \det\mathbf{A}; detA1=1/detA\det\mathbf{A}^{-1} = 1/\det\mathbf{A}; similar matrices share a determinant; row operations, sign rulessquare
Thm 4.3detA0    rk(A)=n\det\mathbf{A} \neq 0 \iff \mathrm{rk}(\mathbf{A}) = nsquarenp.linalg.matrix_rank
Def 4.4tr(A)=iaii\mathrm{tr}(\mathbf{A}) = \sum_i a_{ii}squarenp.trace
Eq 4.19tr(AB)=tr(BA)\mathrm{tr}(\mathbf{A}\mathbf{B}) = \mathrm{tr}(\mathbf{B}\mathbf{A}) — so the trace is cyclicshapes must compose both ways
Eq 4.21tr(xy)=yx\mathrm{tr}(\mathbf{x}\mathbf{y}^\top) = \mathbf{y}^\top\mathbf{x}
trace is invariant under basis change: tr(S1AS)=tr(A)\mathrm{tr}(\mathbf{S}^{-1}\mathbf{A}\mathbf{S}) = \mathrm{tr}(\mathbf{A})S\mathbf{S} invertible

The cost warning. Laplace expansion is about n!n! multiplications; Gaussian elimination is about n3/3n^3/3. Determinants are a theoretical tool.

#resultconditionNumPy
Def 4.6Ax=λx\mathbf{A}\mathbf{x} = \lambda\mathbf{x}, x0\mathbf{x} \neq \mathbf{0}squarenp.linalg.eig
Thm 4.8λ\lambda is an eigenvalue     \iff it is a root of pA(λ)=det(AλI)p_\mathbf{A}(\lambda) = \det(\mathbf{A}-\lambda\mathbf{I})squarenp.roots on the char. poly (don’t)
Def 4.9algebraic multiplicity: multiplicity as a root of pAp_\mathbf{A}
Def 4.11eigenspace Eλ=ker(AλI)E_\lambda = \ker(\mathbf{A}-\lambda\mathbf{I}); geometric multiplicity =dimEλ= \dim E_\lambdan - matrix_rank(A - lam*I)
11 \leq geometric \leq algebraic, always
Def 4.13defective: geometric multiplicities sum to less than nnsquare
Thm 4.12eigenvectors for distinct eigenvalues are linearly independent
Thm 4.14AA\mathbf{A}^\top\mathbf{A} is symmetric positive semidefinite; positive definite iff rk(A)=n\mathrm{rk}(\mathbf{A}) = nany shape
Thm 4.15spectral theorem: a symmetric matrix has an orthonormal basis of eigenvectors and real eigenvaluessymmetricnp.linalg.eigh
Thm 4.16detA=iλi\det\mathbf{A} = \prod_i\lambda_i, counting algebraic multiplicitysquare
Thm 4.17trA=iλi\mathrm{tr}\,\mathbf{A} = \sum_i\lambda_i, counting algebraic multiplicitysquare
Eq 4.23–4.24for a 2×22\times2: pA(λ)=λ2(trA)λ+detAp_\mathbf{A}(\lambda) = \lambda^2 - (\mathrm{tr}\,\mathbf{A})\lambda + \det\mathbf{A}2×22\times2
detA\lvert\det\mathbf{A}\rvert is the volume scaling; its sign is the orientationsquare

Use eigh for symmetric input — faster, real, sorted ascending, orthonormal eigenvectors. Never on non-symmetric input: it reads only the lower triangle.

#resultconditionNumPy
Thm 4.18A=LL\mathbf{A} = \mathbf{L}\mathbf{L}^\top with L\mathbf{L} lower triangular and positive diagonal, uniquelysymmetric positive definitenp.linalg.cholesky
Eq 4.44detA=ilii2\det\mathbf{A} = \prod_i l_{ii}^2SPD
sampling: x=μ+Lz\mathbf{x} = \boldsymbol{\mu} + \mathbf{L}\mathbf{z} with zN(0,I)\mathbf{z}\sim\mathcal{N}(\mathbf{0},\mathbf{I}) gives xN(μ,Σ)\mathbf{x}\sim\mathcal{N}(\boldsymbol{\mu},\boldsymbol{\Sigma})Σ\boldsymbol{\Sigma} SPD
cost 13n3\tfrac13n^3, about half an LU factorisationSPD
a raised LinAlgError is the positive-definiteness testtry/except

§4.4 Eigendecomposition and diagonalization

Section titled “§4.4 Eigendecomposition and diagonalization”
#resultconditionNumPy
Def 4.19diagonalizable: similar to a diagonal matrix, D=P1AP\mathbf{D} = \mathbf{P}^{-1}\mathbf{A}\mathbf{P}square
Eq 4.50AP=PD    \mathbf{A}\mathbf{P} = \mathbf{P}\mathbf{D} \iff the columns of P\mathbf{P} are eigenvectors and D\mathbf{D} holds the eigenvalues
Thm 4.20A=PDP1\mathbf{A} = \mathbf{P}\mathbf{D}\mathbf{P}^{-1} iff the eigenvectors form a basis of Rn\mathbb{R}^nsquare, non-defectivenp.linalg.eig
Thm 4.21a symmetric matrix can always be diagonalized, and P\mathbf{P} can be taken orthogonal so D=PAP\mathbf{D} = \mathbf{P}^\top\mathbf{A}\mathbf{P}symmetricnp.linalg.eigh
Eq 4.62Ak=PDkP1\mathbf{A}^k = \mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}diagonalizablenp.linalg.matrix_power
Eq 4.63detA=idii\det\mathbf{A} = \prod_i d_{ii}diagonalizable
geometry: P1\mathbf{P}^{-1} into the eigenbasis, D\mathbf{D} scales, P\mathbf{P} back. Rotations only if symmetric
defective matrices need the Jordan normal form — outside this book
#resultconditionNumPy
Thm 4.22A=UΣV\mathbf{A} = \mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top with URm×m\mathbf{U} \in \mathbb{R}^{m\times m}, VRn×n\mathbf{V} \in \mathbb{R}^{n\times n} both orthogonal, ΣRm×n\boldsymbol{\Sigma} \in \mathbb{R}^{m\times n} with σi0\sigma_i \geq 0 descendingnonenp.linalg.svd
Eq 4.65–4.66Σ\boldsymbol{\Sigma} has the shape of A\mathbf{A}: zero rows below if m>nm>n, zero columns to the right if m<nm<n
Eq 4.73AA=Vdiag(σi2)V\mathbf{A}^\top\mathbf{A} = \mathbf{V}\,\mathrm{diag}(\sigma_i^2)\,\mathbf{V}^\top — the eigenvectors of AA\mathbf{A}^\top\mathbf{A} are V\mathbf{V}
Eq 4.76AA=Udiag(σi2)U\mathbf{A}\mathbf{A}^\top = \mathbf{U}\,\mathrm{diag}(\sigma_i^2)\,\mathbf{U}^\top — the eigenvectors of AA\mathbf{A}\mathbf{A}^\top are U\mathbf{U}
Eq 4.78ui=Avi/σi\mathbf{u}_i = \mathbf{A}\mathbf{v}_i/\sigma_iσi0\sigma_i \neq 0
Eq 4.79singular value equation Avi=σiui\mathbf{A}\mathbf{v}_i = \sigma_i\mathbf{u}_i, i=1,,ri = 1,\dots,r
Eq 4.80AV=UΣ\mathbf{A}\mathbf{V} = \mathbf{U}\boldsymbol{\Sigma}
the trailing columns of V\mathbf{V} are an orthonormal basis of kerA\ker\mathbf{A}Vt[r:].T
Eq 4.89reduced SVD: U\mathbf{U} is m×nm\times n, Σ\boldsymbol{\Sigma} is n×nn\times n squaremnm \geq nfull_matrices=False
iσi=detA\prod_i\sigma_i = \lvert\det\mathbf{A}\rvert and σ1=A2\sigma_1 = \lVert\mathbf{A}\rVert_2square for the first
σi=λi\sigma_i = \lvert\lambda_i\rvert only for symmetric matricessymmetric
for symmetric A\mathbf{A} the eigendecomposition and the SVD coincidesymmetric

Never compute an SVD through a Gram matrix. κ(AA)=κ(A)2\kappa(\mathbf{A}^\top\mathbf{A}) = \kappa(\mathbf{A})^2; measured, the smallest singular value is 4%4\% wrong at κ=108\kappa = 10^8 and lost entirely at 101210^{12}.

#resultconditionNumPy
Eq 4.90Ai=uivi\mathbf{A}_i = \mathbf{u}_i\mathbf{v}_i^\top, a rank-1 outer productnp.outer
Eq 4.91A=i=1rσiuivi\mathbf{A} = \sum_{i=1}^r \sigma_i\mathbf{u}_i\mathbf{v}_i^\top
Eq 4.92A^(k)=i=1kσiuivi\hat{\mathbf{A}}(k) = \sum_{i=1}^k \sigma_i\mathbf{u}_i\mathbf{v}_i^\top, with rk(A^(k))=k\mathrm{rk}(\hat{\mathbf{A}}(k)) = k exactlykrk \leq r(U[:,:k]*s[:k]) @ Vt[:k]
Def 4.23spectral norm A2=maxxAx2/x2\lVert\mathbf{A}\rVert_2 = \max_\mathbf{x}\lVert\mathbf{A}\mathbf{x}\rVert_2/\lVert\mathbf{x}\rVert_2np.linalg.norm(A, 2)
Thm 4.24A2=σ1\lVert\mathbf{A}\rVert_2 = \sigma_1
Thm 4.25Eckart-Young: A^(k)=argminrk(B)=kAB2\hat{\mathbf{A}}(k) = \operatorname*{argmin}_{\mathrm{rk}(\mathbf{B})=k}\lVert\mathbf{A}-\mathbf{B}\rVert_2 and AA^(k)2=σk+1\lVert\mathbf{A}-\hat{\mathbf{A}}(k)\rVert_2 = \sigma_{k+1}
Eq 4.96AA^(k)=i=k+1rσiuivi\mathbf{A} - \hat{\mathbf{A}}(k) = \sum_{i=k+1}^r\sigma_i\mathbf{u}_i\mathbf{v}_i^\top
Frobenius error: AA^(k)F=i>kσi2\lVert\mathbf{A}-\hat{\mathbf{A}}(k)\rVert_F = \sqrt{\sum_{i>k}\sigma_i^2}, also optimal
storage: k(m+n+1)k(m+n+1) numbers, so it saves only when k<mn/(m+n+1)k < mn/(m+n+1)
classconditionwhat it gives you
real, any shapeSVD, pseudo-inverse
squarem=nm = ndeterminant, trace, eigenvalues
regular / invertibledet0\det \neq 0A1\mathbf{A}^{-1}
non-defectivenn independent eigenvectorsPDP1\mathbf{P}\mathbf{D}\mathbf{P}^{-1}
normalAA=AA\mathbf{A}^\top\mathbf{A} = \mathbf{A}\mathbf{A}^\topsingular and eigen directions align
orthogonal (Def 3.8)AA=AA=I\mathbf{A}^\top\mathbf{A} = \mathbf{A}\mathbf{A}^\top = \mathbf{I}A1=A\mathbf{A}^{-1} = \mathbf{A}^\top, free
rotationorthogonal with det=+1\det = +1preserves orientation
symmetricS=S\mathbf{S} = \mathbf{S}^\topreal eigenvalues, orthonormal eigenbasis
positive definitexPx>0\mathbf{x}^\top\mathbf{P}\mathbf{x} > 0unique Cholesky, λ>0\lambda > 0, invertible
diagonalaij=0a_{ij} = 0, iji \neq jeverything elementwise
identityA=I\mathbf{A} = \mathbf{I}

Diagonal matrices are closed under multiplication and addition but form a group only when every diagonal entry is nonzero.

quantityvaluewhere
Laplace vs elimination at n=20n = 20ratio 1.6×10151.6\times10^{15}§4.1
Cholesky cost13n3\tfrac13n^3, half an LU§4.3
eigendecomposition costabout 10n310n^3 symmetric§4.4
SVD costabout 20n320n^3 square§4.5
Ak\mathbf{A}^k crossover, n=6n=6eigen route wins from k=14k = 14§4.4
defective random 4×44\times4 Gaussians00 of 40004000§4.4
defective small-integer 4×44\times42.675%2.675\%§4.4
det\det of np.linalg.qr’s Q\mathbf{Q}(1)n1(-1)^{n-1}, exactly§4.7
Eckart-Young agreement over 420 truncations6.22×10156.22\times10^{-15}§4.6
random rank-kk competitors below the bound00 of 420420§4.6
Stonehenge rank-5 storage1671516\,715 of 27351202\,735\,120, 0.611%0.611\%§4.6
Gram route error at κ=1012\kappa = 10^{12}100%100\% — the singular value is lost§4.5
#answer
4.100; r3=2r1r2\mathbf{r}_3 = 2\mathbf{r}_1 - \mathbf{r}_2
4.266
4.3(a) defective, λ=1\lambda=1 geometric 11; (b) λ=2,3\lambda = 2, -3, diagonalizable
4.4λ=2,1,1\lambda = 2, 1, -1 (1-1 doubled, geometric 11) — defective
4.5all four invertible-by-diagonalizable combinations
4.6(a) defective 2/32/3; (b) diagonalizable 4/44/4
4.7(a) 2±2i2\pm2i, no over R\mathbb{R}; (b) yes; (c) defective 3/43/4; (d) yes
4.8σ=5,3\sigma = 5, 3
4.9σ=22,2\sigma = 2\sqrt2, \sqrt2, with U=I\mathbf{U} = \mathbf{I}
4.1052[110110]\tfrac52\begin{bmatrix}1&1&0\\1&1&0\end{bmatrix}, error 33
4.11multiply by A\mathbf{A}; needs λ0\lambda \neq 0 to keep Av0\mathbf{A}\mathbf{v} \neq \mathbf{0}
4.12orthogonal factors preserve length; the max is at x=v1\mathbf{x} = \mathbf{v}_1
fromused in
§4.1 determinant, traceCh 5 Jacobians; Ch 6 Gaussian densities carry detΣ\det\boldsymbol{\Sigma}
§4.2 eigenvaluesCh 7 the Hessian’s spectrum decides minimum vs saddle; Ch 10 variance along a component
§4.2 spectral theoremCh 10 orthogonal principal components; Ch 12 kernel matrices
§4.3 CholeskyCh 6 Gaussian sampling and the reparametrisation trick; Ch 11 GMM covariances
§4.4 eigendecompositionCh 10 PCA as an eigendecomposition of a covariance matrix
§4.5 SVDCh 9 the pseudo-inverse and least squares; Ch 10 PCA by another route
§4.6 Eckart-YoungCh 10 the reconstruction-error derivation of PCA

The six mistakes this chapter is designed to prevent

Section titled “The six mistakes this chapter is designed to prevent”
  1. Computing a determinant by cofactor expansion. n!n! against n3/3n^3/3. Use elimination, or Cholesky if the matrix is SPD.
  2. Assuming invertible means diagonalizable. Measured, the implication holds 85%85\% one way and 98%98\% the other. Neither is a theorem.
  3. Assuming a repeated eigenvalue means defective. Exercise 4.6b has an eigenvalue repeated three times and is perfectly diagonalizable. What matters is dimker(AλI)\dim\ker(\mathbf{A}-\lambda\mathbf{I}).
  4. Writing P1=P\mathbf{P}^{-1} = \mathbf{P}^\top without checking symmetry. Example 4.5 is diagonalizable with PPI=0.3162\lVert\mathbf{P}^\top\mathbf{P}-\mathbf{I}\rVert = 0.3162.
  5. Constructing an SVD through AA\mathbf{A}^\top\mathbf{A}. The condition number squares. The construction is a proof, not an algorithm.
  6. Reading individual eigenvector or singular-vector components across a repeated value. Any rotation inside the repeated eigenspace is equally valid, so different builds report different vectors.
pch.quizTag Can you place each result?
  1. Which decomposition needs no condition on the matrix at all?

    pch.quizShowAnswer

    C — The SVD — Theorem 4.22 holds for every real matrix of every shape, with rank anywhere from 0 to min(m,n). Cholesky needs symmetric positive definite; the eigendecomposition needs square and non-defective.

  2. Theorem 4.24 says the spectral norm equals sigma_1. What makes Equation 4.95 follow almost immediately?

    pch.quizShowAnswer

    B — That A minus A-hat(k) is the tail of the SVD sum, so it is already in SVD form with largest singular value sigma-k-plus-one — Equation 4.96 makes that explicit. The hard half of Theorem 4.25 is optimality, Equation 4.94, which needs the rank-nullity contradiction.

  3. Which single result does the rest of the chapter lean on most heavily?

    pch.quizShowAnswer

    B — Theorem 4.15, the spectral theorem: a symmetric matrix has real eigenvalues and an orthonormal eigenbasis — It gives Theorem 4.21 for symmetric matrices, it is what makes the SVD construction of §4.5.2 work at all since A-transpose A is always symmetric, and it is why PCA in Chapter 10 gets orthogonal components without asking.

  • The chapter is a ladder of conditions: Cholesky needs SPD, the eigendecomposition needs square and non-defective, the SVD needs nothing — and the cheaper the decomposition, the stricter the condition.
  • Determinant and trace are basis-independent, so they describe the mapping rather than the matrix; both equal a symmetric function of the eigenvalues (product and sum).
  • The spectral theorem is the load-bearing result: symmetric implies real eigenvalues and an orthonormal eigenbasis, which is what makes Theorem 4.21, the SVD construction and PCA all work.
  • Diagonalizability is about the count of independent eigenvectors, which is the sum of the geometric multiplicities — not about repeats and not about invertibility.
  • The SVD’s two outer factors are orthogonal and live in different spaces, so unlike P and P-inverse they are not inverses of each other; Sigma has the shape of A and pads with zeros.
  • Eckart-Young gives the error before you compute the approximation: exactly sigma-k-plus-one in the spectral norm, and the square root of the discarded tail in the Frobenius norm.
  • Low rank is not few numbers: a rank-k factorisation costs k(m+n+1), so the saving depends on the ratio of k to mn/(m+n+1).
  • Three library traps: cholesky and eigh read only the lower triangle; np.linalg.qr returns a Q with determinant exactly (-1) to the (n-1); and eig returns P for a defective matrix without complaint.

Back to: Matrix Decompositions Overview — or on to Chapter 5, Vector Calculus.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading