Typesetting Math

The Markdown parser included in IPython is MathJax-aware. This means that you can freely mix in mathematical expressions using the MathJax subset of Tex and LaTeX. Some examples from the MathJax site are reproduced below, as well as the Markdown+TeX source.

Inline Typesetting (Mixing Markdown and TeX)

You can mix math and Markdown text in a paragraph:

Source

This expression $\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a **[Markdown-formatted](http://daringfireball.net/projects/markdown/)** sentence.

Display

This expression $\sqrt{3x-1}+(1+x)^2$ is an example of a TeX inline equation in a Markdown-formatted sentence.

Display mode equations

The Lorenz equations

In IPython 0.13.1 you have to use \\\ for LaTeX newlines rather than just \\. This is fixed in master.

Source

\begin{aligned}
\dot{x} & = \sigma(y-x) \\\
\dot{y} & = \rho x - y - xz \\\
\dot{z} & = -\beta z + xy
\end{aligned}

Display

\begin{aligned} \dot{x} & = \sigma(y-x) \\\ \dot{y} & = \rho x - y - xz \\\ \dot{z} & = -\beta z + xy \end{aligned}

The Cauchy-Schwarz inequality

You can also use $$ to indicate display mode equations:

Source

$$
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
$$

Display

$$ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) $$

The probability of getting (k) heads when flipping (n) coins

Source

\begin{equation*}
P(E)   = {n \choose k} p^k (1-p)^{ n-k} 
\end{equation*}

Display

\begin{equation*} P(E) = {n \choose k} p^k (1-p)^{ n-k} \end{equation*}

Exercise

Go to the MathJax website and copy an example equations. Paste it into a Markdown cell and verify it gets rendered correctly. Then try some LaTeX of your own.

In [ ]: