# How can I format mathematical expressions here, using MathJax?

Blatantly ripped off from chem.SE, this post is meant to help people understand how to use MathJax formatting of mathematical expressions here on Robotics.

## Getting started with MathJax

On Robotics Stack Exchange, we use MathJax to format mathematical expressions. MathJax is a tool that lets us display LaTeX expressions on a browser.

To use MathJax, enclose your mathematical expressions within single($...$) or double($$...$$) dollar signs. Single dollar signs make the expression inline, for example, Let $x$ be a variable gives:

Let $x$ be a variable.

On the other hand, double dollar signs make the expression a block element. It gets its own line, and is slightly larger. For example, The equation of motion is as follows: $$v=u+at$$ It is a SUVAT equation gives:

The equation of motion is as follows: $$v=u+at$$ It is a SUVAT equation

Note that the extra spaces in LaTeX do not render, use \: or ~ for a space.

## Basic MathJax

### Superscripts and subscripts

You can denote superscripts via the ^ character, and subscripts via _. For example, x^2 renders as $x^2$, x_1 renders as $x_1$, and x_1^3 renders as $x_1^3$.

If you want to include more than one character in the super/sub script, enclose it in curly braces ({...}).

For example, x^10 renders as $x^10$, but x^{10} renders as $x^{10}$

### Fractions and square roots

Fractions can be easily displayed using \frac{..}{..}. For example, \frac{a+b^c}{de+f} renders as $\frac{a+b^c}{de+f}$

Protip: You can exclude the braces for single-character numerators/denominators (if the first character is a letter, you need to use a space after \frac, though). For example \frac12 renders as $\frac12$, and \frac ab renders as $\frac ab$

Square roots can be added in a similar manner, via \sqrt{....}. For example, \sqrt{x+y} renders as $\sqrt{x+y}$.

### Greek letters

Greek letters can be added usung a backslash ('\'), followed by the name of the letter. Captialise the first letter of the name for greek capital letters.

Eg \alpha \beta \gamma \Omega renders as $\alpha \beta \gamma \Omega$.

Make sure that you put spaces after these if you are typing normal alphabet characters. Eg e^{\pii} gives an error, you need to use e^{\pi i} for $e^{\pi i}$.

Note that there are special commands \varepsilon , \varsigma , \varrho , and \varpi to distinguish between the lunate Greek letters ($\varepsilon \varsigma \varrho \varpi$ rather than $\epsilon \sigma \rho \pi$).