Creating equations with MathML

It is possible to add scientific equations to your drills using the πŸ”— MathML standard. MathML is an XML-based language for describing mathematical notation. This page is by no means a MathML manual, but simply a quick introduction to MathML and how it applies to Drillster.

Managing equations

Equations are added to a drill by simply typing in or copying and pasting the MathML XML code into the edit screen. If Drillster recognizes your code as valid MathML, the text is automatically converted into a graphical representation of the equation. If your code contains an error, or if Drillster is unable to parse your MathML code, the code is saved as literal text instead. No error messages are shown.

entering MathML

Since the equation is converted to an image, it is not possible to edit the equation contents once an equation has been created. Changing an equation is best done by adding an alternative to the incorrect equation with your corrections, and subsequently deleting the incorrect alternative. For this reason it is always advisable to keep a separate (text) file with your equation definitions.

An equation can be removed simply by clicking the small β€œΓ—β€ next to the equation image, just like you would remove a regular image.

Equations can also be inserted as incorrect alternatives. These equations are given a red border in the editor.

deleting a formula

It is possible to add a caption to an equation by clicking on the equation image.

setting a caption

Since equations are handled as images by Drillster, there is no way an equation can be entered as the answer to an open ended question.

Basic structure of an equation

In order for Drillster to recognize a piece of XML as MathML, all equations must have the following basic structure:

<math xmlns="http://www.w3.org/1998/Math/MathML">...</math>

The XML preamble and DOCTYPE should not be included. A valid equation will always start with the math tag.

MathML can be used to describe both the presentation and the meaning of an equation. Drillster uses the πŸ”— presentation variant of MathML. The mode="display" attribute is not required.

Examples

The obvious use for MathML is mathematics, but MathML has something to offer for chemistry and physics as well. Here are some examples of MathML code, with their graphical representation. In order to see the full MathML code, just hover over the code snippets with your mouse.

Mathematics

A very simple example:

simple

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>x</mi>
  <mo>+</mo>
  <mn>5</mn>
  <mo>=</mo>
  <mn>0</mn>
</math>

Something slightly more advanced:

polynomial

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mfenced>
    <mrow>
      <mi>x</mi>
      <mo>+</mo>
      <mn>2</mn>
    </mrow>
  </mfenced>
  <mfenced>
    <mrow>
      <mi>x</mi>
      <mo>-</mo>
      <mn>5</mn>
    </mrow>
  </mfenced>
  <mo>=</mo>
  <msup>
    <mi>x</mi>
    <mn>2</mn>
  </msup>
  <mo>-</mo>
  <mn>2</mn>
  <mi>x</mi>
  <mo>-</mo>
  <mn>15</mn>
</math>

This is the well known equation for solving quadratic polynomials:

Quadratic formula

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mi>x</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo form="prefix">−<!-- minus sign --></mo>
        <mi>b</mi>
        <mo>±<!-- ± --></mo>
        <msqrt>
          <msup>
            <mi>b</mi>
            <mn>2</mn>
          </msup>
          <mo>−<!-- minus sign --></mo>
          <mn>4</mn>
          <mo>⁢<!-- ⁢ --></mo>
          <mi>a</mi>
          <mo>⁢<!-- ⁢ --></mo>
          <mi>c</mi>
        </msqrt>
      </mrow>
      <mrow>
        <mn>2</mn>
        <mo>⁢<!-- ⁢ --></mo>
        <mi>a</mi>
      </mrow>
    </mfrac>
  </mrow>
</math>

Matrices are defined as follows:

matrix

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <matrix>
    <matrixrow>
      <cn> 0 </cn> <cn> 1 </cn> <cn> 0 </cn>
    </matrixrow>
    <matrixrow>
      <cn> 0 </cn> <cn> 0 </cn> <cn> 2 </cn>
    </matrixrow>
    <matrixrow>
      <cn> 3 </cn> <cn> 0 </cn> <cn> 0 </cn>
    </matrixrow>
  </matrix>
</math>

More advanced examples:

schroedinger equation

<math display="block" xmlns="http://www.w3.org/1998/Math/MathML" id="schrodinger">
    <mi title='Imaginary Unit'>i</mi>
    <mi title="Reduced Plank's Constant">ℏ</mi>
    <mfrac title="Partial Differential Operator">
        <mo>∂</mo>
        <mrow>
            <mo>∂</mo>
            <mi title="Time">t</mi>
        </mrow>
    </mfrac>
    <mn title="Wavefunction">Ψ</mn>
    <mo form="infix">=</mo>
    <mfrac>
        <mrow>
            <mo form="infix" lucida="true">-</mo>
            <msup>
                <mi title="Plank's constant">h</mi>
                <mn>2</mn>
            </msup>
        </mrow>
        <mrow>
            <mn>2</mn>
            <mi title="Mass of particle">m</mi>
        </mrow>
    </mfrac>
    <msup title="Laplacian">
        <mo>∇</mo>
        <mn>2</mn>
    </msup>
    <mn title="Wavefunction">Ψ</mn>
    <mo form="infix">+</mo>
    <mi title="Potential energy">V</mi>
    <mn title="Wavefunction">Ψ</mn>
