Function composition in LaTeX is \circ, as in g \circ f, and the isomorphism symbol in LaTeX is \cong (≅), with \simeq for a weaker equivalence; all three are built in. A function is declared with f \colon A \to B, where \colon gets the spacing right, and its rule with \mapsto, as in x \mapsto x^2. The identity map is \operatorname{id} from amsmath. The table lists the function and mapping commands people use most, with the package each one needs; the full list of symbols follows below.
| Symbol | Command | Use | Package | Copy |
|---|---|---|---|---|
f \colon A \to B | Function from A to B | built in | ||
x \mapsto x^2 | Maps to (function rule) | built in | ||
g \circ f | Composition, g after f | built in | ||
f^{-1} | Inverse function | built in | ||
\cong | Isomorphic to | built in | ||
\simeq | Homotopy equivalent, weak isomorphism | built in | ||
\xrightarrow{\sim} | Isomorphism arrow | amsmath | ||
\operatorname{id}_A | Identity map | amsmath | ||
\hookrightarrow | Injection, inclusion | built in | ||
\twoheadrightarrow | Surjection | amssymb | ||
f|_A | Restriction to A | built in |
The inverse is f^{-1} and restriction to a subset is f|_A. Injections and surjections get their own arrows, \hookrightarrow and \twoheadrightarrow (the latter from amssymb), and an isomorphism arrow is \xrightarrow{\sim}. Standard functions such as \sin, \log, \exp, \lim and \ker are built in and typeset upright with correct spacing. Anything else (image, domain, support, sign) should be wrapped in amsmath’s \operatorname{Im} or declared once with \DeclareMathOperator{\dom}{dom}; plain Im(f) would be set as the product of two italic variables. Piecewise definitions use the amsmath cases environment.
Load \usepackage{amsmath, amssymb} for \operatorname, \xrightarrow, cases and \twoheadrightarrow. Our guide to math functions in LaTeX covers operators, limits and function spacing in more depth, and the arrow symbols page lists every mapping arrow.
f(x)f: A \to B\mapsto\to\longrightarrowf \circ gf^{-1}\text{Im}(f)\ker(f)\text{dom}(f)\text{cod}(f)\text{range}(f)\hookrightarrow\twoheadrightarrow\leftrightarrowf|_Af(x) = yf(x) = \begin{cases} a & x > 0 \\ b & x \leq 0 \end{cases}