# Writing equations on PrairieLearn

Many equations can be written perfectly well using standard ASCII characters, and this is often the easiest way to write your proof. However, this doesn't work well in certain situations, e.g. summations, complex fractions, special characters. For these, you'll need to use LaTeX.

You can still use plaintext when that's easier. The fastest and easiest way to write a proof in a PL window is probably a combination of some plaintext and some LaTeX.

## Using LaTeX

LaTeX has a lot of features, but poor error messages. It is best to format only small sections of equation. To typeset a longer equation, put the main pieces individually into LaTeX and join them with ASCII characters (e.g. =). This warning applies even if you are familiar with LaTeX or other similar equation mode environments (e.g. piazza). There are small but annoying differences that you don't want to deal with during an exam. Keep it simple.

If you are curious about LaTeX, more details can be found in this quick summary of LaTeX. However, for this class, most of you will just want to use simple, basic bits of LaTeX.

If your LaTeX does not format properly and you can't quickly see why, remember that the graders can read LaTeX input. Don't waste a lot of time trying to find your small syntax error.

Do use plaintext when it seems easier. It's not quite as pretty but it will be perfectly fine.

## Basics

Each math-mode expression should be enclosed in dollar signs. For example, if you write this in your proof

 $x^{10}$
it will appear as $$x^{10}$$ in the preview below the editor box.

The above example shows you how to write an exponent (^). Also notice that curly brackets are used for grouping. Without them, only the 1 would appear in the exponent. So

 $x^10$
formats as $$x^10$$.

We can build a fraction using the frac command. So to write $$\frac{y+1}{3}$$ we type

 $\frac{y+1}{3}$

A simple example like this could also be written in ASCII, e.g. (y+1)/3. Choose the method that gets you a readable result with the least hassle.

The command \not puts a slash through the following symbol. So $$x \not= y$$ is entered as

$x \not= y$

Finally, if you write a command directly followed by a character (e.g. a variable name), you need to leave a space so that LaTeX will understand where the command ends. E.g. $$\frac y 3$$ should be typed as

 $\frac y 3$

You'll get an error if you omit the space,e.g.

 $\fracy3$

## Summations and friends

Summations are the main reason we're telling you about LaTeX. It's easiest to explain by example. To write $$\sum_{k=3}^{20} k^2$$ we would use the LaTeX expression

 $\sum_{k=3}^{20} k^2$

Notice the curly brackets used to make sure that multi-character expressions (e.g. "k=3") end up entirely in the subscript or superscript.

A product such as $$\prod_{k=3}^{20} \frac{k+3}{k+4}$$ is typeset in a similar way

 $\prod_{k=3}^{20} \frac{k+3}{k+4}$

The limit $$\lim_{x \to \infty}$$ is typeset as

$\lim_{x \to \infty}$

The binomial coefficient $$\binom{n+2}{k+1}$$ is typed as

$\binom{n+2}{k+1}$

The \sqrt command produces the square root symbol. The stuff inside the root is enclosed in curly brackets. E.g. to produce $$x + \sqrt{x+2}$$ you would type

$x + \sqrt{x+2}$

## Other stuff

Adding a prime to a function f' produces the same thing inside math mode: $$f'$$. The font is slightly different, but we'll pretend we didn't notice. The same applies to n!, which comes out as $$n!$$.

For set notation, the funny double-line versions of letters like R are made using the command mathbb, e.g. $$\mathbb{R}$$ is produced by

$\mathbb{R}$

These can be modified with subscripts and superscripts, e.g. to produce $$\mathbb{Z}^+$$ we would type

 $\mathbb{Z}^+$

Since curly brackets are grouping symbols in LaTeX, you can't use them directly to write set notation. One option is to enter math mode after you're inside the set brackets. For example

A = { $x^2$ | x is even }

appears as A = { $$x^2$$ | x is even }. That's not completely pretty because some of the fonts don't match etc. But it's a problem we can ignore for now.

Your other option is to "escape" the curly brackets using backslash. So

$A = \{ x^2 | x is even \}$

appears as $$A = \{ x^2 | x is even \}$$. Oops, bad stuff happened to the words inside math mode! We can fix that by putting the English phrase inside the \text command. So the input

$A = \{ x^2 | x \text{ is even} \}$

will produce $$A = \{ x^2 | x \text{ is even} \}$$

A prettier version would be $$A = \{ x^2 \ | \ x \text{ is even} \}$$. Here, we've added extra space using a command consisting of a backslash followed by a space:

 $A = \{ x^2 \ | \ x \text{ is even} \}$

Most function names in math are single characters. The exceptions look odd unless they are set in text mode. To simplify typing, many have special commands. So

$\sin(s), \cos(x)$

appears as $$\sin(s), \cos(x)$$

## Math symbols

LaTeX supports a very long list of special math symbols. In many cases, it will be faster for you to use words or standard ASCII symbols instead. It won't look quite as pretty, but that doesn't matter for these exams. Here are the commands that are most likely to be useful:

command output
\emptyset $$\emptyset$$
\cap $$\cap$$
\cup $$\cup$$
\in $$\in$$
\subseteq $$\subseteq$$
\rightarrow or \to $$\rightarrow$$
\times $$\times$$
\cdot $$\cdot$$
\ldots $$\ldots$$
\le $$\le$$
\ge $$\ge$$
\equiv $$\equiv$$
\alpha $$\alpha$$
\beta $$\beta$$
\gamma $$\gamma$$
\pi $$\pi$$
\infty $$\infty$$