Advanced mathematics

Aligned equations, matrices, piecewise functions, theorems and proofs.

Load amsmath in the preamble for everything on this page. Theorems also need amsthm.

\usepackage{amsmath}
\usepackage{amsthm}

Aligned and multi-line equations

The align environment lines equations up at the &, usually placed before the equals sign. \\ starts a new line, and each line gets its own number.

\begin{align}
  (a+b)^2 &= a^2 + 2ab + b^2 \\
  (a-b)^2 &= a^2 - 2ab + b^2
\end{align}

Use align* to leave the lines unnumbered.

Matrices and cases

pmatrix draws a matrix in parentheses. cases builds a piecewise definition. Use \text{...} for words inside math.

\[
  A = \begin{pmatrix}
    1 & 0 \\
    0 & 1
  \end{pmatrix}
\]

\[
  |x| = \begin{cases}
    x  & \text{if } x \ge 0 \\
    -x & \text{if } x < 0
  \end{cases}
\]

Other matrix environments are bmatrix (brackets), vmatrix (bars) and matrix (no delimiters).

Theorems and proofs

Declare each theorem type once in the preamble with \newtheorem, then use it as an environment. The optional argument in brackets is the theorem's name. The proof environment ends with a box automatically.

\newtheorem{theorem}{Theorem}

\begin{theorem}[Pythagoras]
The square of the hypotenuse is equal to the sum of the squares of the legs.
\end{theorem}

\begin{proof}
By construction...
\end{proof}