Broad Network


Script and Limit Schemata for Presentation MathML

Presentation Mathematical Markup Language – Part 3

Foreword: In this part of the series I explain how to identify expressions of subscript, superscript or with accent, and the corresponding MathML elements to use.

By: Chrysanthus Date Published: 20 Feb 2016

Introduction

This is part 3 of my series, Presentation Mathematical Markup Language. In this part of the series I explain how to identify expressions of subscript, superscript or with accent, and the corresponding MathML elements to use. You do not need to understand how to evaluate an expression in order to identify it. You should have read the precious parts of the series before coming here, as this is a continuation. The word, “script” here refers to subscript or superscript; it does not refer to programming or writing of notes. I explain what subscript, superscript and accent mean below.

Superscript <msup>
Now,

     35 = 3× 3× 3× 3× 3

In this statement, 3 is known as the base and 5 is known as the superscript or index. So 3 raised to the power (index) of 5 means 3 is the base and 5 is the superscript. In the expression of 2 raised to the power (index) 4, we have 2 as the base and 4 as the superscript; in the expression of 9 raised to the power 8, we have 9 as the base and 8 as the superscript.

In the above statement, 3 raised to the power (index) 5 is an expression, while 3 x 3 x 3 x 3 x 3 on the right hand side of the equal-to sign, is also an expression. You do not need to know more than that in the statement in order to identify the two expressions.

The syntax for the double tag msup element is:

    <msup> base superscript </msup>

where the arguments, base and superscript are also elements. So, 3 raised to the power 5 will be coded as follows:

    <math>
     <msup>
        <mn>3</mn> <mn>5</mn>
     </msup>
    </math>

while the whole statement above is coded as follows:

    <math>
     <msup>
        <mn>3</mn>
        <mn>5</mn>
     </msup>
     <mo>=</mo>
     <mrow>
        <mn>3</mn><mo>&#xD7;</mo>
        <mn>3</mn><mo>&#xD7;</mo>
        <mn>3</mn><mo>&#xD7;</mo>
        <mn>3</mn><mo>&#xD7;</mo>
        <mn>3</mn>
     </mrow>
    </math>

The msup element takes two arguments: the base and the superscript.

The msup element does not need to be nested in an mrow element. It also acts like an mrow element.

The msqrt, mroot, mfenced, menclose, mstyle or msup element does not need to be nested in the mrow element. It also acts as an mrow element. That is, each of these elements does not need the immediate outer mrow element.

How would you code,

     ( x + y ) 2

Let us look at the complete expression: x + y is an expression, a sub-expression. It is nested in another expression, which is of the parentheses, forming the expression, (x + y) . This new sub-expression is raised to the power 2 to form the complete expression. Here, 2 is an index, and in the Mathematical Markup Language, it is a superscript.

We have identified the expressions. We just have to use the right MathML element for an expression, beginning from the innermost expression. With the strategy, we have:

    <math>
     <msup>
        <mrow>
         <mo> ( </mo>
         <mrow>
            <mi> x </mi>
            <mo> + </mo>
            <mi> y </mi>
         </mrow>
         <mo> ) </mo>
        </mrow>
        <mn> 2 </mn>
     </msup>
    </math>

better coded as:

    <math>
     <msup>
        <mfenced>
         <mrow>
            <mi> x </mi>
            <mo> + </mo>
            <mi> y </mi>
         </mrow>
        </mfenced>
        <mn> 2 </mn>
     </msup>
    </math>

The msup element takes two arguments, which are the elements, base and superscript. The base element and even the superscript can be replaced by an expression in the mrow element.

Note: with mfenced, you do not type the comma operator, where it would be typed; mfenced still displays the comma. Try the following code:

    <math>
     <mfenced> <mi>x</mi> <mi>y</mi> </mfenced>
    </math>

In the previous code, there is no need for a comma.

Subscript <msub>
Read the following number sequence:

    0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, . . .

This is counting in base 4, because no number in the sequence is 4 or above. In the sequence. The number 21 should be written as,

     21 4

coded as,

    <math>
     <msub>
        <mn> 21 </mn>
        <mn> 4 </mn>
     </msub>
    </math>

Counting can still be done in base 5, base 6 and other bases.

In mathematics itself, the word, “base” has two meanings making it ambiguous. If a symbol is raised to a power (another ambiguous word – meaning index here), the symbol is called the base. If a symbol is written with a subscript, that subscript can also be called the base.

In the Mathematical Markup Language (which is our focus), there is no ambiguity: you have superscript and subscript, and the symbol is called the base.

The syntax for the MathML msub element is:

    <msub> base subscript </msub>

where base and subscript are elements. msub takes two elements. Either base or subscript can be an expression within an mrow element.

Subscript-superscript Pair <msubsup>
It is possible to have a symbol, which has a superscript as well as a subscript. The syntax for the double tag MathML element is:

    <msubsup> base subscript superscript </msubsup>

The msubsup element nests three elements: the first is the base, the second is the subscript (goes below) and the third is the superscript. Each of these nested elements can be replaced by an expression in one mrow element.

