Skip to content

9.8 Linear algebra problem set, part b: inner products, SVD and low rank, matmul accounting and the roofline

The later sections of this chapter build the first tools that live on vectors. word2vec skip-gram with negative sampling, and the PPMI-SVD baseline in AI Engineering factors a word co-occurrence matrix with the SVD of SVD, Eckart-Young low rank, and least squares and ranks neighbours with the cosine similarity of Inner products, projections, cosine similarity, and top-k. Later, LoRA: low-rank adaptation with PiSSA initialization and merging and Multi-head latent attention reuse the same low-rank factorization on weight matrices, and the TinyStories capstone fits a scaling law with the same least squares.

Concepts from other sections (14)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

Before the code, it pays to compute these quantities by hand on small cases: an angle, a projection, a singular value, the error of a truncation. The set closes with arithmetic that comes back when Cache-blocked, packed, batch-invariant matmul in C tiles the C matmul: how many FLOPs and how many bytes a product costs, and when the machine is waiting on memory instead of computing.

This is a pen-and-paper set. It assumes the linear algebra problem set, part a, the SVD and inner-product sections, and the chapter opening. Every problem is followed by a collapsed worked answer with the final result, the derivation, and the common wrong answers and why they are wrong. There are 14 exact answers (counting lettered parts) and 2 proofs (q3, q8); model proofs for those two are also in course/solutions/solve/S-M03b/. Try each problem before opening its answer.

Learning objectives

  • Compute inner products, cosines, and projections, and prove the Cauchy-Schwarz inequality.
  • Find singular values through the eigenvalues of A⊤AA^\top A and compute the error of a truncated SVD in both norms.
  • Count the parameters of a low-rank factorization.
  • Count the FLOPs and bytes of a matmul and a matrix-vector product, and use the roofline to decide whether a kernel is memory-bound or compute-bound.

These are the facts the problems draw on. The notation:

SymbolMeaningType / shape
a⋅ba \cdot b, ∥a∥\lVert a \rVertinner product ∑iaibi\sum_i a_i b_i and length a⋅a\sqrt{a \cdot a}scalars
cos⁡θ=a⋅b∥a∥∥b∥\cos\theta = \frac{a \cdot b}{\lVert a \rVert \lVert b \rVert}cosine similarityscalar in [−1,1][-1, 1]
proj⁡ab=a⋅ba⋅aa\operatorname{proj}_a b = \frac{a \cdot b}{a \cdot a} aprojection of bb onto the line through aavector
σ1≥σ2≥…\sigma_1 \ge \sigma_2 \ge \dotssingular valuesscalars ≥0\ge 0
ArA_rtruncated SVD of rank rrmatrix
∥⋅∥2\lVert \cdot \rVert_2, ∥⋅∥F\lVert \cdot \rVert_Fspectral and Frobenius normsscalars
FLOPone floating-point add or multiply
IIarithmetic intensity: FLOPs per byte moved between memory and the processorFLOP/byte
PP, β\betapeak compute (FLOP/s) and memory bandwidth (byte/s)

The inner product a⋅b=∥a∥∥b∥cos⁡θa \cdot b = \lVert a \rVert \lVert b \rVert \cos\theta carries both length and angle; cosine similarity keeps the angle by dividing by both lengths. Projecting bb onto the line through aa keeps the component of bb along aa: the coefficient cc in b=c a+rb = c\,a + r with r⊥ar \perp a is c=(a⋅b)/(a⋅a)c = (a \cdot b)/(a \cdot a), divided by a⋅aa \cdot a and not by ∥a∥\lVert a \rVert. The Cauchy-Schwarz inequality ∣a⋅b∣≤∥a∥∥b∥\lvert a \cdot b \rvert \le \lVert a \rVert \lVert b \rVert (q3) is what makes the cosine a cosine, keeping it in [−1,1][-1, 1].

A=UΣV⊤A = U\Sigma V^\top with orthonormal UU, VV and σ1≥σ2≥⋯≥0\sigma_1 \ge \sigma_2 \ge \dots \ge 0. Multiplying out, A⊤A=VΣ2V⊤A^\top A = V\Sigma^2 V^\top, so σi2\sigma_i^2 are the eigenvalues of A⊤AA^\top A (q8): singular values are never simply the diagonal of AA, and a matrix has min⁡(m,n)\min(m, n) of them. The spectral norm is σ1\sigma_1 and the Frobenius norm is ∑iσi2\sqrt{\sum_i \sigma_i^2}. Eckart-Young: the truncated SVD ArA_r is the closest rank-rr matrix, with ∥A−Ar∥2=σr+1\lVert A - A_r \rVert_2 = \sigma_{r+1} and ∥A−Ar∥F=∑i>rσi2\lVert A - A_r \rVert_F = \sqrt{\sum_{i > r}\sigma_i^2}. A rank-rr factorization of a d×dd \times d matrix costs 2dr2dr numbers.

