← blog

Mathematical Formulas — Rendering Test

A reference post testing every type of mathematical notation used in computer science and machine learning research, plus a couple of MDX components.


Basic Arithmetic & Algebra#

Inline math flows naturally in text. The quadratic formula is x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} and the Pythagorean theorem is a2+b2=c2a^2 + b^2 = c^2.

Block equations get their own space:

(a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2 i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}

Calculus#

The definition of a derivative:

f(x)=limh0f(x+h)f(x)hf'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}

The chain rule:

ddx[f(g(x))]=f(g(x))g(x)\frac{d}{dx}[f(g(x))] = f'(g(x)) \cdot g'(x)

Definite integral:

abf(x)dx=F(b)F(a)\int_a^b f(x)\, dx = F(b) - F(a)

Taylor series expansion:

f(x)=n=0f(n)(a)n!(xa)nf(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n

Linear Algebra#

Matrix multiplication — for ARm×kA \in \mathbb{R}^{m \times k} and BRk×nB \in \mathbb{R}^{k \times n}:

(AB)ij=l=1kAilBlj(AB)_{ij} = \sum_{l=1}^{k} A_{il} B_{lj}

Determinant of a 2×2 matrix:

det(abcd)=adbc\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc

Eigenvalue equation:

Av=λvA\mathbf{v} = \lambda \mathbf{v}

L2 norm:

x2=i=1nxi2\|\mathbf{x}\|_2 = \sqrt{\sum_{i=1}^{n} x_i^2}

Singular Value Decomposition:

A=UΣVTA = U \Sigma V^T

Probability & Statistics#

Bayes’ theorem:

P(AB)=P(BA)P(A)P(B)P(A \mid B) = \frac{P(B \mid A)\, P(A)}{P(B)}

Normal distribution (Gaussian):

f(x)=1σ2πexp ⁣((xμ)22σ2)f(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)

KL Divergence:

DKL(PQ)=xP(x)logP(x)Q(x)D_{KL}(P \| Q) = \sum_{x} P(x) \log \frac{P(x)}{Q(x)}

Machine Learning#

Loss Functions#

Mean Squared Error:

LMSE=1ni=1n(yiy^i)2\mathcal{L}_{\text{MSE}} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2

Binary Cross-Entropy:

LBCE=1ni=1n[yilog(y^i)+(1yi)log(1y^i)]\mathcal{L}_{\text{BCE}} = -\frac{1}{n}\sum_{i=1}^{n} \left[ y_i \log(\hat{y}_i) + (1 - y_i)\log(1 - \hat{y}_i) \right]

Activation Functions#

Sigmoid:

σ(x)=11+ex\sigma(x) = \frac{1}{1 + e^{-x}}

Softmax:

softmax(xi)=exij=1Kexj\text{softmax}(x_i) = \frac{e^{x_i}}{\sum_{j=1}^{K} e^{x_j}}

ReLU (inline): ReLU(x)=max(0,x)\text{ReLU}(x) = \max(0, x)

Attention Mechanism (Transformers)#

Attention(Q,K,V)=softmax ⁣(QKTdk)V\text{Attention}(Q, K, V) = \text{softmax}\!\left(\frac{QK^T}{\sqrt{d_k}}\right) V

Big-O Complexity#

Common complexities as inline math: O(1)O(1), O(logn)O(\log n), O(n)O(n), O(nlogn)O(n \log n), O(n2)O(n^2), O(2n)O(2^n), O(n!)O(n!)

Master theorem for divide and conquer — if T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n):

T(n)={O(nlogba)if f(n)=O(nlogbaε)O(nlogbalogn)if f(n)=O(nlogba)O(f(n))if f(n)=Ω(nlogba+ε)T(n) = \begin{cases} O(n^{\log_b a}) & \text{if } f(n) = O(n^{\log_b a - \varepsilon}) \\ O(n^{\log_b a} \log n) & \text{if } f(n) = O(n^{\log_b a}) \\ O(f(n)) & \text{if } f(n) = \Omega(n^{\log_b a + \varepsilon}) \end{cases}

Algorithm Complexity Visualized#


Image with Caption#

Binary search diagram
Binary search repeatedly halves the search space — O(log n) time complexity.

Callouts#


Collapsible Section#

Click to see the full Master Theorem

For T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) where a1a \geq 1, b>1b > 1:

T(n)={O(nlogba)if f(n)=O(nlogbaε)O(nlogbalogn)if f(n)=Θ(nlogba)O(f(n))if f(n)=Ω(nlogba+ε)T(n) = \begin{cases} O(n^{\log_b a}) & \text{if } f(n) = O(n^{\log_b a - \varepsilon}) \\ O(n^{\log_b a} \log n) & \text{if } f(n) = \Theta(n^{\log_b a}) \\ O(f(n)) & \text{if } f(n) = \Omega(n^{\log_b a + \varepsilon}) \end{cases}

Keyboard Shortcuts#

Press Ctrl + C to copy, Ctrl + F to search.


Highlighted Text#

Use <mark> for important highlighted terms inline.


If it renders correctly here — calculus, matrices, ML formulas, piecewise functions, charts, callouts — it will render correctly in any post you write.