The msqrt, mroot, mfenced, menclose, mstyle, msup or msub element does not need to be nested in the mrow element. It also acts as an mrow element. That is, each of these elements does not need the immediate outer mrow element.

Read and try the following code:

    <math>
     <msubsup>
        <mn> 21 </mn>
        <mn> 4 </mn>
        <mn> 3 </mn>
     </msubsup>
    </math>

Overscript <mover>
The average of the numbers, 10, 20 and 30 is 20. Meaning, if you add 10 to 20 and to 30 you will have 60; divide 60 by 3 you get the average, which is 20. Assume that the numbers 10, 20 and 30 are each represented by the variable, x. In order to indicate the average, you would write x with a bar above it. That is, x with a bar above it, here, means average.

MathML calls such a bar an overscript or an accent; and it provides the mover element to code such identity (x with a bar over it). If that bar were a number, MathML would call it a limit. So, in order to code overscript or accent or limit, use the mover element, whose syntax is:

    <mover> base overscript </mover>

mover (m-over) element takes two elements, which are the base and the overscript. Read and try the following code for the x with a bar over it:

    <math>
     <mover>
        <mi> x </mi>
        <mo> - </mo>
     </mover>
    </math>

Now, the bar or anything in its place is a MathML operator. In this code the minus sign on the keyboard has been used, and it goes into the mo element.

In another expression, you may have but the opposite letter v, in the place of the bar. This opposite v is an example of what is called an accent. On my keyboard it is printed above the number 6, both on one key. If you do not have this character on your keyboard, then you can use the numeric character reference, &#x5E; within the mo element.

The average information above, can be coded in a statement as follows (read and try it):

    <math>
     <mover>
        <mi> x </mi>
        <mo> - </mo>
     </mover>
     <mo>=</mo>
     <mfrac>
        <mrow>
         <mn> 10 </mn>
         <mo> + </mo>
         <mn> 20 </mn>
         <mo> + </mo>
         <mn> 30 </mn>
        </mrow>
        <mn> 3 <mn>
     </mfrac>
    </math>

The msqrt, mroot, mfenced, menclose, mstyle, msup, msub or mover element does not need to be nested in the mrow element. It also acts as an mrow element. That is, each of these elements does not need the immediate outer mrow element.

Underscript <munder>
This is the opposite of mover. The syntax is:

    <munder> base underscript </munder>

There is a math symbol called, the n-ary summation symbol. It looks like E. The numeric character reference for it is &#x2211; . This symbol often takes an underscript (and also an overscript). Read and try the following code:

    <math>
     <munder>
        <mi> &#x2211; </mi>
        <mo> 0 </mo>
     </munder>
    </math>

It displays the E-like symbol and 0 as the underscript.

Underscript-overscript Pair <munderover>
The syntax for the munderover element is:

    <munderover> base underscript overscript </munderover>

It is possible to have a symbol with an underscript and overscript. Let each of the above numbers from which the average is obtained by x. The numbers are 10, 20, and 30. Let 10 be number 1; let 20 be number 2; let 30 be number 3. With all this, the sum of the three numbers can be written as follows:

     1 3 ( 10 + 20 + 30 )

This expression, means, sum three numbers which are 10, 20 and 30, counting from 1 to 3. The code is:

    <math>
     <munderover>
        <mi> &#x2211; </mi>
        <mo> 1 </mo>
        <mo> 3 </mo>
     </munderover>
     <mo> &#x2062;<!--INVISIBLE TIMES--> </mo>
     <mrow>
        <mo> ( </mo>
         <mrow>
            <mn> 10 </mn>
            <mo> + </mo>
            <mn> 20 </mn>
            <mo> + </mo>
            <mn> 30 </mn>
         </mrow>
        <mo> ) </mo>
     </mrow>
    </math>

The above average statement can be rewritten as follows:

     x - = 1 3 1 3 ( 10 + 20 + 30 )

Do not worry about the mathematical relationship between the two statements. Instead, try to identify the expressions in the two statements. The code for this second statement is (try to identify the expressions in the code):

    <math>
     <mover>
        <mi> x </mi>
        <mo> - </mo>
     </mover>
     <mo>=</mo>
     <mfrac>
        <mn>1</mn>
        <mn>3</mn>
     </mfrac>
     <mo> &#x2062;<!--INVISIBLE TIMES--> </mo>
     <munderover>
        <mi> &#x2211; </mi>
        <mo> 1 </mo>
        <mo> 3 </mo>
     </munderover>
     <mo> &#x2062;<!--INVISIBLE TIMES--> </mo>
     <mrow>
        <mo> ( </mo>
         <mrow>
            <mn> 10 </mn>
            <mo> + </mo>
            <mn> 20 </mn>
            <mo> + </mo>
            <mn> 30 </mn>
         </mrow>
        <mo> ) </mo>
     </mrow>
    </math>

The msqrt, mroot, mfenced, menclose, mstyle, msup, msub, mover, munder or monderover element does not need to be nested in the mrow element. It also acts as an mrow element. That is, each of these elements does not need the immediate outer mrow element.

Vector
A vector is a math quantity in a direction. You might have heard of velocity. Velocity is speed (say of a car) in a particular direction. m/s means meters per second. If they say a car is running at 10m/s; that is the speed. If they say a car is running at 10m/s north; that is the velocity, because the direction has also been indicated.

In mathematics, speed is an example of what is called a scalar quantity. Velocity is a scalar quantity in a direction. What the police on the road normally checks is speed, not velocity. If they were checking the velocity, then they would have to talk about the direction (which they hardly talk about).

The vector, 10m/s north, may be typed in mathematics as:

    10n

where n means the direction of north. In a math expression, the unit (m/s) is not typed. Whatever is the case, the n just after 10 must be bold, to indicate that the quantity, 10n is a vector. The following code does this (try it):

    <math>
     <mn>10</mn>
     <mi mathvariant="bold">n</mi>
    </math>

All token elements have the mathvariant attribute, with "bold" as a possible value.

Note this: the police will unconsciously check the velocity (direction the car was moving to) of a driver, if they suspect that the driver is a thief (or bad in some other way).

Miscellaneous Example – The Quadratic Formula
The quadratic formula is a mathematical formula. You do not really need to know why it exists, what it does and how it does it, in order to code it. What you need is to be able to identify the expressions in the formula in order to code (present) it. The formula is:

     x = - b ± b 2 - 4 a c 2 a

Notice the special operator consisting of a plus sign just above the minus sign. Try to identify all the expressions in the formula. Remember that expressions can be nested. The code for the formula is:

    <math>
     <mi>x</mi>
     <mo>=</mo>
     <mfrac>
        <mrow>
         <mrow>
            <mo>-</mo>
            <mi>b</mi>
         </mrow>
         <mo>&#xB1;<!--PLUS-MINUS SIGN--></mo>
         <msqrt>
            <mrow>
             <msup>
                <mi>b</mi>
                <mn>2</mn>
             </msup>
             <mo>-</mo>
             <mrow>
                <mn>4</mn>
                <mo>&#x2062;<!--INVISIBLE TIMES--></mo>
                <mi>a</mi>
                <mo>&#x2062;<!--INVISIBLE TIMES--></mo>
                <mi>c</mi>
             </mrow>
            </mrow>
         </msqrt>
        </mrow>
        <mrow>
         <mn>2</mn>
         <mo>&#x2062;<!--INVISIBLE TIMES--></mo>
         <mi>a</mi>
        </mrow>
     </mfrac>
    </math>

Identify the expressions in this code and compare them with the formula.

Invisible Comma
Some subscripts have invisible comma. Read and try the following code:

    <math>
      <msub>
        <mi>m</mi>
        <mrow>
          <mn>1</mn>
          <mo> &#x2063;</mo> <!--INVISIBLE COMMA-->
          <mn>2</mn>
        </mrow>
      </msub>
    </math>

An invisible comma separates 1 and 2 for the subscript.

There are four invisible operators, which are: invisible times, invisible plus, apply function and invisible comma. Each of these has a numeric character reference, which goes into the mo element. It is the responsibility of the math author (scientist) to tell you what and where the invisible operator is. If he does not do that, ask him.

Prescripts and Tensor Indices <mmultiscripts>, <mprescripts/>, <none/>
This is quotation from the specification:

"Presubscripts and tensor notations are represented by a single element, mmultiscripts, using the syntax:

<mmultiscripts>
    base
     (subscript superscript)*
     [ <mprescripts/> (presubscript presuperscript)* ]
</mmultiscripts>

This element allows the representation of any number of vertically-aligned pairs of subscripts and superscripts, attached to one base expression. It supports both postscripts and prescripts. Missing scripts can be represented by the empty element none.

The prescripts are optional, and when present are given after the postscripts, because prescripts are relatively rare compared to tensor notation."

Read and try the following code, still copied from the specification:

<mmultiscripts>
  <mi> R </mi>
  <mi> i </mi>
  <none/>
  <none/>
  <mi> j </mi>
  <mi> k </mi>
  <none/>
  <mi> l </mi>
  <none/>
</mmultiscripts>

As you can see from all the above, coding mathematics is not difficult. You need to identify the expressions, and then use the appropriate MathML elements for the expressions.

Legal Issues
In a mathematical expression, the slightest change in number or script, or the using of a wrong identifier, or the omission of an operator, or parentheses, gives wrong result. In fact the slightest error gives wrong result. Before you publish any mathematics production, make sure the math author (scientist) proofreads it first. Otherwise charges may be levied against you by the users (readers).

That is it for this part of the series. We continue in the next part. We are moving on!

Chrys

Related Links

Basics of HTML 5
Basics of ECMAScript
HTML DOM Basics
CSS Basics
Text Elements in HTML
Grouping Content
Microsyntax Dates and Times in HTML
Sectioning Content
Common Idioms without Dedicated Elements
HTML Embedded Content
HTML Insecurities and Prevention
Presentation Mathematical Markup Language
More Related Links
PurePerl MySQL API
Major in Website Design
Perl Course - Optimized
Web Development Course

BACK NEXT

Comments

Become the Writer's Fan
Send the Writer a Message