Skip to content

Chapter 2 Formula Sheet

Pure reference. Every entry links back to the page that derives it, and the when you use it column is the reason the entry is here at all — a formula you cannot place is a formula you will not reach for.

Symbols follow Notation and Symbols: lowercase italic scalars, lowercase bold vectors, uppercase bold matrices, calligraphic sets.

resultstatementwhen you use it
general formj=1naijxj=bi,  i=1,,m\displaystyle\sum_{j=1}^{n} a_{ij}x_j = b_i,\; i = 1,\dots,mwriting a problem down before doing anything
matrix formAx=b\mathbf{A}\mathbf{x} = \mathbf{b}everywhere
columns formj=1nxjaj=b\displaystyle\sum_{j=1}^{n} x_j\mathbf{a}_j = \mathbf{b}reframing solvability as reachability — the most useful identity in the chapter
three outcomesnone, exactly one, or infinitely many — never twoclassifying a system before solving it
why not twoA(λx+(1λ)y)=b\mathbf{A}(\lambda\mathbf{x} + (1-\lambda)\mathbf{y}) = \mathbf{b} whenever both are solutionsproving the trichotomy in one line
geometryeach equation is a hyperplane; the solution set is their intersectionbuilding intuition in 2-D and 3-D
resultstatementwhen you use it
matrixARm×n\mathbf{A} \in \mathbb{R}^{m\times n}, entry aija_{ij} in row ii, column jjalways row index first
addition(A+B)ij=aij+bij(\mathbf{A}+\mathbf{B})_{ij} = a_{ij} + b_{ij}, same shape requiredelement-wise, unlike multiplication
multiplicationcij=l=1nailbljc_{ij} = \displaystyle\sum_{l=1}^{n} a_{il}b_{lj}, inner dims must matchcomposition of two linear maps
shape rule(m×n)(n×k)=(m×k)(m\times n)(n\times k) = (m\times k)catching a bug before running anything
Hadamard productcij=aijbijc_{ij} = a_{ij}b_{ij} — a different operationit is what A * B computes in NumPy
columns are imagesjj-th column of A\mathbf{A} is Aej\mathbf{A}\mathbf{e}_jthe idea that makes multiplication obvious
associativity(AB)C=A(BC)(\mathbf{A}\mathbf{B})\mathbf{C} = \mathbf{A}(\mathbf{B}\mathbf{C})reordering a product chain to cut cost
distributivity(A+B)C=AC+BC(\mathbf{A}+\mathbf{B})\mathbf{C} = \mathbf{A}\mathbf{C} + \mathbf{B}\mathbf{C}expanding a derivation
identityImA=AIn=A\mathbf{I}_m\mathbf{A} = \mathbf{A}\mathbf{I}_n = \mathbf{A}, and ImIn\mathbf{I}_m \neq \mathbf{I}_nnote the two different sizes for non-square A\mathbf{A}
non-commutativityABBA\mathbf{A}\mathbf{B} \neq \mathbf{B}\mathbf{A}; shapes can even differnever reorder a product
inverseAA1=I=A1A\mathbf{A}\mathbf{A}^{-1} = \mathbf{I} = \mathbf{A}^{-1}\mathbf{A}, square only, unique when it existsundoing a bijective map
2×22\times2 inverseA1=1a11a22a12a21[a22a12a21a11]\mathbf{A}^{-1} = \dfrac{1}{a_{11}a_{22}-a_{12}a_{21}}\begin{bmatrix}a_{22} & -a_{12}\\ -a_{21} & a_{11}\end{bmatrix}hand calculation; the denominator is the determinant
transpose(A)ij=aji(\mathbf{A}^\top)_{ij} = a_{ji}reshaping to make dimensions agree
symmetricA=A\mathbf{A} = \mathbf{A}^\top, square onlycovariance matrices, Gram matrices, Hessians
(AB)1=B1A1true — the order flips(AB)=BAtrue — the order flips here too(A)=Atrue(A+B)=A+Btrue(A1)=(A)1true(A+B)1A1+B1FALSE    12+412+14A,B symmetric⇏AB symmetricFALSE    but AA always is\begin{aligned} (\mathbf{A}\mathbf{B})^{-1} &= \mathbf{B}^{-1}\mathbf{A}^{-1} &&\text{true — the order \textbf{flips}}\\ (\mathbf{A}\mathbf{B})^\top &= \mathbf{B}^\top\mathbf{A}^\top &&\text{true — the order flips here too}\\ (\mathbf{A}^\top)^\top &= \mathbf{A} &&\text{true}\\ (\mathbf{A}+\mathbf{B})^\top &= \mathbf{A}^\top + \mathbf{B}^\top &&\text{true}\\ (\mathbf{A}^{-1})^\top &= (\mathbf{A}^\top)^{-1} &&\text{true}\\[6pt] (\mathbf{A}+\mathbf{B})^{-1} &\neq \mathbf{A}^{-1} + \mathbf{B}^{-1} &&\textbf{FALSE} \;-\; \tfrac{1}{2+4} \neq \tfrac12 + \tfrac14\\ \mathbf{A}, \mathbf{B} \text{ symmetric} &\not\Rightarrow \mathbf{A}\mathbf{B} \text{ symmetric} &&\textbf{FALSE} \;-\; \text{but } \mathbf{A}^\top\mathbf{A} \text{ always is} \end{aligned}
resultstatementwhen you use it
elementary transformationsexchange two rows; multiply a row by λ0\lambda \neq 0; add one row to anothereach is reversible, so the solution set never changes
augmented matrix[Ab][\,\mathbf{A} \mid \mathbf{b}\,]avoiding rewriting variable names every step
row-echelon formzero rows at the bottom; each pivot strictly right of the one abovereading off rank, consistency, free variables
reduced row-echelon formadditionally every pivot is 11 and alone in its columnreading the solution straight off
basic / free variablespivot columns give basic; the rest are freecounting the solution set’s dimension
free variable countnrk(A)n - \operatorname{rk}(\mathbf{A})predicting the answer’s shape before solving
general solutionx=xp+λ1n1++λknk\mathbf{x} = \mathbf{x}_p + \lambda_1\mathbf{n}_1 + \cdots + \lambda_k\mathbf{n}_kthe shape of every solution set in the book
why it worksA(xp+n)=b+0\mathbf{A}(\mathbf{x}_p + \mathbf{n}) = \mathbf{b} + \mathbf{0}one line, and it explains the whole decomposition
minus-1 trickextend the RREF so the diagonal holds only 11 and 1-1; the 1-1 columns are a null-space basisreading a kernel basis without further elimination
inversion[AIn][InA1][\mathbf{A} \mid \mathbf{I}_n] \rightsquigarrow [\mathbf{I}_n \mid \mathbf{A}^{-1}]it is nn systems at once, which is why inv costs more than solve
pseudo-inverseA+=(AA)1A\mathbf{A}^{+} = (\mathbf{A}^\top\mathbf{A})^{-1}\mathbf{A}^\topdo not compute it this way — it squares the condition number
costGaussian elimination is O(n3)O(n^3)why direct methods stop at thousands, not millions
large systemsstationary iterative (Jacobi, Gauss–Seidel) or Krylov (conjugate gradients)huge sparse problems; needs a norm, hence §3.1