C=ABC = AB with AA of shape M×KM \times K and BB of shape K×NK \times N has MNMN entries, each a sum of KK products: KK multiplies and KK adds, so 2MNK2MNK FLOPs (the usual convention counts the KK-th add even though a sum of KK terms needs only K−1K - 1). The least it can move is reading AA and BB once and writing CC once: 4(MK+KN+MN)4(MK + KN + MN) bytes in fp32. Arithmetic intensity is the ratio, FLOPs per byte. The roofline model says a kernel runs at most at min⁡(P,Iβ)\min(P, I\beta) FLOP/s: below the ridge point I=P/βI = P/\beta it is memory-bound (faster memory helps, more compute does not), above it compute-bound. For a square N×NN \times N matmul the intensity grows like NN; for a matrix-vector product it stays near 1/21/2, whatever NN, which is why decoding is memory-bound.

These are siblings of q1, q6, and q10, not problems of the set.

Cosine. u=(1,0,1)u = (1, 0, 1), v=(1,1,0)v = (1, 1, 0): u⋅v=1u \cdot v = 1, ∥u∥=∥v∥=2\lVert u \rVert = \lVert v \rVert = \sqrt{2}, cos⁡θ=1/2\cos\theta = 1/2 (60°60°).

Singular values and truncation. A=(2001)A = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} is already diagonal with non-negative entries in order, so U=V=IU = V = I and σ=(2,1)\sigma = (2, 1). A1=(2000)A_1 = \begin{pmatrix} 2 & 0 \\ 0 & 0 \end{pmatrix}, and A−A1=(0001)A - A_1 = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} has ∥⋅∥2=∥⋅∥F=1=σ2\lVert \cdot \rVert_2 = \lVert \cdot \rVert_F = 1 = \sigma_2. For (0−310)\begin{pmatrix} 0 & -3 \\ 1 & 0 \end{pmatrix} the diagonal says nothing: A⊤A=(1009)A^\top A = \begin{pmatrix} 1 & 0 \\ 0 & 9 \end{pmatrix}, so σ=(3,1)\sigma = (3, 1).

Roofline. A machine with P=1P = 1 TFLOP/s and β=50\beta = 50 GB/s has its ridge at 1012/(5×1010)=2010^{12}/(5 \times 10^{10}) = 20 FLOP/byte. An fp32 N×NN \times N matmul has intensity 2N3/(12N2)=N/62N^3 / (12 N^2) = N/6, so it is compute-bound from N/6≥20N/6 \ge 20, N≥120N \ge 120. A matrix-vector product at intensity about 1/21/2 runs at most at 50×109/2=2550 \times 10^9 / 2 = 25 GFLOP/s, 2.5% of peak.

The problems are grouped by topic, in the order above. Answers are exact (5\sqrt5, not 2.236). Lettered parts are answered separately. The tag after each problem says what kind of answer is expected.

q1. Let u=(1,2,2)u = (1, 2, 2) and v=(2,0,1)v = (2, 0, 1). Give (a) the inner product u⋅vu \cdot v and (b) the cosine of the angle between uu and vv. [number]

Answer

(a) 44. (b) 435=4515≈0.596\frac{4}{3\sqrt5} = \frac{4\sqrt5}{15} \approx 0.596. (a) u⋅v=1⋅2+2⋅0+2⋅1=4u \cdot v = 1 \cdot 2 + 2 \cdot 0 + 2 \cdot 1 = 4. (b) ∥u∥=1+4+4=3\lVert u\rVert = \sqrt{1 + 4 + 4} = 3 and ∥v∥=4+0+1=5\lVert v\rVert = \sqrt{4 + 0 + 1} = \sqrt5, so cos⁡θ=435\cos\theta = \frac{4}{3\sqrt5}. The cosine_sim of Inner products, projections, cosine similarity, and top-k divides by both lengths in the same way. Common mistakes for (b): 415\frac{4}{15}, which divides by ∥u∥ ∥v∥2\lVert u\rVert\,\lVert v\rVert^2, and 45\frac45, which divides by ∥v∥2\lVert v\rVert^2 only; neither is invariant under rescaling the vectors.

