Object Library > Workshop > Schedule > MathML

The Mathematics Markup Language


Extensible Markup Language

The Extensible Markup Language (XML) is a meta-language, that is, a language for creating specialized markup languages for special purposes. Thus, XML is the mother of all markup languages. It is not a language itself, but rather is a framework, or set of rules, for creating standardized, compatible  markup languages. XML is an extremely important standard, and XML applications are now becoming ubiquitous. Here are a few examples:

Just like HTML, XML documents are pure text, with the data marked up with tags of two basic types:

MathML

MathML is an XML application for encoding mathematics. Islands of MathML can be embedded in an ordinary HTML web page to display mathematics in correct notation. MathML is now a widely accepted standard, and is supported by many different applications, including

The potential of MathML is enormous. A mathematical expression encoded in MathML could be

MathML comes in two basic forms:

In Presentation MathML, the mathematical notation is marked up so that the expression is rendered in a specific way. This is much like TeX. By contrast, in Content MathML, the underlying structure and objects of the mathematical expression are marked up. The way that the expression is rendered is controlled by a style sheet.

Although MathML is not intended to be written by hand, a basic understanding of the structure is important for anyone using MathML. In the sections below, we discuss some of the basic markup. First, each mathematical expression in the document is an island of MathML, enclosed in the <math></math> tag. This tag has a display attribute. Setting the attribute to "block" causes the expression to be centered; otherwise the expression is inline.

Browser Issues

MathML can be displayed using Internet Explorer 6.0 on Windows with the free MathPlayer plug-in or in Netscape Navigator 7.0 with MathML enabled and the appropriate fonts installed. In either case, additional markup must be added to the HTML code. 

Internet Explorer

First add an attribute to the HTML tag:

Next, add the following in the <head></head> tag:

<object ID="MathPlayer" CLASSID="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"></object>
<?import NAMESPACE="m" IMPLEMENTATION="#MathPlayer"?><xml:namespace prefix="m" />
<style> m:math {behavior: url(mml.htc)} </style>

Finally, each MathML tag has the prefix m:

Internet Explore and Netscape Navigator

First the files must be saved with the extension .xml, instead of .htm or .html. The following files, available from the MathML site at the World Wide Web Consortium should be saved to the server:

The first two lines should be as follows, where href points to the URL of mathml.xls

<?xml-stylesheet type="text/xsl" href="mathml.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml">

Finally, each island of MathML in the document begins with

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

Presentation MathML

Identifiers

Variables and names are enclosed in the <mi></mi> tag. By default, a single character is rendered in italics, while multiple characters are rendered in regular style.

Numbers

Numbers are enclosed in the <mn></mn> tag.

Operators

Operators are enclosed in the <mo></mo>. The usual arithmetic operators are examples, but parentheses and other fences are also treated as operators.

Rows

Subexpressions are grouped using the <mrow></mrow> tag.

Example

5(x+y)

<math>
    <mrow><mn>5</mn><mo>(</mo><mi>x</mi><mo>+</mo><mi>y</mi><mo>)</mo></mrow>
</math>

Subscripts

Subscripts are defined using the <msub></msub> tag.

Example

Xn+1

<math>
    <msub><mi>X</mi><mrow><mi>n</mn><mo>+</mo><mn>1</mn></mrow></msub>
</math>

Superscripts

Superscripts are defined using the <msup></msup> tag.

Example

Xn+1

<math>
    <msup><mi>X</mi><mrow><mi>n</mn><mo>+</mo><mn>1</mn></mrow></msup>
</math>

Fractions

Fractions are defined using the <mfrac></mfrac> tag

Example

x 2 1 x 2 +1

<math>
    <mfrac>
        <mrow><msup><mi>x</mi><mn>2</mn> </msup>
        <mo>&#8722;</mo><mn>1</mn> </mrow>
        <mrow><msup><mi>x</mi><mn>2</mn> </msup>
        <mo>+</mo><mn>1</mn> </mrow>
    <mfrac>
</math>

Example

( n k )

<math>
    <mrow>
        <mo>(</mo>
        <mfrac linethickness="0">
            <mi>n</mi>
            <mi>k</mi>
        </mfrac>
        <mo>)</mo>
    </mrow>
</math>

Example

a b f(x)dx

<math>
    <mrow>
         <munderover>
            <mo>&#8747;</mo>
            <mi>a</mi>
            <mi>b</mi>
        </munderover>
        <mrow>
            <mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mi>d</mi><mi>x</mi>
        </mrow>
    </mrow>
</math>

Example

X ¯ n = i=1 n X i

<m:math display="block">
    <mrow>
        <msub>
            <mover accent='true'>
                <mi>X</mi>
                <mo>&#x00AF;</mo>
            </m:mover>
            <mi>n</mi>
        </msub>
        <mo>=</mo>
        <munderover>
            <mo>&#x2211;</mo>
            <mrow>
                <mi>i</mi><m:mo>=</mo><mn>1</mn>
            </mrow>
            <mi>n</mi>
        </munderover>
        <mrow>
            <msub>
                <mi>X</mi>
                <mi>i</mi>
            </msub>
        </mrow>
    </mrow>
</math>

Content MathML

Identifiers

Variables and names are enclosed in the <ci></ci> tag. By default, a single character is rendered in italics, while multiple characters are rendered in regular style.

Numbers

Numbers are enclosed in the <cn></cn> tag.

Operators

Operators are enclosed in a tag of the form <apply><operator /></apply>.

Functions

Functions are defined with the <apply></apply> tag. The first included element is the function name, and the remaining included elements are the variables.

Special functions have their own tags. They include

Example

x 2 1 x 2 1

<math display="block">
    <apply><divide />
        <apply><plus />
            <apply><power />
                <ci>x</ci>
                <cn>2</cn>
            </apply>
            <cn>1</cn>
        </apply>
        <apply><minus />
            <apply><power />
                <ci>x</ci>
                <cn>2</cn>
            </apply>
            <cn>1</cn>
        </apply>
    </apply>
</math>

Example

f x x 1 x

<math display="block">
    <apply><m:eq />
        <apply>
            <ci>f</ci>
            <ci>x</ci>
        </apply>
        <apply><times />
            <ci>x</ci>
            <apply><sin />
                <apply><divide />
                    <cn>1</cn>
                    <ci>x</ci>
                </apply>
            </apply>
        </apply>
    </apply>
</math>

Resources

Resources on the Web

Tools at the Workshop

Exercises

  1. Explore the MathML in the source code of this page.
  2. Visit the page on Probability Measures in Virtual Laboratories in Probability and Statistics. Note the mathematical notation on the page. Examine the source code and study the corresponding MathML.
  3. Copy some of the content MathML expression on this page to the clipboard and then paste them into a Maple docuemnt.
  4. Add some simple  mathematical expressions to some of the pages in your project by hand-coding the MathML
  5. Use MathType to add mathematics (in MathML form) to some of the pages in your project.
  6. Use Maple to add mathematics (in MathML form) to some of the pages in your project.

Object Library > Workshop > Schedule > MathML | Comments