<< 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.

Functions and operators

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 f of x ". (Note that you have to include the attribute type='fn' on the ci tag denoting f .) <m:math> <m:apply> <m:ci type='fn'>f</m:ci> <m:ci>x</m:ci> </m:apply> </m:math> This will display as f x .

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 x " 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 x .

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 n th-power of something), and root (for taking the n 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 x ." <m:math> <m:apply> <m:minus/> <m:ci>x</m:ci> </m:apply> </m:math> This will display as x .

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 -1 .

To create more complicated expressions, you can nest these bits of apply code within each other. You can createarbitrarily complex expressions this way. " a times the quantity b plus c " 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 a b c .

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Cnxml tutorial. OpenStax CNX. Jul 08, 2009 Download for free at http://cnx.org/content/col10121/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Cnxml tutorial' conversation and receive update notifications?

Ask