q2. Give the orthogonal projection of b=(1,2,3)b = (1, 2, 3) onto the line spanned by a=(1,1,1)a = (1, 1, 1). [vector]

Answer

(2,2,2)(2, 2, 2). a⋅ba⋅aa=63(1,1,1)\frac{a \cdot b}{a \cdot a}a = \frac{6}{3}(1, 1, 1). Its project divides by v⋅vv \cdot v for the same reason. Common mistakes: (23,23,23)(2\sqrt3, 2\sqrt3, 2\sqrt3), which divides by ∥a∥\lVert a\rVert instead of a⋅aa \cdot a, and (−1,0,1)(-1, 0, 1), which is the residual b−proj⁡abb - \operatorname{proj}_a b rather than the projection.

q3. Prove the Cauchy-Schwarz inequality ∣a⋅b∣≤∥a∥ ∥b∥\lvert a \cdot b \rvert \le \lVert a \rVert \, \lVert b \rVert for vectors a,b∈Rna, b \in \mathbb{R}^n, with equality exactly when one is a multiple of the other. Conclude that cosine similarity lies in [−1,1][-1, 1]. [proof]

Answer

Claim. For a,b∈Rna, b \in \mathbb{R}^n, ∣a⋅b∣≤∥a∥ ∥b∥\lvert a \cdot b\rvert \le \lVert a\rVert\,\lVert b\rVert, with equality exactly when one is a scalar multiple of the other.

Proof. If b=0b = 0, both sides are 0 and b=0⋅ab = 0 \cdot a: equality holds. Let b≠0b \ne 0. A squared length is never negative, so for every real tt, 0≤∥a−tb∥2=∥a∥2−2t (a⋅b)+t2∥b∥2.0 \le \lVert a - tb\rVert^2 = \lVert a\rVert^2 - 2t\,(a \cdot b) + t^2\lVert b\rVert^2 . Choose t=(a⋅b)/∥b∥2t = (a \cdot b)/\lVert b\rVert^2: 0≤∥a∥2−2(a⋅b)2∥b∥2+(a⋅b)2∥b∥2=∥a∥2−(a⋅b)2∥b∥2.0 \le \lVert a\rVert^2 - 2\frac{(a \cdot b)^2}{\lVert b\rVert^2} + \frac{(a \cdot b)^2}{\lVert b\rVert^2} = \lVert a\rVert^2 - \frac{(a \cdot b)^2}{\lVert b\rVert^2} . Multiplying by ∥b∥2>0\lVert b\rVert^2 > 0 gives (a⋅b)2≤∥a∥2∥b∥2(a \cdot b)^2 \le \lVert a\rVert^2\lVert b\rVert^2, and taking non-negative square roots gives the inequality.

Equality. If equality holds, the chain gives ∥a−tb∥2=0\lVert a - tb\rVert^2 = 0 for that tt, so a=tba = tb. Conversely, if a=sba = sb, then ∣a⋅b∣=∣s∣ ∥b∥2=∥a∥ ∥b∥\lvert a \cdot b\rvert = \lvert s\rvert\,\lVert b\rVert^2 = \lVert a\rVert\,\lVert b\rVert (and symmetrically if b=sab = sa).

Cosine. For nonzero a,ba, b, dividing by ∥a∥ ∥b∥>0\lVert a\rVert\,\lVert b\rVert > 0 gives −1≤a⋅b∥a∥ ∥b∥≤1-1 \le \frac{a \cdot b}{\lVert a\rVert\,\lVert b\rVert} \le 1, with ±1\pm 1 exactly for parallel or opposite vectors.

A complete proof treats b=0b = 0 separately, expands ∥a−tb∥2≥0\lVert a - tb\rVert^2 \ge 0, picks tt (or uses the discriminant of the quadratic in tt), and proves both directions of the equality case. Model proof also in q3.md.

q4. A=(1101)A = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}. Give (a) its largest singular value σ1\sigma_1 and (b) its smallest σ2\sigma_2. [number]

Answer

