<< Chapter < Page | Chapter >> Page > |
The
ci
elements have a type attribute which
can be used to provide more information about the content ofthe 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 themeaning of the math that you are writing.
In order to apply a function to a variable, make the
function the first argument of an apply. The secondargument will be the variable. For example, you would use
the following code to encode the meaning, "the function
of
". (Note that you have to
include the attribute
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
.
There are also pre-defined functions and operators in
Content MathML. For example, sine and cosine arepredefined. These predefined functions and operators are
all
empty tags and they directly follow the
apply tag. "The sine of
" is
similar to the example above.
<m:math>
<m:apply>
<m:sin/>
<m:ci>x</m:ci>
</m:apply>
</m:math>
This will display as
.
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
th-power of something), and
root (for taking the
th-root
of something).
Most operators expect a specific number of child tags. For example, the power operator expects two children. The firstchild is the base and the second is the value in the exponent. However, there are other tags which can take manychildren. For example, the plus operator merely expects one or more children. It will add together all of its childrenwhether 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" hasslightly 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>
This will display as
.
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>
This will display as
.
To create more complicated expressions, you can nest these
bits of apply code within each other. You can createarbitrarily complex expressions this way.
"
times the quantity
plus
" would be written as
follows.
<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
.
Notification Switch
Would you like to follow the 'Cnxml tutorial' conversation and receive update notifications?