Typesetting mathematics
Load amsmath and amssymb in the preamble for common mathematical environments and symbols. Math mode changes how characters behave: spaces are ignored, and operators and symbols use dedicated commands.
\usepackage{amsmath,amssymb}
Inline and display equations
Inline math: $E = mc^2$.
\[ E = mc^2 \] % display, not numbered
\begin{equation}\label{eq:energy}
E = mc^2
\end{equation} % numbered and referenceable
Use \( ... \) and \[ ... \] as alternatives to dollar delimiters in longer documents.
Fractions, roots, subscripts, and sums
\frac{a+b}{c} % fraction
\sqrt{x} % square root
\sqrt[n]{x} % nth root
x_i, x_{i+1} % subscript
x^2, x^{n+1} % superscript
\sum_{i=1}^{n} x_i
\prod_{i=1}^{n} x_i
\int_a^b f(x)\,dxAligned equations
In align, align equations at each &. Each row ends with \\; use \nonumber to suppress a row number.
\begin{align}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + 2ab + b^2
\end{align}
\begin{align*} % unnumbered
f(x) &= x^2 + 1 \\
&= (x- i)(x+i) + 1
\end{align*}Matrices and piecewise definitions
\begin{equation}
A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
\end{equation}
\[
f(x) = \begin{cases}
x^2, & x \geq 0, \\
-x, & x < 0.
\end{cases}
\]Common symbols and notation
\alpha, \beta, \theta % Greek letters
\leq, \geq, \neq % relations
\in, \subseteq, \forall % set and logic symbols
\mathbf{x}, \mathbb{R} % bold vector, real numbers (amssymb)
\hat{y}, \bar{x}, \lambda % accents
\log(x), \sin(x), \max_i % upright named operators
Prefer semantic commands such as \sin to typing function names as ordinary letters; spacing and font will be correct.