Building a formula step-by-step
7.4.7 Building a formula step-by-step
It is easy to build up complex formulas from the components described in this section. Try the formula
X 3 x i µ(i)
(i − 1)
i,i+1
3 ρ(i) −2+ ρ(i) −1 Build this formula in several steps. Create a new file in your work folder. Name
i+3
i=1
it formula.tex, type in the following lines, and save it: % File: formula.tex
\documentclass{amsart} \usepackage{amssymb,latexsym} \begin{document} \end{document}
At present, the file has an empty document environment. Type each part of the formula as an inline or displayed formula within this environment so that you can typeset the document and check for errors.
Step 1 We start with n 2 . Type the following line into formula.tex: $\left[ \frac{n}{2} \right]$ and test it by typesetting the document.
Step 2 Now you can do the sum
i=1
For the superscript, you can copy and paste the formula created in Step 1 (without the dollar signs), so that you have
\[ \sum_{i = 1}^{ \left[ \frac{n}{2} \right] } \]
Step 3 Next, do the two formulas in the binomial
x i 2 i,i+1 i+3
Type them as separate formulas in formula.tex: \[
x_{i, i + 1}^{i^{2}}\qquad\left[ \frac{i + 3}{3} \right] \]
7.4 Basic constructs 165
Step 4 Now it is easy to do the binomial. Piece together the following formula by copying and pasting the previous formulas and dropping the \qquad command:
\[ \binom{x_{i,i + 1}^{i^{2}}}{\left[\frac{i + 3}{3}\right]} \]
which typesets as
x i 2 i,i+1 i+3
Step 5 3 Next, type the formula under the square root, µ(i) 2 (i 2 − 1): $\mu(i)^{ \frac{3}{2} } (i^{2} - 1)$
and then the square root, 3 µ(i) 2 (i 2 − 1):
$\sqrt{ \mu(i)^{ \frac{3}{2} } (i^{2} - 1) }$
Step 6 3 The two cube roots, 3 p
ρ(i) − 2 and ρ(i) − 1, are easy to type: $\sqrt[3]{ \rho(i) - 2 }$ $\sqrt[3]{ \rho(i) - 1 }$
Step 7 Now the fraction
µ(i) 3 2 (i 2 − 1) p 3 p
ρ(i)
−2+ 3 ρ(i) −1
is typed, copied, and pasted together as \[
\frac{ \sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} -1) } } { \sqrt[3]{\rho(i) - 2} + \sqrt[3]{\rho(i) - 1} } \]
Step 8 Finally, the whole formula,
µ(i) 2 (i − 1)
i,i+1
3 ρ(i) −2+ ρ(i) −1 is formed by copying and pasting the pieces together, leaving only one pair of displayed
i+3
i=1
math delimiters:
166 Chapter 7 Typing math
\[ \sum_{i = 1}^{ \left[ \frac{n}{2} \right] } \binom{ x_{i, i + 1}^{i^{2}} }
{ \left[ \frac{i + 3}{3} \right] } \frac{ \sqrt{ \mu(i)^{ \frac{3}{2}} (i^{2} - 1) } } {\sqrt[3]{\rho(i)-2} + \sqrt[3]{\rho(i) - 1}} \]
Note the use of
Hierarchical indentation, to keep track of the structure of the formula Spacing to help highlight the braces—some text editors help you balance braces Separate lines for the various pieces of formulas that are more than a line long
It is to your advantage to keep your source file readable. L A TEX does not care how its input is formatted, and would happily accept the following:
\[\sum_{i=1}^{\left[\frac{n}{2}\right]}\binom{x_{i,i+1} ^{i^{2}}}{\left[\frac{i+3}{3}\right]}\frac{\sqrt{\mu(i) ^{\frac{3}{2}}(i^{2}-1)}}{\sqrt[3]{\rho(i)-2}+\sqrt[3] {\rho(i)-1}}\]
But this haphazard style not only makes it more difficult for your coauthors or editor to work with your source file, it also makes finding mistakes difficult. Try to find the error in the next version:
\[\sum_{i=1}^{\left[\frac{n}{2}\right]} \binom{x_{i,i+1}^{i^{2}}}{\left[\frac{i+3}{3}\right]} \frac{\sqrt{\mu(i)^{\frac{3}{2}}}(i^{2}-1)}}{\sqrt[3] {\rho(i)-2}+\sqrt[3]{\rho(i)-1}}\]
Answer: \frac{3}{2 should be followed by }} and not by }}}.