[1] 16
prod(x)[1] 80
Mathematical notation is compressed language. Once you can read it, it is faster and more precise than English. Until you can, it is a wall.
This chapter is the key. It is a reference rather than a narrative — skim it now, come back when a symbol stops you. Every convention used in the rest of the book is fixed here.
Numbers come in families, each contained in the next.
| Symbol | Name | Contains | Example |
|---|---|---|---|
| \(\mathbb{N}\) | naturals | counting numbers | \(1, 2, 3, \dots\) |
| \(\mathbb{Z}\) | integers | naturals, zero, negatives | \(-2, 0, 7\) |
| \(\mathbb{Q}\) | rationals | ratios of integers | \(\tfrac{3}{4}\), \(-0.25\) |
| \(\mathbb{R}\) | reals | rationals plus everything between | \(\pi\), \(\sqrt{2}\) |
| \(\mathbb{C}\) | complex | reals plus imaginary parts | \(2 + 3i\) |
\[ \mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C} \]
The blackboard-bold letters are a fixed convention: seeing \(\mathbb{R}\) tells you “real numbers” before you read anything else. This book lives almost entirely in \(\mathbb{R}\), with \(\mathbb{C}\) appearing only when a rotation forces it (Section 8.2).
Collections of numbers get a superscript:
| Notation | Meaning |
|---|---|
| \(\mathbb{R}^n\) | vectors of \(n\) real numbers |
| \(\mathbb{R}^{m \times n}\) | \(m \times n\) real matrices |
| \(\mathbb{R}^{+}\) | strictly positive reals |
| \(\mathbb{R}_{\geq 0}\) | non-negative reals |
And ranges of the real line get brackets, where square means included and round means excluded:
| Notation | Meaning | In words |
|---|---|---|
| \([a, b]\) | \(a \leq x \leq b\) | closed |
| \((a, b)\) | \(a < x < b\) | open |
| \([a, b)\) | \(a \leq x < b\) | half-open |
| \((0, \infty)\) | \(x > 0\) | infinity is never included |
\((a, b)\) is ambiguous on the page: it can mean an open interval or an ordered pair or a point. Only context distinguishes them. Probabilities live in \([0,1]\); a correlation of \((0.3, 0.8)\) is probably a confidence interval; \((3, 1)\) next to a picture of a plane is a point.
The core conventions, fixed for the whole book. Shape is carried by typeface, which is why the distinction between \(a\), \(\mathbf{a}\), and \(\mathbf{A}\) is load-bearing rather than decorative.
| Object | Convention | Example |
|---|---|---|
| Scalar | lowercase italic | \(a\), \(\lambda\), \(n\) |
| Vector | lowercase bold | \(\mathbf{x}\), \(\boldsymbol{\beta}\) |
| Matrix | uppercase bold | \(\mathbf{A}\), \(\mathbf{X}\) |
| Element of a vector | italic, one subscript | \(x_i\) |
| Element of a matrix | italic, two subscripts | \(a_{ij}\) (row \(i\), column \(j\)) |
| Column of a matrix | bold, one subscript | \(\mathbf{a}_j\) |
| Set | blackboard bold or uppercase | \(\mathbb{R}\), \(S\) |
| Random variable | uppercase italic | \(X\) |
| Transpose | superscript \(\top\) | \(\mathbf{A}^\top\) |
| Inverse | superscript \(-1\) | \(\mathbf{A}^{-1}\) |
| Estimate | hat | \(\hat{\beta}\), \(\hat{y}\) |
| Mean | bar | \(\bar{x}\) |
| Zero vector, identity | bold | \(\mathbf{0}\), \(\mathbf{I}\) |
Two conventions that save constant confusion:
Vectors are columns. \(\mathbf{x} \in \mathbb{R}^n\) means an \(n \times 1\) matrix. A row vector is written \(\mathbf{x}^\top\). This is why \(\mathbf{x}^\top\mathbf{y}\) is a scalar and \(\mathbf{x}\mathbf{y}^\top\) is a matrix.
Indices start at 1. The first element of \(\mathbf{x}\) is \(x_1\). This matches R and most mathematical writing; it does not match Python, C, or most other programming languages (Section 2.5).
Greek letters are not decoration — each carries a strong conventional meaning, and using the wrong one reads like a spelling mistake.
| Letter | Name | Usually means |
|---|---|---|
| \(\alpha\) | alpha | significance level; learning rate; a mixing weight |
| \(\beta\) | beta | regression coefficients |
| \(\gamma\) | gamma | a discount factor; a kernel width |
| \(\delta\), \(\Delta\) | delta | a small change; \(\Delta\) for a finite difference |
| \(\epsilon\), \(\varepsilon\) | epsilon | an error term; a vanishingly small quantity |
| \(\eta\) | eta | learning rate |
| \(\theta\), \(\Theta\) | theta | parameters generally; \(\Theta\) the parameter space |
| \(\lambda\), \(\Lambda\) | lambda | eigenvalue; regularization strength |
| \(\mu\) | mu | a mean |
| \(\pi\), \(\Pi\) | pi | a probability or mixing proportion; \(\Pi\) for a product |
| \(\rho\) | rho | a correlation |
| \(\sigma\), \(\Sigma\) | sigma | standard deviation; \(\Sigma\) for a sum or a covariance matrix |
| \(\phi\), \(\Phi\) | phi | normal density; \(\Phi\) its CDF |
| \(\chi\) | chi | as in \(\chi^2\) |
| \(\omega\), \(\Omega\) | omega | an outcome; \(\Omega\) the sample space |
\(\Sigma\) does double duty and the two uses look identical. \(\sum_{i=1}^n x_i\) is a sum — you can tell by the index underneath. \(\boldsymbol{\Sigma}\) is a covariance matrix — bold, no index. Likewise \(\pi \approx 3.14159\) versus \(\pi_k\) as a mixing proportion.
\[ \sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n \]
Read: “the sum, from \(i\) equals 1 to \(n\), of \(x\) sub \(i\).” The \(i\) is a dummy variable — it exists only inside the sum, and renaming it changes nothing.
The product version replaces \(\sum\) with \(\prod\):
\[ \prod_{i=1}^{n} x_i = x_1 \times x_2 \times \cdots \times x_n \]
Three identities used constantly:
\[ \begin{aligned} \sum_i (x_i + y_i) &= \sum_i x_i + \sum_i y_i &&\text{sums split} \\ \sum_i c\,x_i &= c\sum_i x_i &&\text{constants factor out} \\ \sum_{i=1}^{n} c &= nc &&\text{summing a constant} \end{aligned} \]
Sums nest, and the order can be swapped freely when the limits do not depend on each other:
\[ \sum_{i=1}^{m}\sum_{j=1}^{n} a_{ij} = \sum_{j=1}^{n}\sum_{i=1}^{m} a_{ij} \]
by_row by_col all
21 21 21
Other index sets appear under the \(\sum\). \(\sum_{i \neq j}\) skips the diagonal; \(\sum_{i \in S}\) runs over a set; a bare \(\sum_i\) means “over all valid \(i\)”, left to context.
Almost every loss function is a sum over observations: \(\frac{1}{n}\sum_{i=1}^{n} \ell(y_i, \hat{y}_i)\). Almost every likelihood is a product over observations, which is exactly why we take logarithms — \(\log\) turns \(\prod\) into \(\sum\) (Section 21.5), and sums are both easier to differentiate and far better behaved numerically.
Subscripts pick out parts:
| Notation | Meaning |
|---|---|
| \(x_i\) | the \(i\)-th element of vector \(\mathbf{x}\) |
| \(a_{ij}\) | row \(i\), column \(j\) of matrix \(\mathbf{A}\) |
| \(\mathbf{a}_j\) | the \(j\)-th column of \(\mathbf{A}\) (bold) |
| \(\mathbf{x}^{(i)}\) | the \(i\)-th observation in a dataset |
| \(x_j^{(i)}\) | feature \(j\) of observation \(i\) |
A[2, 3] # row 2, column 3[1] 6
A[, 2] # column 2[1] 3 4
Row-versus-column order is fixed: rows first, always. \(a_{23}\) is row 2, column 3. Both math and R follow this; NumPy’s A[2, 3] does too, but its zero-based indexing means it refers to a different entry.
The two kinds of index are easy to confuse. In machine learning writing, \(\mathbf{x}^{(i)}\) with a parenthesized superscript is the \(i\)-th observation, while \(x_j\) with a subscript is the \(j\)-th feature. The parentheses matter: \(x^2\) is a square, \(x^{(2)}\) is the second observation.
Counting starts at 1 here and in R. Python, C, Java and most other languages start at 0, so a formula that reads \(\sum_{i=1}^{n}\) becomes for i in range(n) — same \(n\) terms, shifted labels. This is a standing source of off-by-one bugs when translating formulas into code.
Being able to say an expression is most of understanding it. If you cannot pronounce a formula, you cannot hold it in your head.
| Symbol | Read as |
|---|---|
| \(\in\) | “in”, “is an element of” |
| \(\notin\) | “is not in” |
| \(\subset\), \(\subseteq\) | “is a subset of” |
| \(\forall\) | “for all”, “for every” |
| \(\exists\) | “there exists” |
| \(:\) or \(\mid\) | “such that” |
| \(\Rightarrow\) | “implies” |
| \(\iff\) | “if and only if” |
| \(:=\) or \(\triangleq\) | “is defined as” |
| \(\approx\) | “is approximately” |
| \(\propto\) | “is proportional to” |
| \(\gg\) | “is much greater than” |
| \(f: A \to B\) | “\(f\) maps \(A\) to \(B\)” |
| \(\mathbf{x} \mapsto \mathbf{A}\mathbf{x}\) | “\(\mathbf{x}\) maps to \(\mathbf{A}\mathbf{x}\)” |
| \(X \sim \mathcal{N}(\mu, \sigma^2)\) | “\(X\) is distributed as normal, mean mu, variance sigma squared” |
| \(\arg\min_x f(x)\) | “the \(x\) that minimizes \(f\)” |
| \(O(n^2)\) | “big oh of \(n\) squared” |
| \(\|\mathbf{x}\|\) | “the norm of \(\mathbf{x}\)” |
Worked out in full:
\[ \hat{\boldsymbol{\beta}} = \arg\min_{\boldsymbol{\beta} \in \mathbb{R}^p} \sum_{i=1}^{n}\left(y_i - \mathbf{x}_i^\top\boldsymbol{\beta}\right)^2 \]
“Beta-hat is the beta in R-p that minimizes the sum, from \(i\) equals 1 to \(n\), of \(y\)-sub-\(i\) minus \(\mathbf{x}\)-sub-\(i\) transpose beta, squared.”
And in English: choose the coefficients making the total squared error smallest. Being able to move between all three registers — symbols, spoken form, plain meaning — is the actual skill.
\(\arg\min\) and \(\min\) are different. \(\min_x f(x)\) is the smallest value \(f\) takes; \(\arg\min_x f(x)\) is the input achieving it. For \(f(x) = (x-3)^2\), the min is 0 and the argmin is 3.
Mathematical writing is full of shortcuts that are technically wrong and universally used. Knowing them is the difference between reading fluently and getting stuck.
Vertical bars mean four different things.
| Written | Means | Applied to |
|---|---|---|
| \(\lvert x \rvert\) | absolute value | a scalar |
| \(\lVert \mathbf{x} \rVert\) | norm (length) | a vector |
| \(\lvert \mathbf{A} \rvert\) | determinant | a matrix |
| \(\lvert S \rvert\) | cardinality (size) | a set |
| \(p(x \mid y)\) | “given” | a conditional probability |
Only the type of the thing inside tells you which. This is why keeping track of whether a symbol is a scalar, vector, matrix, or set is not pedantry.
\(f\) and \(f(x)\) get conflated. Strictly, \(f\) is the function and \(f(x)\) is its value at \(x\). Everyone writes “the function \(f(x)\)” anyway.
The same letter is reused with different meanings. \(p\) might be a probability, a number of features, or a \(p\)-value — sometimes in one paragraph. \(n\) is almost always a sample size, but not always.
\(p(\cdot)\) names a different function depending on its argument. In \(p(x)\) and \(p(y)\), these are two different densities distinguished only by what is inside. Statisticians do this constantly.
Equality is sometimes definition. \(y = mx + b\) might assert a fact or introduce a definition. Careful writers use \(:=\) for the second; most do not.
Shapes get coerced silently. A formula may treat \(\mathbf{x}\) as a row when the convention says column, because the alternative is transposes everywhere. Check dimensions when a product looks wrong.
One abuse is worth singling out because it causes real bugs: broadcasting. Writing \(\mathbf{X} - \boldsymbol{\mu}\) where \(\mathbf{X}\) is \(n \times p\) and \(\boldsymbol{\mu}\) is \(p \times 1\) is not a valid matrix subtraction — it means “subtract \(\boldsymbol{\mu}\) from every row”. Every array library implements this, each with slightly different rules, and R’s recycling (Section 4.4) is its own version. When arithmetic between different shapes succeeds, make sure it did what you meant.
| If you see | It is |
|---|---|
| \(a\) | a scalar |
| \(\mathbf{a}\) | a vector (column) |
| \(\mathbf{A}\) | a matrix |
| \(\mathbb{R}^n\) | the space of \(n\)-vectors |
| \(\hat{\theta}\) | an estimate |
| \(\bar{x}\) | a mean |
| \(\sum\), \(\prod\) | sum, product |
| \(\|\cdot\|\) | a norm |
| \(\arg\min\) | the minimizing input |