XML technologies / MathML / Content markup / Operators and functions / Relations

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

Several content elements have been defined for representing various types of arithmetic and logical relations, such as a = b or x < y. You express a relation in content markup by using a relational content element as the first argument of an apply element. You do it this way because you can think of a relational expression as the result of applying a function to a set of arguments. The result of applying the function is one of the logical values, True or False.

The following content elements represent the common types of relational operators: eq, neq, gt, lt, geq, leq, equivalent, approx, factorof, implies, and tendsto.

Here is an example of a simple equality:

2 + 2 = 4

<apply>
  <eq/>
  <apply>
    <plus/>
    <cn>2</cn>
    <cn>2</cn>
  </apply>
  <cn>4</cn>
</apply>

The number of child elements in the apply element is determined by the type of relational element that occurs as the first argument. Some relational elements such as neq act as binary operators since they always express a relation between two quantities. Other relational elements such as eq, leq, lt, gt, and geq act as n-ary operators; that is, they can be followed by an arbitrary number of elements to express compound relations, such as in the markup below:

a < b < c < d

<apply>
  <lt/>
  <ci>a</ci>
  <ci>b</ci>
  <ci>c</ci>
  <ci>d</ci>
</apply>

   

 

 

 

 

back to top