Showing posts with label Content MathML. Show all posts
Showing posts with label Content MathML. Show all posts

Wednesday, 9 May 2012

A look into MathML


Mathematical Markup Language is an application of Extensible Markup Language (XML) for describing mathematical notation and capturing both its structure and content. The main aim of MathML is to integrate math with the World Wide Web. Essentially MathML is for math what HTML is for text. 

As mentioned before MathML deals with both the structure and the content of a mathematical notation. The structure part is called Presentation MathML and as the name suggests it deals with the display of the notation, equation or formula. Whereas the content part is called Content MathML and it focuses on the semantics. 
An example of a Presentation MathML for  is :

 <math>
  <mrow>
    <mi>x</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mrow>
          <mo>-</mo>
          <mi>b</mi>
        </mrow>
        <mo>
          &#xB1;<!--PLUS-MINUS SIGN-->
        </mo>
        <msqrt>
          <mrow>
            <msup>
              <mi>b</mi>
              <mn>2</mn>
            </msup>
            <mo>-</mo>
            <mrow>
              <mn>4</mn>
              <mo>
                &#x2062;<!--INVISIBLE TIMES-->
              </mo>
              <mi>a</mi>
              <mo>
                &#x2062;<!--INVISIBLE TIMES-->
              </mo>
              <mi>c</mi>
            </mrow>
          </mrow>
        </msqrt>
      </mrow>
      <mrow>
        <mn>2</mn>
        <mo>
          &#x2062;<!--INVISIBLE TIMES-->
        </mo>
        <mi>a</mi>
      </mrow>
    </mfrac>
  </mrow>
</math>

As seen above every valid MathML expression is wrapped in outer <math> tags which shows each instance of MathML markup within a document. 

The presentation elements have 2 classes – Token Elements (symbols, numbers, names etc.) and Layout Schemata (which builds expressions out of the parts and have only elements as its content). Here we are using various token elements such as mi – identifier, mo – operator, mn – number. And general layout schemata elements such as mrow (groups any numbers of sub-expressions horizontally), mfrac (fraction of 2 sub-expressions), msqrt (square root)

Also above we can see that we write b^2 using superscript and two letters written side by side will mean two variables multiplied together which shows that the presentation markup just holds the structure and we need content markup to put in meaning into the formula. 

Content MathML for the same formula would be:

<math>
  <apply>
    <eq/>
    <ci>x</ci>
    <apply>
      <divide/>
      <apply>
        <plus/>
        <apply>
          <minus/>
          <ci>b</ci>
        </apply>
        <apply>
          <root/>
          <apply>
            <minus/>
            <apply>
              <power/>
              <ci>b</ci>
              <cn>2</cn>
            </apply>
            <apply>
              <times/>
              <cn>4</cn>
              <ci>a</ci>
              <ci>c</ci>
            </apply>
          </apply>
        </apply>
      </apply>
      <apply>
        <times/>
        <cn>2</cn>
        <ci>a</ci>
      </apply>
    </apply>
  </apply>
</math>

Content MathML represents mathematical objects as expression trees (i.e. applying operator to sub objects). Hence, the terminal nodes represents basic math objects such as numbers, variables etc. and the internal nodes represent mathematical constructions or function applications. 

Token elements – ci (represent variables) ,cn(numbers), Predefined functions elements – divide, minus, plus are used here. And as we can see above that the Apply element groups the function with its arguments syntactically.

About thirty-eight of the MathML tags describe abstract notational structures, while another about one hundred and seventy provide a way of unambiguously specifying the intended meaning of an expression.