Arithmetic operations
7.4.1 Arithmetic operations
The arithmetic operations are typed pretty much as you would expect. To get a + b,
a − b, −a, a/b, and ab, type $a + b$, $a - b$, $-a$, $a / b$, $a b$
158 Chapter 7 Typing math
There are two other forms of multiplication and one of division: a · b, a × b, and
a ÷ b. They are typed as follows: $a \cdot b$, $a \times b$, $a \div b$ In displayed formulas, fractions are usually typed with the \frac command. To
\frac{1 + 2x}{x + y + xy} \]
You can use display-style fractions inline with \dfrac, and inline-style frac- 3+a 2
tions in displayed math environments with \tfrac; for example, is typed as 4+b $\dfrac{3 + a^{2}}{4 + b}$ and
3+a 2 4+b
is typed as \[
\tfrac{3 + a^{2}}{4 + b} \]
The \dfrac command is often used in matrices whose entries would look too small with the \frac command. See Formula 20 in the Formula Gallery (Section 7.9) for an example, and Section 8.6.1 for other fraction variants.
Subscripts and superscripts Subscripts are typed with _ and superscripts with ^. Remember to enclose the sub-
scripted or superscripted expression in braces: \[
a_{1},\ a_{i_{1}},\ a^{2},\ a^{b^{c}},\ a^{i_{1}},\ a_{i} + 1,\ a_{i + 1},\ a_{1}^{2},\ a^{2}_{1}
\] typesets as
1 ,a 2 1 For a b c , type $a^{b^{c}}$, not $a^{b}^{c}$. If you type the latter, you get the error message
2 b a c 1 ,a i 1 ,a ,a ,a i 1 ,a i + 1, a i+1 ,a 2
7.4 Basic constructs 159
! Double superscript.
Similarly, a b c is typed as $a_{b_{c}}$, not as $a_{b}_{c}$. In many instances, the braces for the subscripts and superscripts could be omitted, but you should type them anyway.
Tip You may safely omit the braces for a subscript or superscript that is a single digit or letter, as in $a_1$ and $(a + b)^x$, which are typeset as a 1 and (a + b) x . Be careful, however. If you have to edit $a_1$ to make it a 12 , then the braces can no longer be omitted, you must type $a_{12}$ to obtain a 12 because $a_12$ typesets as a 1 2.
There is one symbol that is automatically superscripted in math mode, the prime, that is, ’. To get f ′ (x), type $f’(x)$. However, to get f ′2 you must type
$f^{\prime 2}$ Typing ${f’}^{2}$ results in f ′2 , with the 2 too high; typing it as $f’^{2}$ causes
a double superscript error. Sometimes you may want a symbol to appear superscripted or subscripted by itself, as in the phrase
use the symbol † to indicate the dualspace typed as
use the symbol ${}^{\dagger}$ to indicate the dualspace where { } is the empty group. The empty group can be used to separate symbols, to
terminate commands, or as the base for subscripting and superscripting. The \sb and \sp commands also typeset subscripts and superscripts, respectively, as in
$a\sb{1} - a\sp{x + y}$ which produces a 1 −a x+y . These commands are seldom used, however, except in the
alltt environment (see Section 12.3) and in the Mathematical Reviews of the AMS. For multiline subscripts and superscripts, see Section 7.6.5.