(a) σ1=1+52\sigma_1 = \frac{1 + \sqrt5}{2}. (b) σ2=5−12\sigma_2 = \frac{\sqrt5 - 1}{2}. A⊤A=(1112)A^\top A = \begin{pmatrix} 1 & 1 \\ 1 & 2 \end{pmatrix} has trace 3 and determinant 1, so its eigenvalues are 3±52\frac{3 \pm \sqrt5}{2}. The singular values are their square roots, and (1±52)2=6±254=3±52\left(\frac{1 \pm \sqrt5}{2}\right)^2 = \frac{6 \pm 2\sqrt5}{4} = \frac{3 \pm \sqrt5}{2} gives them in closed form (≈1.618\approx 1.618 and 0.6180.618). Check: σ1σ2=1=∣det⁡A∣\sigma_1\sigma_2 = 1 = \lvert\det A\rvert. Common mistakes: 1 for either part, read off the diagonal (singular values are not the diagonal unless AA is diagonal and non-negative), and 3±52\frac{3 \pm \sqrt5}{2}, the eigenvalues of A⊤AA^\top A without the square root.

q5. Give the singular values of A=(023000)A = \begin{pmatrix} 0 & 2 \\ 3 & 0 \\ 0 & 0 \end{pmatrix} in descending order. [vector]

Answer

(3,2)(3, 2). A⊤A=(9004)A^\top A = \begin{pmatrix} 9 & 0 \\ 0 & 4 \end{pmatrix}, so the singular values are 3 and 2, listed in descending order as the svd of SVD, Eckart-Young low rank, and least squares returns them (the signs and the order of the columns live in UU and VV). Common mistakes: (2,3)(2, 3), the column order, and (3,2,0)(3, 2, 0): a 3×23 \times 2 matrix has min⁡(m,n)=2\min(m, n) = 2 singular values.

q6. A 3×33 \times 3 matrix AA has singular values 5,3,15, 3, 1, and ArA_r is its truncated SVD of rank rr. Give (a) ∥A−A1∥2\lVert A - A_1 \rVert_2, (b) ∥A−A1∥F\lVert A - A_1 \rVert_F, (c) the smallest rr with ∥A−Ar∥F≤3/2\lVert A - A_r \rVert_F \le 3/2. [number]

Answer

(a) 33. (b) 10\sqrt{10}. (c) r=2r = 2. By Eckart-Young, A−A1A - A_1 has singular values 3,13, 1. (a) Its spectral norm is the largest, σ2=3\sigma_2 = 3: the first dropped singular value. (b) Its Frobenius norm is 32+12=10≈3.16\sqrt{3^2 + 1^2} = \sqrt{10} \approx 3.16. (c) ∥A−A1∥F=10>32\lVert A - A_1\rVert_F = \sqrt{10} > \frac32, while ∥A−A2∥F=1≤32\lVert A - A_2\rVert_F = 1 \le \frac32, so r=2r = 2. Common mistakes: 1 for (a) (the last singular value rather than the first dropped), 10\sqrt{10} for (a) (the Frobenius error), and 4 for (b) (summing the dropped values instead of their squares).

q7. A weight matrix of shape 4096×40964096 \times 4096 is replaced by a product BCBC with BB of shape 4096×r4096 \times r and CC of shape r×4096r \times 4096 (a rank-rr adapter). Give the number of parameters in BB and CC together. [expr in r]

Answer

8192 r8192\,r. BB has 4096r4096r entries and CC has r⋅4096r \cdot 4096, so together 2⋅4096⋅r2 \cdot 4096 \cdot r: the 2dr2dr that LoRA (LoRA: low-rank adaptation with PiSSA initialization and merging) trains instead of d2=16 777 216d^2 = 16\,777\,216. At r=8r = 8 that is 65 536 parameters, 0.4% of the full matrix. Common mistakes: 4096r4096r (one factor only) and r2r^2.

q8. Let A=UΣV⊤A = U \Sigma V^\top be an SVD of a real m×nm \times n matrix. Prove that (i) the columns of VV are eigenvectors of A⊤AA^\top A with eigenvalues σi2\sigma_i^2, so the singular values are the square roots of the eigenvalues of A⊤AA^\top A, and (ii) max⁡∥x∥=1∥Ax∥=σ1\max_{\lVert x \rVert = 1} \lVert A x \rVert = \sigma_1. [proof]

Answer

