BrainBoner.me

Mathematical Formulas — LaTeX Rendering Test

    A reference post testing every type of mathematical notation used in computer science and machine learning research.


    Basic Arithmetic & Algebra

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

    Block equations get their own space:

    $$(a + b)^2 = a^2 + 2ab + b^2$$
    $$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$$
    $$\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}$$

    Calculus

    The definition of a derivative:

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

    The chain rule:

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

    Definite integral:

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

    Integration by parts:

    $$\int u\, dv = uv - \int v\, du$$

    Taylor series expansion:

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

    Linear Algebra

    Matrix multiplication — for $A \in \mathbb{R}^{m \times k}$ and $B \in \mathbb{R}^{k \times n}$:

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

    Determinant of a 2×2 matrix:

    $$\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc$$

    Eigenvalue equation:

    $$A\mathbf{v} = \lambda \mathbf{v}$$

    The dot product and cosine similarity:

    $$\mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\| \|\mathbf{b}\| \cos\theta$$

    L2 norm:

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

    Singular Value Decomposition:

    $$A = U \Sigma V^T$$

    Probability & Statistics

    Bayes’ theorem:

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

    Normal distribution (Gaussian):

    $$f(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)$$

    Expected value and variance:

    $$\mathbb{E}[X] = \sum_{x} x \cdot P(X = x)$$
    $$\text{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2$$

    KL Divergence:

    $$D_{KL}(P \| Q) = \sum_{x} P(x) \log \frac{P(x)}{Q(x)}$$

    Machine Learning

    Loss Functions

    Mean Squared Error:

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

    Binary Cross-Entropy:

    $$\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:

    $$\sigma(x) = \frac{1}{1 + e^{-x}}$$

    Softmax:

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

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

    Gradient Descent

    Weight update rule:

    $$\theta \leftarrow \theta - \alpha \nabla_\theta \mathcal{L}(\theta)$$

    Backpropagation — gradient of loss w.r.t. weights:

    $$\frac{\partial \mathcal{L}}{\partial W^{(l)}} = \delta^{(l)} \cdot (a^{(l-1)})^T$$

    Attention Mechanism (Transformers)

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

    Information Theory

    Entropy:

    $$H(X) = -\sum_{x} P(x) \log_2 P(x)$$

    Mutual Information:

    $$I(X; Y) = \sum_{x,y} P(x,y) \log \frac{P(x,y)}{P(x)P(y)}$$

    Big-O Complexity (Inline)

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

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

    $$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}$$

    Greek Letters Reference

    Commonly used in ML and math: $\alpha$ (alpha), $\beta$ (beta), $\gamma$ (gamma), $\delta$ (delta), $\epsilon$ (epsilon), $\theta$ (theta), $\lambda$ (lambda), $\mu$ (mu), $\sigma$ (sigma), $\tau$ (tau), $\phi$ (phi), $\psi$ (psi), $\omega$ (omega), $\Sigma$ (Sigma), $\Pi$ (Pi), $\Delta$ (Delta), $\nabla$ (nabla).


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


    Chemistry (mhchem)

    Water and carbon dioxide: $\ce{H2O}$ and $\ce{CO2}$

    Reaction:

    $$\ce{H2SO4 -> 2H+ + SO4^2-}$$

    Equilibrium:

    $$\ce{N2 + 3H2 <=> 2NH3}$$

    Isotope notation: $\ce{^{14}_{6}C}$


    Chart.js — Algorithm Complexity


    Image with Caption

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

    Collapsible Section (inline HTML)

    Click to see the full Master Theorem

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

    $$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}$$

    ASCII Art

    Binary Search — step-by-step on [1,3,5,7,9,11,13,15], target=7
    
    Index:  0   1   2   3   4   5   6   7
    Value: [1] [3] [5] [7] [9][11][13][15]
                        ^
                  mid=3, found!
    

    Keyboard Shortcuts

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


    Highlighted Text

    Use <mark> for important highlighted terms inline.