Math

Contents

Every page loads MathJax, so notes can include LaTeX math – in markdown and org alike. This page doubles as a quick reference: each example shows the source next to what it renders as.

Delimiters

  • Inline math sits inside a sentence. Write $e^{i\pi} + 1 = 0$ or \(e^{i\pi} + 1 = 0\) to get $e^{i\pi} + 1 = 0$.
  • Display math gets its own line. Write $$...$$ or \[...\]:

$$\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}$$

  • A literal dollar sign needs a backslash: \$5 renders as \$5.
  • Math inside code blocks is left alone (MathJax skips pre and code tags), so you can safely show LaTeX source like this page does.

Common syntax

Write Get
x^{2} $x^{2}$
x_{n} $x_{n}$
\frac{a}{b} $\frac{a}{b}$
\sqrt{x} $\sqrt{x}$
\sqrt[3]{x} $\sqrt[3]{x}$
\alpha, \beta, \pi $\alpha, \beta, \pi$
\Delta, \Sigma, \Omega $\Delta, \Sigma, \Omega$
\sum_{i=1}^{n} i $\sum_{i=1}^{n} i$
\prod_{i=1}^{n} i $\prod_{i=1}^{n} i$
\int_a^b f(x)\,dx $\int_a^b f(x)\,dx$
\lim_{x \to \infty} f(x) $\lim_{x \to \infty} f(x)$
\infty $\infty$
\leq, \geq, \neq, \approx $\leq, \geq, \neq, \approx$
\times, \cdot, \pm $\times, \cdot, \pm$
\in, \subset, \cup, \cap $\in, \subset, \cup, \cap$
\to, \implies, \iff $\to, \implies, \iff$
\vec{v}, \hat{x} $\vec{v}, \hat{x}$
\binom{n}{k} $\binom{n}{k}$
\frac{\partial f}{\partial x} $\frac{\partial f}{\partial x}$
\text{plain text} $x = \text{plain text}$

Multi-line equations

Use aligned inside display math; & marks the alignment point and \\ ends a line:

$$\begin{aligned}
(a + b)^2 &= (a + b)(a + b) \\
          &= a^2 + 2ab + b^2
\end{aligned}$$

$$\begin{aligned} (a + b)^2 &= (a + b)(a + b) \\ &= a^2 + 2ab + b^2 \end{aligned}$$

cases handles piecewise definitions:

$$|x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}$$

$$|x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}$$

pmatrix (or bmatrix for square brackets) builds matrices:

$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$

$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$

Further reading