Evolution is progress—
progress is creativity.

# Test Math Formula HTML

The first test were disappointing. It seems no mathematical formulas work with Creole.

Neither the mediawiki HTML format

```{{math|{{radical|1 &amp;minus; ''e''&amp;sup2;}}}}
```

Nor the TEX format

```[itex] f(x) = x^2\,\![/itex]
```

Nor MathML

``` <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msubsup>
<mo> &int; </mo>
<mn> 0 </mn>
<mn> 1 </mn>
</msubsup>
<mrow>
<msqrt><mi> x </mi></msqrt>
<mo> &InvisibleTimes; </mo>
<mrow>
<mo> &DifferentialD; </mo>
<mi> x </mi>
</mrow>
</mrow>
</mrow>
[/itex]
Überschrift mit einer in MathML gesetzten Formel
```

Although I created a macro that is capable to display this, but it is not convenient to read.

${\int }_{0}^{1}\sqrt{x}dx$

An other example.

```<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<mn>17</mn>
<mo>+</mo>
<mn>29</mn>
<mo/>
<mi>i</mi>
</mrow>
<mo></mo>
<mi mathvariant="double-struck">C</mi>
</mrow>
[/itex]
```

Is rendered as

$17+29i\mathbb{C}$

And finally

```<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo>(</mo><mtable>
<mtr><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd></mtr>
<mtr><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd></mtr>
<mtr><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd></mtr>

</mtable><mo>)</mo></mrow>
[/itex]
```

yields

$\left(\begin{array}{ccc}0& 1& 0\\ 0& 0& 1\\ 1& 0& 0\end{array}\right)$

Examples from http://www.w3.org/Math/XSL/csmall2.xml

These two entries offer some useful suggestions.

As I decided to implement matplotlib anyway, I opted for MathtextBackend. Unfortunately this is poorly documented. Although a tutorial and an extended example is available, no examples cover how it is used with web applications.

I learned from this webpage how to provide matplotlib graphics from a web server. An idea how to integrate matplotlib into django I found here.

This leaves us with two options how to implement matplotlib graphics

1. by calling a view with the urlencoded TEX formula.
2. by storing a temporary image that has to be destroyed after its use.

The implementation is explained here.

Tags: Software

(c) Mato Nagel, Weißwasser 2004-2013, Disclaimer