Group (G,)(\mathcal{G}, \otimes) — four axioms:

closurex,yG:xyGassociativity(xy)z=x(yz)neutral elemente  x:xe=ex=xinverse elementx  y:xy=yx=e\begin{aligned} &\text{closure} && \forall x,y \in \mathcal{G}: x \otimes y \in \mathcal{G}\\ &\text{associativity} && (x \otimes y) \otimes z = x \otimes (y \otimes z)\\ &\text{neutral element} && \exists e\; \forall x: x \otimes e = e \otimes x = x\\ &\text{inverse element} && \forall x\; \exists y: x \otimes y = y \otimes x = e \end{aligned}

Abelian adds xy=yxx \otimes y = y \otimes x. General linear group GL(n,R)GL(n,\mathbb{R}): the invertible n×nn\times n matrices under multiplication — a group, and not Abelian.

Vector space (V,+,)(\mathcal{V}, +, \cdot) with +:V×VV+ : \mathcal{V}\times\mathcal{V} \to \mathcal{V} and :R×VV\cdot : \mathbb{R}\times\mathcal{V} \to \mathcal{V}:

1.  (V,+) is an Abelian group2.  λ(x+y)=λx+λyand(λ+ψ)x=λx+ψx3.  λ(ψx)=(λψ)x4.  1x=x\begin{aligned} &1.\; (\mathcal{V}, +) \text{ is an Abelian group}\\ &2.\; \lambda(\mathbf{x}+\mathbf{y}) = \lambda\mathbf{x} + \lambda\mathbf{y} \quad\text{and}\quad (\lambda+\psi)\mathbf{x} = \lambda\mathbf{x} + \psi\mathbf{x}\\ &3.\; \lambda(\psi\mathbf{x}) = (\lambda\psi)\mathbf{x}\\ &4.\; 1\cdot\mathbf{x} = \mathbf{x} \end{aligned}
resultstatementwhen you use it
no vector productab\mathbf{a}\mathbf{b} is undefinedonly abRn×n\mathbf{a}\mathbf{b}^\top \in \mathbb{R}^{n\times n} and abR\mathbf{a}^\top\mathbf{b} \in \mathbb{R} exist
subspace testU\mathcal{U} \neq \emptyset with 0U\mathbf{0} \in \mathcal{U}; closed under scaling; closed under additionall three, every time
trivial subspacesVV itself and {0}\{\mathbf{0}\}edge cases in proofs
homogeneous solutions{x:Ax=0}\{\mathbf{x} : \mathbf{A}\mathbf{x} = \mathbf{0}\} is a subspaceit is the kernel
inhomogeneous solutions{x:Ax=b}\{\mathbf{x} : \mathbf{A}\mathbf{x} = \mathbf{b}\}, b0\mathbf{b} \neq \mathbf{0}, is notit is an affine subspace (§2.8)
intersectionsthe intersection of arbitrarily many subspaces is a subspacebuilding subspaces from constraints
converseevery subspace of Rn\mathbb{R}^n is the solution space of some Ax=0\mathbf{A}\mathbf{x} = \mathbf{0}subspaces and homogeneous systems are the same objects
bounded setsa bounded set is never a subspace unless it is {0}\{\mathbf{0}\}distinguishing subspaces from convex sets (§7.3)
linear combination:v=i=1kλixi\text{linear combination:}\quad \mathbf{v} = \sum_{i=1}^{k}\lambda_i\mathbf{x}_i dependent    λi not all zero with iλixi=0\text{\textbf{dependent}} \iff \exists\,\lambda_i \text{ not all zero with } \sum_i \lambda_i\mathbf{x}_i = \mathbf{0} independent    iλixi=0 forces every λi=0\text{\textbf{independent}} \iff \sum_i \lambda_i\mathbf{x}_i = \mathbf{0} \text{ forces every } \lambda_i = 0
shortcutstatementwhen you use it
no third optionevery set is dependent or independent
zero vectorany set containing 0\mathbf{0} is dependentthe cheapest test; do it first
duplicatestwo identical vectors force dependencesecond cheapest
multiplesxi=λxj\mathbf{x}_i = \lambda\mathbf{x}_j for any λ\lambda forces dependencesign of λ\lambda is irrelevant
the characterisationnonzero vectors with k2k \ge 2 are dependent iff one is a combination of the othersthe conceptual statement
counting boundmm vectors in Rk\mathbb{R}^k with m>km > k are dependentno arithmetic needed
pivot-column testwrite as columns, reduce; independent iff every column is a pivot columnthe reliable method
ordering caveatwhich vectors survive depends on the order offered; the count does notcomparing two people’s answers
coefficient shortcutif xj=Bλj\mathbf{x}_j = \mathbf{B}\boldsymbol\lambda_j with B\mathbf{B}‘s columns independent, then {xj}\{\mathbf{x}_j\} independent iff {λj}\{\boldsymbol\lambda_j\} istesting combinations of combinations cheaply
resultstatementwhen you use it
spanthe set of all linear combinations; always a subspacemanufacturing a subspace
generating setspans all of VVnecessary but not sufficient for a basis
basisa linearly independent generating setthe four characterisations below
dimensionthe common size of every basis, dim(V)\dim(V)it is well defined precisely because the size is invariant
subspace dimensiondim(U)dim(V)\dim(U) \le \dim(V), with equality iff U=VU = Vno same-dimension proper subspaces
dimension caveatit counts directions, not componentsa line in R1000\mathbb{R}^{1000} is one-dimensional
basis of a subspacespanning vectors as columns → row-echelon form → keep the pivot columnsextracting a basis from a spanning set
dimension formuladim(U1U2)=dimU1+dimU2dim(U1+U2)\dim(U_1 \cap U_2) = \dim U_1 + \dim U_2 - \dim(U_1 + U_2)predicting an intersection’s size before computing it

