Writing equations on moodle

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 equation mode.

At the top of the moodle editor window, there are three rows of icons. (If you only see one, click the down arrow on the left of the icon row.) You may have experimented with some useful features on the middle row, e.g. subscript and superscript (middle left), funny symbols (paper/pen icon, third from right). And perhaps the latex equation editor (calculator icon, fourth from right).

The equation editor makes it easy to write latex equations, but you can also type the latex directly into the moodle editing window. If you understand some latex, you can also edit equations produced by the equation editor.

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

Using latex equation mode

Equation mode has a lot of features but, also, poor error messages. It is best to format only small sections of equation. To typeset a longer equation, put the main pieces individually into equation mode 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.

On the bottom row of moodle icons, notice the icon at the far right, which looks like a little magnifying glass. Clicking it will display how your answer will look to us, i.e. after moodle has formatted your latex equations. Clicking it again will put you back in editing mode.

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.

Gotchas

Here's a couple suggestions if simple equations refuse to format.

Basics

Each math-mode expression should be enclosed in double dollar signs. When you click the preview icon, your answer will display with the math mode properly typeset. For example, if you write this in your proof

 $$x^{10}$$ 
it will appear as \(x^{10} \) when you click the preview icon.

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 equation mode. 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
\alpha \(\alpha\)
\beta \(\beta\)
\gamma \(\gamma\)
\pi \(\pi\)
\infty \(\infty\)
\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\)