</math>

Netwon biominal

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <msup>
    <mrow>
      <mfenced separators="|">
        <mrow>
          <mi>x</mi>
          <mo>+</mo>
          <mi>a</mi>
        </mrow>
      </mfenced>
    </mrow>
    <mrow>
      <mi>n</mi>
    </mrow>
  </msup>
  <mo>=</mo>
  <mrow>
    <msubsup>
      <mo stretchy="true">βˆ‘</mo>
      <mrow>
        <mi>k</mi>
        <mo>=</mo>
        <mn>0</mn>
      </mrow>
      <mrow>
        <mi>n</mi>
      </mrow>
    </msubsup>
    <mrow>
      <mfenced separators="|">
        <mrow>
          <mfrac linethickness="0pt">
            <mrow>
              <mi>n</mi>
            </mrow>
            <mrow>
              <mi>k</mi>
            </mrow>
          </mfrac>
        </mrow>
      </mfenced>
      <msup>
        <mrow>
          <mi>x</mi>
        </mrow>
        <mrow>
          <mi>k</mi>
        </mrow>
      </msup>
      <msup>
        <mrow>
          <mi>a</mi>
        </mrow>
        <mrow>
          <mi>n</mi>
          <mo>-</mo>
          <mi>k</mi>
        </mrow>
      </msup>
    </mrow>
  </mrow>
</math>

It is even possible to include colors in equations:

colors

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <msup>
    <mi>e</mi>
    <mrow mathcolor='#cc0000'>
      <mn>2</mn>
      <mi>x</mi>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </msup>
</math>

Reaction equations

MathML can also be used for reaction equations in chemistry and physics.

This equation describes the combustion of methane:

Combustion reaction

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <msub>
    <mi>CH</mi>
    <mn>4</mn>
  </msub>
  <mo>+</mo>
  <mn>2</mn>
  <msub>
    <mi>O</mi>
    <mn>2</mn>
  </msub>
  <mo>→</mo>
  <msub>
    <mi>CO</mi>
    <mn>2</mn>
  </msub>
  <mo>+</mo>
  <mn>2</mn>
  <msub>
    <mi>H</mi>
    <mn>2</mn>
  </msub>
  <mi>O</mi>
</math>

An ionic reaction:

Ionic

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <msup>
    <mi>Ca</mi>
    <mo>2+</mo>
  </msup>
  <mo>+</mo>
  <mn>2</mn>
  <msup>
    <mi>Cl</mi>
    <mo>-</mo>
  </msup>
  <mo>+</mo>
  <mn>2</mn>
  <msup>
    <mi>Ag</mi>
    <mo>+</mo>
  </msup>
  <mo>+</mo>
  <mn>2</mn>
  <msup>
    <msub>
      <mi>NO</mi>
      <mn>3</mn>
    </msub>
    <mi>-</mi>
  </msup>
  <mo>→</mo>
  <msup>
    <mi>Ca</mi>
    <mo>2+</mo>
  </msup>
  <mo>+</mo>
  <mn>2</mn>
  <msup>
    <msub>
      <mi>NO</mi>
      <mn>3</mn>
    </msub>
    <mi>-</mi>
  </msup>
  <mo>+</mo>
  <mn>2</mn>
  <mi>Ag</mi>
  <mi>Cl</mi>
  <mi>(s)</mi>
</math>

Fission of uranium:

fission

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mmultiscripts>
    <mi>n</mi>
    <mprescripts/> <mi>0</mi> <mi>1</mi>
  </mmultiscripts>
  <mo>+</mo>
  <mmultiscripts>
    <mi>U</mi>
    <mprescripts/> <mi>92</mi> <mi>235</mi>
  </mmultiscripts>
  <mo>→</mo>
  <mmultiscripts>
    <mi>Ba</mi>
    <mprescripts/> <mi>56</mi> <mi>141</mi>
  </mmultiscripts>
  <mo>+</mo>
  <mmultiscripts>
    <mi>Kr</mi>
    <mprescripts/> <mi>36</mi> <mi>92</mi>
  </mmultiscripts>
  <mo>+</mo>
  <mn>3</mn>
  <mmultiscripts>
    <mi>n</mi>
    <mprescripts/> <mi>0</mi> <mi>1</mi>
  </mmultiscripts>
</math>

Authoring Tools

Manually typing in MathML code is not always easy. Luckily there are many external tools available that enable users to design their equations with a graphical user interface, and subsequently create the MathML code as a file export or through copying and pasting.

These products have been tested to work correctly with Drillster:

  • Online MathML conversion tool by Wolfram Research allows direct conversion to MathML from Mathematica notation and standard text-based notation.
  • MathType by Design Science allows you to draw an equation with a pen, digitize it and copy and paste the equation into Drillster in MathML format.
  • Microsoft Word contains an equation editor for easy authoring of equations. Copy and paste your equations directly into Drillster. Make sure you select β€œMathML” as the standard clipboard format for equations. The standard setting does not work.
  • OpenOffice has native MathML support.

There are many more free and paid alternatives available. Please let us know if you have good experiences with another product that you feel should be listed here.