Four equivalent characterisations of a basis B\mathcal{B}:

1.  B is a basis2.  B is a minimal generating set3.  B is a maximal linearly independent set4.  every x has a unique representation x=iλibi\begin{aligned} &1.\; \mathcal{B} \text{ is a basis}\\ &2.\; \mathcal{B} \text{ is a minimal generating set}\\ &3.\; \mathcal{B} \text{ is a maximal linearly independent set}\\ &4.\; \text{every } \mathbf{x} \text{ has a \textbf{unique} representation } \mathbf{x} = \sum_i \lambda_i\mathbf{b}_i \end{aligned}

Rank rk(A)\operatorname{rk}(\mathbf{A}) — the number of independent columns, which equals the number of independent rows:

propertystatementwhen you use it
row = column rankrk(A)=rk(A)\operatorname{rk}(\mathbf{A}) = \operatorname{rk}(\mathbf{A}^\top)switching whichever is easier to count
image dimensiondim(Im(A))=rk(A)\dim(\operatorname{Im}(\mathbf{A})) = \operatorname{rk}(\mathbf{A})how much the map can reach
invertibilityARn×n\mathbf{A} \in \mathbb{R}^{n\times n} invertible     rk(A)=n\iff \operatorname{rk}(\mathbf{A}) = ndeciding without computing an inverse
solvabilityAx=b\mathbf{A}\mathbf{x} = \mathbf{b} solvable     rk(A)=rk(Ab)\iff \operatorname{rk}(\mathbf{A}) = \operatorname{rk}(\mathbf{A}\mid\mathbf{b})classifying a system in two rank calls
null-space dimensiondim(ker(A))=nrk(A)\dim(\ker(\mathbf{A})) = n - \operatorname{rk}(\mathbf{A})the free-variable count
full rankrk(A)=min(m,n)\operatorname{rk}(\mathbf{A}) = \min(m,n)not the same as invertible
near-dependencerank cannot see it; use np.linalg.condthe practical diagnostic on real data
Φ linear    x,y,λ,ψ:  Φ(λx+ψy)=λΦ(x)+ψΦ(y)\Phi \text{ linear} \iff \forall\mathbf{x},\mathbf{y},\lambda,\psi:\; \Phi(\lambda\mathbf{x} + \psi\mathbf{y}) = \lambda\Phi(\mathbf{x}) + \psi\Phi(\mathbf{y}) consequence:Φ(0)=0— the cheapest disqualifier\text{consequence:}\quad \Phi(\mathbf{0}) = \mathbf{0} \quad\text{— the cheapest disqualifier}
resultstatementwhen you use it
isomorphismlinear and bijective“the same space in disguise”
endomorphismΦ:VV\Phi : V \to V linearChapter 4’s subject
automorphismΦ:VV\Phi : V \to V linear and bijectiveinvertible endomorphism
isomorphism theoremfinite-dimensional V,WV, W isomorphic     dimV=dimW\iff \dim V = \dim Wwhy Rm×nRmn\mathbb{R}^{m\times n} \cong \mathbb{R}^{mn}
coordinatesx=iαibi\mathbf{x} = \sum_i \alpha_i\mathbf{b}_i with BB an ordered basisordering matters — coordinates are a list
transformation matrixcolumn jj of AΦ\mathbf{A}_\Phi = coordinates of Φ(bj)\Phi(\mathbf{b}_j) in CCconstructing the matrix of a map
coordinate mappingy^=AΦx^\hat{\mathbf{y}} = \mathbf{A}_\Phi\hat{\mathbf{x}}matrices map coordinates, not vectors
basis changeA~Φ=T1AΦS\tilde{\mathbf{A}}_\Phi = \mathbf{T}^{-1}\mathbf{A}_\Phi\mathbf{S}read right to left: translate in, map, translate out
equivalenceA~=T1AS\tilde{\mathbf{A}} = \mathbf{T}^{-1}\mathbf{A}\mathbf{S}general basis change
similarityA~=S1AS\tilde{\mathbf{A}} = \mathbf{S}^{-1}\mathbf{A}\mathbf{S}endomorphisms; similar implies equivalent, not conversely
compositionAΨΦ=AΨAΦ\mathbf{A}_{\Psi\circ\Phi} = \mathbf{A}_\Psi\mathbf{A}_\Phiwhy multiplication is composition
kernelker(Φ)={v:Φ(v)=0}Rn\ker(\Phi) = \{\mathbf{v} : \Phi(\mathbf{v}) = \mathbf{0}\} \subseteq \mathbb{R}^n (the width)what gets destroyed
imageIm(Φ)=Φ(V)Rm\operatorname{Im}(\Phi) = \Phi(V) \subseteq \mathbb{R}^m (the height)the column space; what can be reached
injectivityΦ\Phi injective     ker(Φ)={0}\iff \ker(\Phi) = \{\mathbf{0}\}the all-pairs test collapses to one system
rank-nullitydim(kerΦ)+dim(ImΦ)=dim(V)\dim(\ker\Phi) + \dim(\operatorname{Im}\Phi) = \dim(V)a conservation law; the fundamental theorem of linear mappings
three-way equivalenceif dimV=dimW\dim V = \dim W: injective     \iff surjective     \iff bijectivesquare matrices only — check one, get three
similar invariantssimilar matrices share determinant, trace and eigenvaluesthe fastest check on any basis change
resultstatementwhen you use it
affine subspaceL=x0+UL = \mathbf{x}_0 + U with UU a subspacea subspace slid off the origin
not a subspaceexcludes 0\mathbf{0} whenever x0U\mathbf{x}_0 \notin U; not closed under either operationit fails all three subspace tests
parametric equationx=x0+λ1b1++λkbk\mathbf{x} = \mathbf{x}_0 + \lambda_1\mathbf{b}_1 + \cdots + \lambda_k\mathbf{b}_kdescribing a line, plane or hyperplane
containmentLL~    UU~L \subseteq \tilde{L} \iff U \subseteq \tilde{U} and x0x~0U~\mathbf{x}_0 - \tilde{\mathbf{x}}_0 \in \tilde{U}comparing two descriptions of possibly-equal sets
linek=1k = 1one support point, one direction
planek=2k = 2two independent directions
hyperplanek=n1k = n-1codimension one, so it has two sides — the decision boundary
inhomogeneous solutionsempty, or an affine subspace of dimension nrk(A)n - \operatorname{rk}(\mathbf{A})§2.3’s general solution, renamed
single equationiλixi=b\sum_i \lambda_ix_i = b with some λi0\lambda_i \neq 0 defines a hyperplaneone equation removes one dimension
converseevery kk-dimensional affine subspace of Rn\mathbb{R}^n solves some system with rk=nk\operatorname{rk} = n-kaffine subspaces and inhomogeneous systems coincide
affine mappingϕ(x)=a+Φ(x)\phi(\mathbf{x}) = \mathbf{a} + \Phi(\mathbf{x}), a\mathbf{a} the translation vectorwhat a “linear layer” actually computes
decompositionevery affine map is uniquely a linear map followed by a translationseparating the two parts
preserveddimension and parallelismwhy affine maps keep flat things flat
augmentation trickappend 11 to x\mathbf{x}, absorb a\mathbf{a} into an extra columnwhy design matrices have a column of ones

