Summary: A short introduction to writing Content MathML by hand. It covers tokens, prefix notation, and applying functions and operators. In addition it introduces writing derivatives, integrals, vectors, and matrices.
m prefix is used to
denote tags in the MathML namespace. Thus the
<apply> tag is referred to as
<m:apply>. Remember all markup in
the MathML namespace must be surrounded by
<m:math> tags.
<m:math>
<m:apply>
<m:plus/>
<m:cn>2</m:cn>
<m:cn>3</m:cn>
</m:apply>
</m:math>
This would display as
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
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.
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.
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>This would display as
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.
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>This will display as
<m:math> <m:apply> <m:sin/> <m:ci>x</m:ci> </m:apply> </m:math>This will display as
plus
(for addition), minus (for subtraction),
times (for multiplication), divide
(for division), power (for taking the
<m:math> <m:apply> <m:minus/> <m:ci>x</m:ci> </m:apply> </m:math>This will display as
<m:math><m:cn>-1</m:cn></m:math>This will display as
<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>This will display as
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>This will display as
int. However,
unlike the operators and functions discussed above, it has
children that define the independent variable that you
integrate with respect to (bvar) and the interval
over which the integral is taken (use either
lowlimit and uplimit, or
interval, or condition).
lowlimit and uplimit (which go
together), interval, and condition
are just three different ways of denoting the integrands.
Don't forget that the bvar, lowlimit,
uplimit, interval, and
condition children take token elements as well.
The following is "the integral of
<m:math>
<m:apply>
<m:int/>
<m:bvar><m:ci>x</m:ci></m:bvar>
<m:lowlimit><m:cn>0</m:cn></m:lowlimit>
<m:uplimit><m:ci>b</m:ci></m:uplimit>
<m:apply>
<m:ci type='fn'>f</m:ci>
<m:ci>x</m:ci>
</m:apply>
</m:apply>
</m:math>
This will display as
diff. The derivative
is done in much the same way as the integral. That is, you
need to define a base variable (using bvar). The
following is "the derivative of the function
<m:math>
<m:apply>
<m:diff/>
<m:bvar>
<m:ci>x</m:ci>
</m:bvar>
<m:apply>
<m:ci type="fn">f</m:ci>
<m:ci>x</m:ci>
</m:apply>
</m:apply>
</m:math>
This will display as
degree tag inside of the bvar tag.
The degree tag will contain the order of the derivative. The
following shows "the second derivative of the function
<m:math>
<m:apply>
<m:diff/>
<m:bvar>
<m:ci>x</m:ci>
<m:degree><m:cn>2</m:cn></m:degree>
</m:bvar>
<m:apply><m:ci type="fn">f</m:ci>
<m:ci>x</m:ci>
</m:apply>
</m:apply>
</m:math>
This will display as
vector tag.
<m:math>
<m:vector>
<m:apply>
<m:plus/>
<m:ci>x</m:ci>
<m:ci>y</m:ci>
</m:apply>
<m:ci>z</m:ci>
<m:cn>0</m:cn>
</m:vector>
</m:math>
This will display as
matrix element contains several
matrixrow elements. Then each
matrixrow element contains several other
elements.
<m:math>
<m:matrix>
<m:matrixrow>
<m:ci>a</m:ci>
<m:ci>b</m:ci>
<m:ci>c</m:ci>
</m:matrixrow>
<m:matrixrow>
<m:ci>d</m:ci>
<m:ci>e</m:ci>
<m:ci>f</m:ci>
</m:matrixrow>
<m:matrixrow>
<m:ci>g</m:ci>
<m:ci>h</m:ci>
<m:ci>j</m:ci>
</m:matrixrow>
</m:matrix>
</m:math>
This will display as
Comments, questions, feedback, criticisms?