Claim. Let A=UΣV⊤A = U\Sigma V^\top with UU (m×mm \times m) and VV (n×nn \times n) orthogonal and Σ\Sigma (m×nm \times n) zero except Σii=σi≥0\Sigma_{ii} = \sigma_i \ge 0, σ1≥σ2≥…\sigma_1 \ge \sigma_2 \ge \dots. Then (i) A⊤Avi=σi2viA^\top A v_i = \sigma_i^2 v_i for each column viv_i of VV (with σi=0\sigma_i = 0 beyond min⁡(m,n)\min(m, n)), and (ii) max⁡∥x∥=1∥Ax∥=σ1\max_{\lVert x\rVert = 1}\lVert Ax\rVert = \sigma_1.

Proof. (i) Using U⊤U=IU^\top U = I, A⊤A=VΣ⊤U⊤UΣV⊤=V(Σ⊤Σ)V⊤A^\top A = V\Sigma^\top U^\top U\Sigma V^\top = V(\Sigma^\top\Sigma)V^\top, where Σ⊤Σ\Sigma^\top\Sigma is diagonal with entries σi2\sigma_i^2. With vi=Veiv_i = Ve_i and V⊤V=IV^\top V = I: A⊤Avi=V(Σ⊤Σ)ei=σi2viA^\top A v_i = V(\Sigma^\top\Sigma)e_i = \sigma_i^2 v_i. The viv_i form a basis, so these are all the eigenvalues, and σi=λi(A⊤A)\sigma_i = \sqrt{\lambda_i(A^\top A)}.

(ii) Let ∥x∥=1\lVert x\rVert = 1 and c=V⊤xc = V^\top x; ∥c∥=1\lVert c\rVert = 1 because V⊤V^\top is orthogonal. Then ∥Ax∥2=x⊤A⊤Ax=c⊤(Σ⊤Σ)c=∑iσi2ci2≤σ12∑ici2=σ12.\lVert Ax\rVert^2 = x^\top A^\top A x = c^\top(\Sigma^\top\Sigma)c = \sum_i \sigma_i^2 c_i^2 \le \sigma_1^2\sum_i c_i^2 = \sigma_1^2 . At x=v1x = v_1, c=e1c = e_1 and ∥Av1∥=σ1\lVert Av_1\rVert = \sigma_1, so the bound is attained.

The essential steps are the two orthogonality cancellations (U⊤UU^\top U in (i), ∥V⊤x∥=∥x∥\lVert V^\top x\rVert = \lVert x\rVert in (ii)) and showing the maximum is attained, not just bounded. This is why Eckart-Young’s spectral error is σr+1\sigma_{r+1}. Model proof also in q8.md.

q9. (a) Give the number of floating-point operations (one multiply and one add per term) of C=ABC = AB with AA of shape M×KM \times K and BB of shape K×NK \times N. [expr in M, N, K] (b) A matrix-vector product y=Wxy = Wx with WW of shape N×NN \times N in fp32 (4 bytes per number) reads WW and xx once and writes yy once. Give its arithmetic intensity, floating-point operations per byte moved. [expr in N]

Answer

(a) 2MNK2MNK. (b) 2N24N2+8N=N2N+4\frac{2N^2}{4N^2 + 8N} = \frac{N}{2N + 4}. (a) CC has MNMN entries, each KK multiplies and KK adds. (b) A matrix-vector product does 2N22N^2 FLOPs and moves 4(N2+N+N)4(N^2 + N + N) bytes (WW, xx, yy), so its intensity is just under 12\frac12 for every NN. That is why decoding, one matrix-vector product per weight matrix per token, is memory-bound. Common mistakes: MNKMNK for (a), counting multiply-adds instead of FLOPs; 2N24N2=12\frac{2N^2}{4N^2} = \frac12 for (b), forgetting to move xx and yy; and N/6N/6, the square matmul’s intensity.

q10. A square N×NN \times N fp32 matmul reads AA and BB once and writes CC once. (a) Give its arithmetic intensity in FLOP per byte. [expr in N] (b) A machine has a peak of 1010 TFLOP/s and a memory bandwidth of 100100 GB/s. Give the smallest NN at which this matmul reaches the compute-bound side of the roofline (intensity at least the ridge point). [number]

Answer