If you keep only six facts from Chapter 2:

1.    Ax=b asks whether b is a combination of A’s columns.2.    The columns of A are Aej — where the basis vectors go.3.    Every solution set is xp+ker(A).4.    rk(A) decides invertibility, solvability, and both dimensions.5.    dim(kerΦ)+dim(ImΦ)=dim(V).6.    Affine=linear+a translation, and that translation is the bias term.\begin{aligned} &\textbf{1.}\;\; \mathbf{A}\mathbf{x} = \mathbf{b} \text{ asks whether } \mathbf{b} \text{ is a combination of } \mathbf{A}\text{'s columns.}\\[3pt] &\textbf{2.}\;\; \text{The columns of } \mathbf{A} \text{ are } \mathbf{A}\mathbf{e}_j \text{ — where the basis vectors go.}\\[3pt] &\textbf{3.}\;\; \text{Every solution set is } \mathbf{x}_p + \ker(\mathbf{A}).\\[3pt] &\textbf{4.}\;\; \operatorname{rk}(\mathbf{A}) \text{ decides invertibility, solvability, and both dimensions.}\\[3pt] &\textbf{5.}\;\; \dim(\ker\Phi) + \dim(\operatorname{Im}\Phi) = \dim(V).\\[3pt] &\textbf{6.}\;\; \text{Affine} = \text{linear} + \text{a translation, and that translation is the bias term.} \end{aligned}
you wantusenot
solve a square systemnp.linalg.solve(A, b)inv(A) @ b
least squares, any shapenp.linalg.lstsq(A, b, rcond=None)the normal equations — they square κ\kappa
the pseudo-inverse itselfnp.linalg.pinv(A)forming (AA)1A(\mathbf{A}^\top\mathbf{A})^{-1}\mathbf{A}^\top
ranknp.linalg.matrix_rank(A)counting nonzero singular values by eye
how close to singularnp.linalg.cond(A)the rank — it cannot see near-dependence
matrix productA @ BA * B, which is the Hadamard product
a genuine column vectorx.reshape(-1, 1)x.T on a 1-D array, which does nothing
compare two resultsnp.allclose(a, b)a == b

Next: Analytic Geometry — adds length, angle and distance to everything above.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading