পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Saturday, March 4, 2017

MathML - Basic Elements

There are five basic elements of a MathML expression.
  • <math> element - It is top or root level element and is used to encapsulate each instance of MathML instance. Every valid MathML expression should be wrapped in outer <math> tag. It can contain any number of child elements. One math element cannot contain another math element tag.
  • <mrow> element - It is used to group any number of sub expressions in horizontal way.
  • <mi> element - It is used to specify an identifier such as name of a variable, function or a constant etc. For example, <mi>PI</mi> .
  • <mo> element - It is used to specify an operator like +, - etc. For example, <mo>+</mo>.
  • <mn> element - It is used to specify a numerical literal like 3.14 etc. For example, <mn>3.14</mn>.

Example

Let's build a simple mathematical equation a + b = 5 using MathML notation.

Step 1: Identification

Here a, b are variables. + is an operator and 5 is a number. We'll enclose them as <mi>a</mi> , <mi>b</mi>, <mo>+</mo> and <mn>+</mn>

Step 2: Build Expression, a + b.

Syntax

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>  
   <mi>a</mi>  
   <mo>+</mo>  
   <mi>b</mi>  
</mrow>  
</math>

Output

a+b

Step 3: Build Expression, a + b = 5.

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow> 
   <mrow>  
      <mi>a</mi>  
      <mo>+</mo>  
      <mi>b</mi>  
   </mrow>
   <mo>=</mo>  
   <mn>5</mn>  
</mrow>    
</math>

Output

a+b=5

No comments:

Post a Comment