Axeleratio

Combining natural sciences
& computational linguistics

Posts, Memos & Notes

Custom Search

How to encode binomial coefficients in MathML


A binomial coefficient ( n k ) , read n choose k, defines a number as follows:

( n k ) = n (n-1) (n-k+1) k (k-1) (1) .
For example, ( 6 3 ) = 20 . A binomial coefficient symbol looks like a parentheses-enclosed fraction with a missing horizontal fraction line, also termed fraction bar or fraction stroke. This is “how MathML sees it.” Once you know how to encode fractions, you know how to encode binomial coefficients: setting the value of the linethickness attribute inside MathML's mfrag tag does the trick.

We illustrate the markup of binomial coefficients in MathML with the absorption idendity (see page 157 in [CoMa1994]),

( r k ) = r k ( r-1 k-1 ) ,
for which we are using the following MathML code:

<math xmlns="http://www.w3.org/1998/Math/MathML" 
              display="block">
  <mrow>
    <mo>(</mo>
      <mfrac linethickness="0">
        <mi>r</mi>
        <mi>k</mi>
      </mfrac>
      <mo>)</mo>
    <mo>=</mo>
    <mfrac>
      <mi>r</mi>
      <mi>k<mi>
    </mfrac>
    <mo>&InvisibleTimes;</mo>
    <mo>(</mo>
      <mfrac linethickness="0">
        <mrow>
          <mi>r</mi><mo>-</mo><mn>1</mn>
        </mrow>
        <mrow>
          <mi>k</mi><mo>-</mo><mn>1</mn>
        </mrow>
      </mfrac>
    <mo>)</mo>
  </mrow>
</math>
Copy this code or download it here (right-click and “save as...”).

Note: The default linethickness value is medium. Setting the value to 0 shrinks the fraction bar out of display.

Reference

[CoMa1994] Ronald L. Graham, Donald E. Knuth and Oren Patashnik: Concrete Mathematics. Second Edition. Addison-Wesley Publishing Company, Reading, Massachussetts, 1994.