Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

Advanced mathematics

Beyond simple formulas, LaTeX excels at aligned systems of equations, matrices and piecewise functions. The amsmath package provides all of this.

Aligning several equations

The align environment lines equations up on a marker (the &, often placed before the =). Each line ends with \\.

Compile Compile this system: the two lines align on the = sign.

Matrices

Between \[ … \], the pmatrix environment gives a matrix in parentheses (bmatrix for square brackets). & separates the columns, \\ the rows.

Modify Your turn: turn this 2×2 matrix into a 3×3 matrix (add a column and a row), then compile.
Show the solution
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \]
\end{document}

Piecewise functions

The cases environment handles piecewise definitions (with a brace).

Complete Complete the second line of the definition: -x for x < 0. Compile.
Show the solution
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ f(x) = \begin{cases} x^2 & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases} \]
\end{document}
Key point: with amsmath, align aligns equations, pmatrix/bmatrix make matrices, cases handles piecewise functions. Everywhere, & marks the columns and \\ ends a line.