The fundamental concept to grasp about Content MathML is that it consists of applying a series of functions and operators to other elements. To do this, Content MathML uses prefix notation. Prefix notation is when the operator comes first and is followed by the operands. Here is how to write "2 plus 3".
<m:math>
<m:apply>
<m:plus/>
<m:cn>2</m:cn>
<m:cn>3</m:cn>
</m:apply>
</m:math>
There are three types of elements in the Content MathML
example shown above. First, there is the apply
tag, which indicates that an operator (or function) is about
to be applied to the operands. Second, there is the function
or operator to be applied. In this case the operator,
plus, is being applied. Third, the operands
follow the operator. In this case the operands are the
numbers being added. In summary, the apply tag applies the
function (which could be sin or
Tokens
Content MathML has three tokens: ci,
cn, and csymbol. A
token is basically the lowest level element.
The tokens denote what kind of element you are acting on.
The cn tag indicates that the content of the
tag is a number. The ci tag indicates that the
content of the tag is an identifier. An
identifier could be any variable or function;
ci elements can contain
Presentation MathML. Tokens, especially ci and
cn, are used profusely in Content MathML.
Every number, variable, or function is marked by a token.
csymbol is a different type of token from
ci and cn. It is used to create a
new object whose semantics is defined externally. It can
contain plain text or Presentation MathML. If you find that
you need something, such as an operator or function, that is
not defined in Content MathML, then you can use csymbol to
create it.
Both ci and csymbol can use
Presentation MathML to determine how an identifier or a new
symbol will be rendered. To learn more about Presentation
MathML see Section 3
of the MathML 2.0 Specification. For example, to
denote "
<m:math>
<m:ci>
<m:msub>
<m:mi>x</m:mi>
<m:mn>2</m:mn>
</m:msub>
</m:ci>
</m:math>
The ci elements have a type attribute which
can be used to provide more information about the content of
the element. For example, you can declare the contents of a
ci tag to be a function
(type='fn'), or a vector
(type='vector'), or a complex number
(type='complex'), as well as any number of
other things. Using the type attribute helps encode the
meaning of the math that you are writing.
Functions and Operators
In order to apply a function to a variable, make the
function the first argument of an apply. The second
argument will be the variable. For example, you would use
the following code to encode the meaning, "the function
type='fn' on the
ci tag denoting
<m:math>
<m:apply>
<m:ci type='fn'>f</m:ci>
<m:ci>x</m:ci>
</m:apply>
</m:math>
There are also pre-defined functions and operators in
Content MathML. For example, sine and cosine are
predefined. These predefined functions and operators are
all empty tags and they directly follow the
apply tag. "The sine of
<m:math>
<m:apply>
<m:sin/>
<m:ci>x</m:ci>
</m:apply>
</m:math>
You can find a more thorough description of the different predefined functions in Chapter 4 of the MathML specification.
In addition to the predefined functions, there are also many
predefined operators. A few of these are plus
(for addition), minus (for subtraction),
times (for multiplication), divide
(for division), power (for taking the
Most operators expect a specific number of child tags. For example, the power operator expects two children. The first child is the base and the second is the value in the exponent. However, there are other tags which can take many children. For example, the plus operator merely expects one or more children. It will add together all of its children whether there are two or five. This is referred to as an n-ary operator.
Representing "the negative of a variable" and explicitly
representing "the positive of a variable or number" has
slightly unusual syntax. In this case you apply the plus or
minus operator to the variable or number, etc., in question.
The following is the code for "negative
<m:math>
<m:apply>
<m:minus/>
<m:ci>x</m:ci>
</m:apply>
</m:math>
In contrast to representing the negative of a variable, the negative of a number may be coded as follows:
<m:math><m:cn>-1</m:cn></m:math>
To create more complicated expressions, you can nest these
bits of apply code within each other. You can create
arbitrarily complex expressions this way.
"
<m:math>
<m:apply>
<m:times/>
<m:ci>a</m:ci>
<m:apply>
<m:plus/>
<m:ci>b</m:ci>
<m:ci>c</m:ci>
</m:apply>
</m:apply>
</m:math>
The eq operator is used to write equations. It
is used in the same way as any other operator. That is, it
is the first child of an apply. It takes two (or more)
children which are the two quantities that are equal to each
other. For example, "
<m:math>
<m:apply>
<m:eq/>
<m:apply>
<m:plus/>
<m:apply>
<m:times/>
<m:ci>a</m:ci>
<m:ci>b</m:ci>
</m:apply>
<m:apply>
<m:times/>
<m:ci>a</m:ci>
<m:ci>c</m:ci>
</m:apply>
</m:apply>
<m:apply>
<m:times/>
<m:ci>a</m:ci>
<m:apply>
<m:plus/>
<m:ci>b</m:ci>
<m:ci>c</m:ci>
</m:apply>
</m:apply>
</m:apply>
</m:math>







MathML Specification

"The canonical how-to guide to using Connexions."