Formula library

80 formulas · 8 domains · Free, like everything here

The maths the lessons lean on. Each entry is written out, glossed in plain English, has its symbols named, and links to the topics that use it.

NameExpressionDomainsLessons
Action-value functionQπ(s,a)=Eπ ⁣[Gt∣St=s,At=a]Q^{\pi}(s, a) = \mathbb{E}_{\pi}\!\left[G_t \mid S_t = s, A_t = a\right]Reinforcement learning1
Adamθt+1=θt−ηm^tv^t+ϵ\theta_{t+1} = \theta_t - \eta \frac{\hat{m}_t}{\sqrt{\hat{v}_t} + \epsilon}Optimization, Deep learning2
Advantage functionAπ(s,a)=Qπ(s,a)−Vπ(s)A^{\pi}(s, a) = Q^{\pi}(s, a) - V^{\pi}(s)Reinforcement learning—
Arithmetic intensityI=FLOPsbytes movedI = \frac{\text{FLOPs}}{\text{bytes moved}}Inference4
Batch normalizationBN(xi)=γxi−μBσB2+ϵ+β\mathrm{BN}(x_i) = \gamma \frac{x_i - \mu_{\mathcal{B}}}{\sqrt{\sigma_{\mathcal{B}}^2 + \epsilon}} + \betaDeep learning1
Bayes' theoremP(A∣B)=P(B∣A) P(A)P(B)P(A \mid B) = \frac{P(B \mid A)\, P(A)}{P(B)}Probability—
Bellman expectation equationVπ(s)=Eπ ⁣[r+γVπ(s′)∣s]V^{\pi}(s) = \mathbb{E}_{\pi}\!\left[r + \gamma V^{\pi}(s') \mid s\right]Reinforcement learning1
Bellman optimality equationV∗(s)=max⁡aE ⁣[r+γV∗(s′)∣s,a]V^{*}(s) = \max_{a} \mathbb{E}\!\left[r + \gamma V^{*}(s') \mid s, a\right]Reinforcement learning—
Bernoulli distributionp(x)=θx(1−θ)1−x,x∈{0,1}p(x) = \theta^{x} (1-\theta)^{1-x}, \quad x \in \{0, 1\}Probability—
Binomial distributionP(k)=(nk)θk(1−θ)n−kP(k) = \binom{n}{k} \theta^{k} (1-\theta)^{n-k}Probability—
Central limit theoremXˉn−μσ/n→dN(0,1)\frac{\bar{X}_n - \mu}{\sigma / \sqrt{n}} \xrightarrow{d} \mathcal{N}(0, 1)Probability—
Chain ruleddxf(g(x))=f′(g(x))⋅g′(x)\frac{d}{dx} f(g(x)) = f'(g(x)) \cdot g'(x)Calculus1
Channel capacityC=max⁡p(x)I(X;Y)C = \max_{p(x)} I(X; Y)Information theory—
Chinchilla scaling lawL(N,D)=E+ANα+BDβL(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}Inference1
Conditional entropyH(Y∣X)=H(X,Y)−H(X)H(Y \mid X) = H(X, Y) - H(X)Information theory—
Conditional probabilityP(A∣B)=P(A∩B)P(B)P(A \mid B) = \frac{P(A \cap B)}{P(B)}Probability—
Cosine learning-rate scheduleηt=ηmin⁡+12(ηmax⁡−ηmin⁡)(1+cos⁡tπT)\eta_t = \eta_{\min} + \tfrac{1}{2}(\eta_{\max} - \eta_{\min})\left(1 + \cos\frac{t\pi}{T}\right)Optimization—
Cosine similaritysim⁡(a,b)=a⋅b∥a∥ ∥b∥\operatorname{sim}(\mathbf{a}, \mathbf{b}) = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|\,\|\mathbf{b}\|}Linear algebra4
CovarianceCov⁡(X,Y)=E ⁣[(X−E[X])(Y−E[Y])]\operatorname{Cov}(X, Y) = \mathbb{E}\!\left[(X - \mathbb{E}[X])(Y - \mathbb{E}[Y])\right]Probability1
Cross-entropyH(P,Q)=−∑xP(x)log⁡Q(x)H(P, Q) = -\sum_{x} P(x) \log Q(x)Information theory, Deep learning3
Derivativef′(x)=lim⁡h→0f(x+h)−f(x)hf'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}Calculus—
Determinant (2 by 2)det⁡(abcd)=ad−bc\det\begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bcLinear algebra—
Directional derivativeDuf=∇f⋅uD_{\mathbf{u}} f = \nabla f \cdot \mathbf{u}Calculus—
Discounted returnGt=∑k=0∞γkrt+k+1G_t = \sum_{k=0}^{\infty} \gamma^{k} r_{t+k+1}Reinforcement learning1
Discrete convolution(f∗g)[n]=∑mf[m] g[n−m](f * g)[n] = \sum_{m} f[m]\, g[n-m]Deep learning1
Dot producta⋅b=∑i=1naibi=∥a∥ ∥b∥cos⁡θ\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = \|\mathbf{a}\|\,\|\mathbf{b}\|\cos\thetaLinear algebra3
Dropouth~=m⊙h1−p,mi∼Bernoulli(1−p)\tilde{h} = \frac{m \odot h}{1 - p}, \qquad m_i \sim \mathrm{Bernoulli}(1-p)Deep learning1
Eigenvalue equationAv=λv,v≠0A\mathbf{v} = \lambda \mathbf{v}, \quad \mathbf{v} \neq \mathbf{0}Linear algebra1
Euclidean norm∥x∥2=∑i=1nxi2\|\mathbf{x}\|_2 = \sqrt{\sum_{i=1}^{n} x_i^2}Linear algebra4
Expected valueE[X]=∑xx p(x)\mathbb{E}[X] = \sum_{x} x\, p(x)Probability1
Fundamental theorem of calculus∫abf′(x) dx=f(b)−f(a)\int_a^b f'(x)\, dx = f(b) - f(a)Calculus—
GELUGELU(x)=x⋅Φ(x)\mathrm{GELU}(x) = x \cdot \Phi(x)Deep learning1
Gradient∇f=(∂f∂x1,…,∂f∂xn)\nabla f = \left( \frac{\partial f}{\partial x_1}, \dots, \frac{\partial f}{\partial x_n} \right)Calculus1
Gradient descentθt+1=θt−η∇θL(θt)\theta_{t+1} = \theta_t - \eta \nabla_{\theta} L(\theta_t)Optimization2
HessianHij=∂2f∂xi ∂xjH_{ij} = \frac{\partial^2 f}{\partial x_i \, \partial x_j}Calculus—
Integration by parts∫u dv=uv−∫v du\int u \, dv = uv - \int v \, duCalculus—
JacobianJij=∂fi∂xjJ_{ij} = \frac{\partial f_i}{\partial x_j}Calculus—
Jensen–Shannon divergenceJSD(P∥Q)=12DKL(P∥M)+12DKL(Q∥M)\mathrm{JSD}(P \parallel Q) = \tfrac{1}{2} D_{\mathrm{KL}}(P \parallel M) + \tfrac{1}{2} D_{\mathrm{KL}}(Q \parallel M)Information theory—
Joint entropyH(X,Y)=−∑x,yp(x,y)log⁡p(x,y)H(X, Y) = -\sum_{x, y} p(x, y) \log p(x, y)Information theory—
Kullback–Leibler divergenceDKL(P∥Q)=∑xP(x)log⁡P(x)Q(x)D_{\mathrm{KL}}(P \parallel Q) = \sum_{x} P(x) \log \frac{P(x)}{Q(x)}Information theory, Probability—
KV-cache sizeMKV=2⋅L⋅H⋅dh⋅S⋅B⋅bM_{\text{KV}} = 2 \cdot L \cdot H \cdot d_h \cdot S \cdot B \cdot bInference8
L1 regularizationLtotal=L+λ∑i∣θi∣L_{\text{total}} = L + \lambda \sum_{i} |\theta_i|Optimization1
L2 regularizationLtotal=L+λ∥θ∥22L_{\text{total}} = L + \lambda \|\theta\|_2^2Optimization1
Lagrange multipliersL(x,λ)=f(x)−λ g(x)\mathcal{L}(x, \lambda) = f(x) - \lambda\, g(x)Optimization—
Law of total probabilityP(A)=∑iP(A∣Bi) P(Bi)P(A) = \sum_{i} P(A \mid B_i)\, P(B_i)Probability—
Layer normalizationLN(x)=γ⊙x−μσ2+ϵ+β\mathrm{LN}(\mathbf{x}) = \gamma \odot \frac{\mathbf{x} - \mu}{\sqrt{\sigma^2 + \epsilon}} + \betaDeep learning—
Little's lawL=λWL = \lambda WInference5
Matrix multiplication(AB)ij=∑k=1nAikBkj(AB)_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}Linear algebra—
Memory-bound token latencyttoken≈Mweights+MKVBWt_{\text{token}} \approx \frac{M_{\text{weights}} + M_{\text{KV}}}{\mathrm{BW}}Inference4
Model memory footprintMweights=N⋅bM_{\text{weights}} = N \cdot bInference7
Momentumvt+1=βvt+∇θL,θt+1=θt−ηvt+1v_{t+1} = \beta v_t + \nabla_{\theta} L, \qquad \theta_{t+1} = \theta_t - \eta v_{t+1}Optimization1
Mutual informationI(X;Y)=∑x,yp(x,y)log⁡p(x,y)p(x) p(y)I(X; Y) = \sum_{x, y} p(x, y) \log \frac{p(x, y)}{p(x)\, p(y)}Information theory—
Newton's methodθt+1=θt−H−1∇θL\theta_{t+1} = \theta_t - H^{-1} \nabla_{\theta} LOptimization—
Normal distributionp(x)=1σ2πexp⁡ ⁣(−(x−μ)22σ2)p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)Probability1
Outer product(uv⊤)ij=uivj(\mathbf{u} \mathbf{v}^{\top})_{ij} = u_i v_jLinear algebra—
PerplexityPPL=exp⁡ ⁣(−1N∑i=1Nlog⁡p(xi∣x<i))\mathrm{PPL} = \exp\!\left(-\frac{1}{N} \sum_{i=1}^{N} \log p(x_i \mid x_{<i})\right)Information theory, Inference2
PPO clipped objectiveL=E ⁣[min⁡ ⁣(ρtAt,  clip(ρt,1−ϵ,1+ϵ)At)]L = \mathbb{E}\!\left[\min\!\left(\rho_t A_t, \; \mathrm{clip}(\rho_t, 1-\epsilon, 1+\epsilon) A_t\right)\right]Reinforcement learning—
Product rule(fg)′=f′g+fg′(fg)' = f'g + fg'Calculus—
Q-learning updateQ(s,a)←Q(s,a)+α ⁣[r+γmax⁡a′Q(s′,a′)−Q(s,a)]Q(s, a) \leftarrow Q(s, a) + \alpha\!\left[r + \gamma \max_{a'} Q(s', a') - Q(s, a)\right]Reinforcement learning1
REINFORCE policy gradient∇θJ=Eπθ ⁣[∇θlog⁡πθ(a∣s) Gt]\nabla_{\theta} J = \mathbb{E}_{\pi_\theta}\!\left[\nabla_{\theta} \log \pi_{\theta}(a \mid s)\, G_t\right]Reinforcement learning—
ReLUReLU(x)=max⁡(0,x)\mathrm{ReLU}(x) = \max(0, x)Deep learning2
RMSPropst+1=ρst+(1−ρ)(∇θL)2,θt+1=θt−ηst+1+ϵ∇θLs_{t+1} = \rho s_t + (1-\rho)(\nabla_\theta L)^2, \qquad \theta_{t+1} = \theta_t - \frac{\eta}{\sqrt{s_{t+1}} + \epsilon} \nabla_\theta LOptimization1
Scaled dot-product attentionAttention(Q,K,V)=softmax ⁣(QK⊤dk)V\mathrm{Attention}(Q, K, V) = \mathrm{softmax}\!\left(\frac{QK^{\top}}{\sqrt{d_k}}\right) VDeep learning4
Self-informationI(x)=−log⁡p(x)I(x) = -\log p(x)Information theory—
Shannon entropyH(X)=−∑xp(x)log⁡p(x)H(X) = -\sum_{x} p(x) \log p(x)Information theory, Probability1
Sigmoidσ(x)=11+e−x\sigma(x) = \frac{1}{1 + e^{-x}}Deep learning3
Singular value decompositionA=UΣV⊤A = U \Sigma V^{\top}Linear algebra1
Sinusoidal positional encodingPE(pos,2i)=sin⁡ ⁣(pos100002i/d)PE_{(pos, 2i)} = \sin\!\left(\frac{pos}{10000^{2i/d}}\right)Deep learning1
Softmaxσ(z)i=ezi∑j=1Kezj\sigma(\mathbf{z})_i = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}Deep learning, Probability5
Speculative decoding speedupE[tokens per step]=1−αk+11−α\mathbb{E}[\text{tokens per step}] = \frac{1 - \alpha^{k+1}}{1 - \alpha}Inference—
State-value functionVπ(s)=Eπ ⁣[Gt∣St=s]V^{\pi}(s) = \mathbb{E}_{\pi}\!\left[G_t \mid S_t = s\right]Reinforcement learning1
Stochastic gradient descentθt+1=θt−η∇θLB(θt)\theta_{t+1} = \theta_t - \eta \nabla_{\theta} L_{\mathcal{B}}(\theta_t)Optimization2
Taylor seriesf(x)=∑n=0∞f(n)(a)n!(x−a)nf(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x-a)^nCalculus—
Temperature samplingpi=exp⁡(zi/T)∑jexp⁡(zj/T)p_i = \frac{\exp(z_i / T)}{\sum_{j} \exp(z_j / T)}Inference, Deep learning3
Temporal-difference errorδt=rt+1+γV(st+1)−V(st)\delta_t = r_{t+1} + \gamma V(s_{t+1}) - V(s_t)Reinforcement learning—
Top-p (nucleus) samplingVp=min⁡{V′⊆V:∑x∈V′p(x)≥p}\mathcal{V}_p = \min \left\{ \mathcal{V}' \subseteq \mathcal{V} : \sum_{x \in \mathcal{V}'} p(x) \geq p \right\}Inference3
Tracetr⁡(A)=∑i=1nAii\operatorname{tr}(A) = \sum_{i=1}^{n} A_{ii}Linear algebra—
Transformer forward FLOPsCfwd≈2NDC_{\text{fwd}} \approx 2NDInference2
VarianceVar⁡(X)=E ⁣[(X−E[X])2]\operatorname{Var}(X) = \mathbb{E}\!\left[(X - \mathbb{E}[X])^2\right]Probability2
Vector projectionproj⁡ba=a⋅bb⋅bb\operatorname{proj}_{\mathbf{b}}\mathbf{a} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{b} \cdot \mathbf{b}} \mathbf{b}Linear algebra—
Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark