MathML Semantic Enrichment Demo

Input

This demo lets you try out the experimental Semantic Enrichment process, converting simple LaTeX inputs to semantically richer Presentation MathML, Content MathML and Maxima input syntax.

Simply enter a LaTeX math mode expression into the box below and hit Go! to see the resulting outputs.

You can also click the Show Options button if you want to see or mess around with the various configurable options and assumptions that SnuggleTeX will use when processing your input.

NOTE: There is currently a more advanced version of this demo brewing up in the SnuggleTeX Math Playground that you might want to have a look at as well.

LaTeX Math Mode Input:

MathML Rendering

Your browser does not support MathML so we have converted any MathML in this page to either XHTML + CSS or images, depending on how complex the MathML is.

(Note: this statement will not necessarily be true if you are viewing a cached or proxied version of this page, e.g. within the Google cache or something similar. In this case, try viewing the page directly if you can.)

Raw Presentation MathML

This is the Presentation MathML normally produced by SnuggleTeX:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <semantics>
    <mfrac>
      <mrow>
        <mn>2</mn>
        <mi>f</mi>
        <mfenced close=")" open="(">
          <mi>x</mi>
        </mfenced>
        <mo>-</mo>
        <msup>
          <mi>e</mi>
          <mi>x</mi>
        </msup>
      </mrow>
      <mrow>
        <mi>sin</mi>
        <mi>x</mi>
        <msup>
          <mi>y</mi>
          <mn>2</mn>
        </msup>
        <mfenced close=")" open="(">
          <mrow>
            <mi>x</mi>
            <mo>-</mo>
            <mn>2</mn>
          </mrow>
        </mfenced>
      </mrow>
    </mfrac>
    <annotation encoding="SnuggleTeX">\[ \frac{2f(x)-e^x}{\sin xy^2(x-2)} \]</annotation>
  </semantics>
</math>

Enhanced Presentation MathML

This shows the result of attempting to infer semantics from the raw Presentation MathML, as described in Presentation MathML Enhancement:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mfrac>
    <mrow>
      <mrow>
        <mn>2</mn>
        <mo>&InvisibleTimes;</mo>
        <mrow>
          <mi>f</mi>
          <mo>&ApplyFunction;</mo>
          <mfenced close=")" open="(">
            <mi>x</mi>
          </mfenced>
        </mrow>
      </mrow>
      <mo>-</mo>
      <msup>
        <mi>e</mi>
        <mi>x</mi>
      </msup>
    </mrow>
    <mrow>
      <mi>sin</mi>
      <mo>&ApplyFunction;</mo>
      <mrow>
        <mi>x</mi>
        <mo>&InvisibleTimes;</mo>
        <msup>
          <mi>y</mi>
          <mn>2</mn>
        </msup>
        <mo>&InvisibleTimes;</mo>
        <mfenced close=")" open="(">
          <mrow>
            <mi>x</mi>
            <mo>-</mo>
            <mn>2</mn>
          </mrow>
        </mfenced>
      </mrow>
    </mrow>
  </mfrac>
</math>

Content MathML

This shows the result of an attempted conversion to Content MathML:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <apply>
    <divide/>
    <apply>
      <minus/>
      <apply>
        <times/>
        <cn>2</cn>
        <apply>
          <ci type="function">f</ci>
          <ci>x</ci>
        </apply>
      </apply>
      <apply>
        <exp/>
        <ci>x</ci>
      </apply>
    </apply>
    <apply>
      <sin/>
      <apply>
        <times/>
        <ci>x</ci>
        <apply>
          <power/>
          <ci>y</ci>
          <cn>2</cn>
        </apply>
        <apply>
          <minus/>
          <ci>x</ci>
          <cn>2</cn>
        </apply>
      </apply>
    </apply>
  </apply>
</math>

Maxima Input Syntax

This shows the result of an attempted conversion to Maxima Input syntax:

((2 * f(x)) - exp(x)) / sin((x * (y^2) * (x - 2)))

