# LaTeX Math Formulas

There are three environments that put LaTeX in math mode: math, displaymath, and equation. The math environment is for formulas that appear right in the text. The displaymath environment is for formulas that appear on their own line. The equation environment is the same as the displaymath environment except that it adds an equation number in the right margin.

The math environment can be used in both paragraph and LR mode, but the displaymath and equation environments can be used only in paragraph mode. The math and displaymath environments are used so often that they have the following short forms:

$$...$$
\begin{math}...\end{math}

$...$
\begin{displaymath}...\end{displaymath}

In fact, the math environment is so common that it has an even shorter form:

$...$
$$...$$

$$...$$
$...$

Some building blocks for mathematical typesetting:

### Subscripts and superscripts

To get an expression exp to appear as a subscript, you just type
_{exp}
in some of the math modes. To get exp to appear as a superscript, you type
^{exp}
. LaTeX handles superscripted superscripts and all of that stuff in the natural way. It even does the right thing when something has both a subscript and a superscript.

### Spacing in math mode

In a math environment, LaTeX ignores the spaces you type and puts in the spacing that it thinks is best. LaTeX formats mathematics the way it's done in mathematics texts. If you want different spacing, LaTeX provides the following four commands for use in math mode:
• \; a thick space
• \: a medium space
• \, a thin space
• \! a negative thin space

### Fractions

 \frac{num}{den}

Produces the fraction num divided by den.

### Square root

 \sqrt[root]{arg}

The \sqrt command produces the square root of its argument. The optional argument, root, determines what root to produce, i.e., the cube root of
x+y
would be typed as
$\sqrt[3]{x+y}$
.

### Undeline and overline

 \overline{text}

causes the argument text to be overlined.
 \underline{text}

causes the argument text to be underlined. These commands can also be used in paragraph and LR modes.

### Put brace over or under a text

 \overbrace{text}

generates a brace over text.
 \underbrace{text}

generates text with a brace underneath.

### Various math symbols

TeX provides almost any mathematical symbol you're likely to need. The commands for generating them can be used only in math mode. For example, if you include $\pi$ in your source, you will get the symbol "pi" in your output. Here is a partial list of what is available.
• \cdots produces a horizontal ellipsis where the dots are raised to the center of the line.
• \ddots a diagonal ellipsis.
• \ldots ellipsis notation. This command works in any mode, not just math mode.
• \vdots vertical ellipsis.
• Greek letters from \alpha to \omega
• Different arrows such as \leftarrow (single), \Leftarrow (double), \longleftarrow (longer), \uparrow, \Longleftrightarrow and the other combinations.
• Set theoretical operators: \cap, \cup
• Mathematical functions: \sin, \cos, \ln, \log, tan, etc.