Fandom

MathML

648pages on
this wiki
Add New Page
Comments0 Share

Mathematical Markup Language is an application of XML for describing mathematical notations and capturing both its structure and content. It aims at integrating mathematical formulae into World Wide Web pages and other documents. It is a recommendation of the W3C math working group.

Presentation and semanticsEdit

MathML deals not only with the presentation but also the meaning of formula components (the latter part of MathML is known as “Content MathML”). Because the meaning of the equation is preserved separate from the presentation, how the content is communicated can be left up to the user. For example, web pages with MathML embedded in them can be viewed as normal web pages with many browsers but visually impaired users can also have the same MathML read to them through the use of screen readers (e.g. using the MathPlayer plugin for Internet Explorer, Opera 9.50 build 9656+ or the Fire Vox extension for Firefox).

Presentation MathMLEdit

Presentation MathML focuses on the display of an equation, and has about 30 elements, and 50 attributes. The elements all begin with m and include token element: <mi>x</mi> - identifiers; <mo>+</mo> - operators; <mn>2</mn> - number. Tokens are combined using layout elements that include: <mrow> - a row; <msup> - superscripts; mfrac - fractions. The attributes mainly control fine details of the presentation. A large number of entities are available that represent letters &pi;, symbols &RightArrow; and some non-visible character such as &InvisibleTimes; representing multiplication.

For valid XML documents as per the W3C specifications, a MathML file must have a <!DOCTYPE> declaration:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"
           "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">

Thus, the expression a x^2+b x+c could be represented in a valid MathML file as:

 <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"
           "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
  <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mrow>
      <mi>a</mi>
      <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi>b</mi>
      <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
      <mi>x</mi>
      <mo>+</mo>
      <mi>c</mi>
    </mrow>
  </math>

Content MathMLEdit

Content MathML focuses on the semantic meaning of the expression. Central to Content MathML is the <apply> element that represents a function or operator, given in the first child, applied to the remaining child elements. For example <apply><sin/><ci>x</ci></apply> represents \sin(x) and <apply><plus/><ci>x</ci><cn>5</cn></apply> represents x+5. The <ci> element represents an identifier, <cn> a number, and there are over a hundred different elements for different functions and operators. Content MathML uses only a few attributes.

The expression a x^2+b x+c could be represented as

<math>
    <apply>
        <plus/>
        <apply>
            <times/>
            <ci>a</ci>
            <apply>
                <power/>
                <ci>x</ci>
                <cn>2</cn>
            </apply>
        </apply>
        <apply>
            <times/>
            <ci>b</ci>
            <ci>x</ci>
        </apply>
        <ci>c</ci>
    </apply>
</math>

Embedding MathML in HTML5 filesEdit

Inline MathML is also supported in HTML5 files in the upcoming versions of WebKit (Safari, Chrome), Gecko (Firefox) and Presto (Opera).

e.g. math-test.html:

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="language" content="en-US" />
    <meta name="description" content="Example of MathML embedded in an HTML5 file" />
    <meta name="keywords" content="Example of MathML embedded in an HTML5 file" />
    <title>Example of MathML embedded in an HTML5 file</title>
  </head>
  <body>
    <h1>Example of MathML embedded in an HTML5 file</h1>
    <p>
      Given the quadratic equation
      <math xmlns="http://www.w3.org/1998/Math/MathML">
        <mrow>
          <mi>a</mi>
          <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
          <msup>
            <mi>x</mi>
            <mn>2</mn>
          </msup>
          <mo>+</mo>
          <mi>b</mi>
          <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>c</mi>
        </mrow>
      </math>
      , the roots are given by
      <math xmlns="http://www.w3.org/1998/Math/MathML">
        <mrow>
          <mi>x</mi>
          <mo>=</mo>
          <mfrac>
            <mrow>
              <mo form="prefix">&#x2212;<!-- &minus; --></mo>
              <mi>b</mi>
              <mo>&#x00B1;<!-- &PlusMinus; --></mo>
              <msqrt>
                <msup>
                  <mi>b</mi>
                  <mn>2</mn>
                </msup>
                <mo>&#x2212;<!-- &minus; --></mo>
                <mn>4</mn>
                <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
                <mi>a</mi>
                <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
                <mi>c</mi>
              </msqrt>
            </mrow>
            <mrow>
              <mn>2</mn>
              <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
              <mi>a</mi>
            </mrow>
          </mfrac>
        </mrow>
      </math>
      .
    </p>
  </body>
</html>

External LinksEdit


This page uses Creative Commons Licensed content from Wikipedia (view authors).

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.