MathML Parallel Markup

This shows the enhanced Presentation MathML with other forms encapsulated as annotations:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <semantics>
    <mfrac>
      <mrow>
        <mrow>
          <mn>2</mn>
          <mo>&InvisibleTimes;</mo>
          <mrow>
            <mi>f</mi>
            <mo>&ApplyFunction;</mo>
            <mfenced close=")" open="(">
              <mi>x</mi>
            </mfenced>
          </mrow>
        </mrow>
        <mo>-</mo>
        <msup>
          <mi>e</mi>
          <mi>x</mi>
        </msup>
      </mrow>
      <mrow>
        <mi>sin</mi>
        <mo>&ApplyFunction;</mo>
        <mrow>
          <mi>x</mi>
          <mo>&InvisibleTimes;</mo>
          <msup>
            <mi>y</mi>
            <mn>2</mn>
          </msup>
          <mo>&InvisibleTimes;</mo>
          <mfenced close=")" open="(">
            <mrow>
              <mi>x</mi>
              <mo>-</mo>
              <mn>2</mn>
            </mrow>
          </mfenced>
        </mrow>
      </mrow>
    </mfrac>
    <annotation-xml encoding="MathML-Content">
      <apply>
        <divide/>
        <apply>
          <minus/>
          <apply>
            <times/>
            <cn>2</cn>
            <apply>
              <ci type="function">f</ci>
              <ci>x</ci>
            </apply>
          </apply>
          <apply>
            <exp/>
            <ci>x</ci>
          </apply>
        </apply>
        <apply>
          <sin/>
          <apply>
            <times/>
            <ci>x</ci>
            <apply>
              <power/>
              <ci>y</ci>
              <cn>2</cn>
            </apply>
            <apply>
              <minus/>
              <ci>x</ci>
              <cn>2</cn>
            </apply>
          </apply>
        </apply>
      </apply>
    </annotation-xml>
    <annotation encoding="SnuggleTeX">\[ \frac{2f(x)-e^x}{\sin xy^2(x-2)} \]</annotation>
    <annotation encoding="LaTeX">\[ \frac{2f(x)-e^x}{\sin xy^2(x-2)} \]</annotation>
    <annotation encoding="Maxima">((2 * f(x)) - exp(x)) / sin((x * (y^2) * (x - 2)))</annotation>
    <annotation-xml encoding="SnuggleTeX-upconversion-options">
      <s:upconversion-options xmlns:s="http://www.ph.ed.ac.uk/snuggletex">
        <s:option name="doContentMathML" value="true"/>
        <s:option name="doMaxima" value="true"/>
        <s:option name="addOptionsAnnotation" value="true"/>
        <s:option name="roundBracketHandling" value="grouping"/>
        <s:option name="roundFenceHandling" value="vector"/>
        <s:option name="squareFenceHandling" value="list"/>
        <s:option name="curlyFenceHandling" value="set"/>
        <s:option name="emptyFenceHandling" value="list"/>
        <s:option name="maximaInverseFunction" value="inverse"/>
        <s:option name="maximaOperatorFunction" value="operator"/>
        <s:option name="maximaUnitsFunction" value="units"/>
        <s:symbol assume="imaginaryNumber">
          <mi>i</mi>
        </s:symbol>
        <s:symbol assume="exponentialNumber">
          <mi>e</mi>
        </s:symbol>
        <s:symbol assume="constantPi">
          <mi>&pi;</mi>
        </s:symbol>
        <s:symbol assume="function">
          <mi>g</mi>
        </s:symbol>
        <s:symbol assume="function">
          <mi>f</mi>
        </s:symbol>
        <s:symbol assume="function">
          <msub>
            <mi>f</mi>
            <mi>n</mi>
          </msub>
        </s:symbol>
        <s:symbol assume="eulerGamma">
          <mi>&gamma;</mi>
        </s:symbol>
      </s:upconversion-options>
    </annotation-xml>
  </semantics>
</math>