All posts

LaTex Cheatsheet

February 9, 2022
tutorialopen-source
LaTex Cheatsheet

This is a simple LaTex Cheatsheet for writing math symbols and formulas in Jupyter Notebook, which uses MathJax to render LaTex inside the Markdown cells.

  • For inline mode, enclose the formula in $...$
  • For display mode (formulas will be centered and displayed in a separate line), enclose the formula in $$...$$
SymbolCodeSymbolCode
yxy^{x}y^{x}yxy_{x}y_{x}
xy\frac{x}{y}\frac{x}{y}∑k=1n\sum_{k=1}^n\sum_{k=1}^n
xn\sqrt[n]{x}\sqrt[n]{x}∏k=1n\prod_{k=1}^n\prod_{k=1}^n
SymbolCodeSymbolCode
≤\leq\leq≥\geq\geq
≠\neq\neq≈\approx\approx
×\times\times÷\div\div
±\pm\pm⋅\cdot\cdot
x∘x^{\circ}x^{\circ}∘\circ\circ
x′x^\primex^\prime⋯\cdots\cdots
∞\infty\infty¬\neg\neg
∧\wedge\wedge∨\vee\vee
⊃\supset\supset∀\forall\forall
∈\in\in→\rightarrow\rightarrow
⊂\subset\subset∃\exists\exists
∉\notin\notin⇒\Rightarrow\Rightarrow
∪\cup\cup∩\cap\cap
∣\mid\mid⇔\Leftrightarrow\Leftrightarrow
a˙\dot a\dot aa^\hat a\hat a
aˉ\bar a\bar aa~\tilde a\tilde a
SymbolCodeSymbolCode
α\alpha\alphaβ\beta\beta
γ\gamma\gammaδ\delta\delta
ϵ\epsilon\epsilonζ\zeta\zeta
η\eta\etaε\varepsilon\varepsilon
θ\theta\thetaι\iota\iota
κ\kappa\kappaϑ\vartheta\vartheta
π\pi\piρ\rho\rho
σ\sigma\sigmaτ\tau\tau
υ\upsilon\upsilonϕ\phi\phi
χ\chi\chiψ\psi\psi
ω\omega\omegaΓ\Gamma\Gamma
Δ\Delta\DeltaΘ\Theta\Theta
Λ\Lambda\LambdaΞ\Xi\Xi
Π\Pi\PiΣ\Sigma\Sigma
Υ\Upsilon\UpsilonΦ\Phi\Phi
Ψ\Psi\PsiΩ\Omega\Omega

I also created the list of symbols table used in the Mathematics for Machine Learning book, which is a great LaTex reference and can be accessed at:

SymbolTypical Meaning
a,b,c,α,β,γa,b,c, \alpha,\beta,\gammaScalars are lowercase
x,y,z\mathbf{x},\mathbf{y},\mathbf{z}Vectors are bold lowercase
A,B,C\mathbf{A},\mathbf{B},\mathbf{C}Matrices are bold uppercase
x⊤,A⊤\mathbf{x}^\top, \mathbf{A}^\topTranspose of a vector or matrix
A−1\mathbf{A}^{-1}Inverse of a matrix
⟨x,y⟩\langle \mathbf{x}, \mathbf{y}\rangleInner product of x\mathbf{x} and y\mathbf{y}
x⊤y\mathbf{x}^\top \mathbf{y}Dot product of x\mathbf{x} and y\mathbf{y}
B=(b1,b2,b3)B = (\mathbf{b}_1, \mathbf{b}_2, \mathbf{b}_3)(Ordered) tuple
B=[b1,b2,b3]\mathbf{B} = [\mathbf{b}_1, \mathbf{b}_2, \mathbf{b}_3]Matrix of column vectors stacked horizontally
B={b1,b2,b3}\mathcal{B} = \{\mathbf{b}_1, \mathbf{b}_2, \mathbf{b}_3\}Set of vectors (unordered)
Z,N\mathbb{Z},\mathbb{N}Integers and natural numbers, respectively
R,C\mathbb{R},\mathbb{C}Real and complex numbers, respectively
Rn\mathbb{R}^nnn-dimensional vector space of real numbers
∀x\forall xUniversal quantifier: for all xx
∃x\exists xExistential quantifier: there exists xx
a:=ba := baa is defined as bb
a=:ba =: bbb is defined as aa
a∝ba\propto baa is proportional to bb, i.e., a=constant⋅ba = \text{constant} \cdot b
g∘fg\circ fFunction composition: gg after ff
  ⟺  \iffIf and only if
  ⟹  \impliesImplies