(a) N/6N/6. (b) N=600N = 600. (a) 2N32N^3 FLOPs over 4⋅3N2=12N24 \cdot 3N^2 = 12N^2 bytes gives N6\frac{N}{6}. It grows with NN, which is why tiling a large matmul (Cache-blocked, packed, batch-invariant matmul in C) pays off. (b) The ridge point is 10×1012100×109=100\frac{10 \times 10^{12}}{100 \times 10^9} = 100 FLOP/byte, and N6≥100\frac{N}{6} \ge 100 gives N≥600N \ge 600. Common mistakes: 2N3\frac{2N}{3} for (a) (numbers counted instead of 4-byte values), N12\frac{N}{12} (multiply-adds instead of FLOPs), 100 for (b) (the ridge point itself, not NN), and 150 (from the intensity 2N/32N/3).

The wrong answers above fall into a few patterns, each with a recognizable symptom:

MistakeSymptomThe habit that avoids it
Dividing the inner product by one length, or by squared lengthsa “cosine” outside [−1,1][-1, 1] or one that changes when a vector is rescaleddivide by ∥u∥ ∥v∥\lVert u\rVert\,\lVert v\rVert, each length once (q1 b)
Dividing by ∥a∥\lVert a \rVert instead of a⋅aa \cdot a in a projectionthe projection scaled by ∥a∥\lVert a \rVertdivide by a⋅aa \cdot a (q2)
Reading singular values off the diagonalwrong whenever AA is not diagonal with non-negative entriesgo through the eigenvalues of A⊤AA^\top A (q4)
Reporting eigenvalues of A⊤AA^\top A as singular valuesthe square of the right answertake the square root at the end (q4)
Listing max⁡(m,n)\max(m, n) singular values, or not sorting thema padded or unordered spectrum; low_rank keeps the wrong directionslist min⁡(m,n)\min(m, n) values in descending order (q5)
Confusing the spectral and the Frobenius error, or summing values instead of squaresthe wrong truncation rank chosen for a budgetuse σr+1\sigma_{r+1} for the spectral error and the root of the sum of squares for the Frobenius error (q6)
Counting multiply-adds as FLOPs, or numbers as bytesintensities off by a factor 2 or 4; the wrong side of the ridgecount 2 FLOPs per term and 4 bytes per fp32 number (q9 a, q10)
Forgetting the vector reads in a matrix-vector productan intensity of exactly 1/2 instead of slightly lesscount the bytes of WW, xx, and yy (q9 b)

Looking back, this set builds on the elimination, bases, eigenvalues, and QR of the linear algebra problem set, part a. q1 and q2 are cosine_sim and project from Inner products, projections, cosine similarity, and top-k done by hand, and q4 to q8 are svd, low_rank, and the eigenvalue bridge of SVD, Eckart-Young low rank, and least squares.

Looking forward, in AI Engineering: the PPMI-SVD embeddings of word2vec skip-gram with negative sampling, and the PPMI-SVD baseline keep the top singular directions, and its analogies rank by cosine. LoRA: low-rank adaptation with PiSSA initialization and merging trains LoRA’s 2dr2dr parameters (q7) and initializes from PiSSA’s truncated SVD. In Cache-blocked, packed, batch-invariant matmul in C, intensity and the ridge point decide the tile size. And in The KV cache, incremental decoding, and generate, decoding is a matrix-vector product per token, and so memory-bound (q9 b).

  • Strang, Introduction to Linear Algebra, sections 1.2, 4.2, 7.1 to 7.2.
  • Trefethen and Bau, Numerical Linear Algebra, lectures 4 and 5.
  • Williams, Waterman, and Patterson, “Roofline: an insightful visual performance model for multicore architectures” (CACM 2009).
  • Cosine similarity divides the inner product by both lengths, and Cauchy-Schwarz keeps it in [−1,1][-1, 1] (q1, q3).
  • A projection onto a line divides by a⋅aa \cdot a, not by ∥a∥\lVert a \rVert (q2).
  • Singular values are the square roots of the eigenvalues of A⊤AA^\top A, never the diagonal of AA, and a matrix has min⁡(m,n)\min(m, n) of them (q4, q5, q8).
  • Truncating the SVD after rr terms leaves an error of exactly the first dropped singular value in the spectral norm and the root of the sum of squares of the dropped ones in the Frobenius norm (q6); a rank-rr factorization of a d×dd \times d matrix costs 2dr2dr numbers (q7).
  • A matmul does 2MNK2MNK FLOPs on O(MK+KN+MN)O(MK + KN + MN) bytes, so its intensity grows with size; a matrix-vector product does about half a FLOP per byte whatever its size, which is why decoding is memory-bound (q9, q10).