Write subscripts, fractions, and roots
Build common mathematical expressions with grouping, scripts, fractions, and radicals.
On this page
Subscripts use _, superscripts use ^, and braces group every multi-token script or command argument. Most surprising results on this page come from omitting a pair of braces.
Group the whole mathematical unit#
In the square-root example below, assume a > 0 when calling √a the
positive solution. For a = 0, that solution is zero; for negative real a,
there is no real square root.
Compare x_n+1, which means “x with subscript n, then plus one,” with x_{n+1}, whose entire subscript is (n+1). Write both a subscript and superscript as a_i^2 or a^2_i; the first order is often easier to read in source.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
For iteration \(n+1\), the normalized update is
\[
x_{n+1}^{(j)} =
\frac{x_n^{(j)}-\mu_j}{\sqrt{\sigma_j^2+\varepsilon}}.
\]
For \(a>0\), the positive solution of \(z^2=a\) is \(z=\sqrt{a}\), while
\(z=\sqrt[3]{a}\) denotes the real cube root. A nested ratio may be written
\[
r = \frac{1}{1+\frac{k}{n}}.
\]
\end{document}The first display combines a grouped subscript, a parenthesized superscript, a fraction, and a square root. The second shows a nested fraction. Compile after deleting the braces around n+1; the output changes without necessarily producing an error, which is why visual inspection matters.
Balance source clarity and printed size#
\frac{numerator}{denominator} takes two required arguments. \sqrt{expression} makes a square root, while \sqrt[index]{expression} supplies an optional root index. Braces around a single token are optional for _ and ^, but consistently writing x_{i} can make later edits safer.
Fractions shrink in inline math. A simple inline ratio such as a/b may read better than \frac{a}{b}; move a nested or tall fraction to display math. Do not replace \frac with a slash when the grouping would become ambiguous.
Check common brace failures#
x_ijprints onlyias the subscript; usex_{ij}.e^-ktdoes not group the exponent; usee^{-kt}.\frac12xworks but hides the argument boundaries; prefer\frac{1}{2}xin maintainable source.\sqrt x+1places onlyxunder the radical; use\sqrt{x+1}.
Practice by writing \(c_{i,t+1}=\sqrt[3]{a_i^2/b_t}\), then replace the
radicand with a fraction using \frac. You are done when every intended
multi-character script stays grouped after you change an index. Next, size
brackets and choose symbols.