A,C\mathcal{A}, \mathcal{C}Sets
a∈Aa \in \mathcal{A}aa is an element of set A\mathcal{A}
∅\emptysetEmpty set
A∖B\mathcal{A}\setminus \mathcal{B}A\mathcal{A} without B\mathcal{B}: the set of elements in A\mathcal{A} but not in B\mathcal{B}
DDNumber of dimensions; indexed by d=1,…,Dd=1,\dots,D
NNNumber of data points; indexed by n=1,…,Nn=1,\dots,N
Im\mathbf{I}_mIdentity matrix of size m×mm\times m
0m,n\mathbf{0}_{m,n}Matrix of zeros of size m×nm\times n
1m,n\mathbf{1}_{m,n}Matrix of ones of size m×nm\times n
ei\mathbf{e}_iStandard canonical vector (where ii is the component that is 11)
dim⁡\dimDimensionality of vector space
rk(A)\mathrm{rk}(\mathbf{A})Rank of matrix A\mathbf{A}
Im(Φ)\mathrm{Im}(\Phi)Image of linear mapping Φ\Phi
ker(Φ)\mathrm{ker}(\Phi)Kernel (null space) of a linear mapping Φ\Phi
span[b1]\mathrm{span}[\mathbf{b}_1]Span (generating set) of b1\mathbf{b}_1
tr(A)\text{tr}(\mathbf{A})Trace of A\mathbf{A}
det⁡(A)\det(\mathbf{A})Determinant of A\mathbf{A}
∥⋅∥\| \cdot \|Absolute value or determinant (depending on context)
∥∥⋅∥∥\|\| \cdot \|\|Norm; Euclidean, unless specified
λ\lambdaEigenvalue or Lagrange multiplier
EλE_\lambdaEigenspace corresponding to eigenvalue λ\lambda
x⊥y\mathbf{x} \perp \mathbf{y}Vectors x\mathbf{x} and y\mathbf{y} are orthogonal
VVVector space
V⊥V^\perpOrthogonal complement of vector space VV
∑n=1Nxn\sum_{n=1}^N x_nSum of the xnx_n: x1+…+xNx_1 + \dotsc + x_N
∏n=1Nxn\prod_{n=1}^N x_nProduct of the xnx_n: x1⋅…⋅xNx_1 \cdot\dotsc \cdot x_N
θ\boldsymbol{\theta}Parameter vector
∂f∂x\frac{\partial f}{\partial x}Partial derivative of ff with respect to xx
dfdx\frac{\mathrm{d} f}{\mathrm{d} x}Total derivative of ff with respect to xx
∇\nablaGradient
f∗=min⁡xf(x)f_* = \min_x f(x)The smallest function value of ff
x∗∈arg⁡min⁡xf(x)x_* \in \arg\min_x f(x)The value x∗x_* that minimizes ff (note: arg⁡min⁡\arg\min returns a set of values)
L\mathfrak{L}Lagrangian
L\mathcal{L}Negative log-likelihood
(nk)\binom{n}{k}Binomial coefficient, nn choose kk
VX[x]\mathbb{V}_X[\mathbf{x}]Variance of x\mathbf{x} with respect to the random variable XX
EX[x]\mathbb{E}_X[\mathbf{x}]Expectation of x\mathbf{x} with respect to the random variable XX
Cov⁡X,Y[x,y]\operatorname{Cov}_{X,Y}[\mathbf{x}, \mathbf{y}]Covariance between x\mathbf{x} and y\mathbf{y}
X⊥⊥Y∣ZX \perp\kern-5pt\perp Y \vert ZXX is conditionally independent of YY given ZZ
X∼pX\sim pRandom variable XX is distributed according to pp
N(μ,Σ)\mathcal{N}\big(\boldsymbol{\mu},\boldsymbol{\Sigma}\big)Gaussian distribution with mean μ\boldsymbol{\mu} and covariance Σ\boldsymbol{\Sigma}
Ber(μ)\text{Ber}(\mu)Bernoulli distribution with parameter μ\mu
Bin(N,μ)\text{Bin}(N, \mu)Binomial distribution with parameters N,μN, \mu
Beta(α,β)\text{Beta}(\alpha, \beta)Beta distribution with parameters α,β\alpha, \beta

A more complete LaTex cheatsheet can be found here.

Back to Top