Comment 18 for bug 891812

Revision history for this message
In , Bastiaan J. Braams (bjbraams) wrote :

The presumed cause of the bug is that the multinomial is computed as a ratio of factorials; this would indeed cause an overflow when the sum of the arguments exceeds 170. Please note that for the implementation of the Binomial in LibreOffice Calc (function COMBIN) no such restriction applies; it is computed carefully to avoid unnecessary overflow.

Please note also that the bug with multinomial would be almost trivial to fix.

A recurrence for computing the multinomial function as a product of
binomials may be found in the description of the multinomial function in
the Sage mathematics system:

http://www.sagemath.org/doc/reference/sage/rings/arith.html#sage.rings.arith.multinomial

The associated 5-line Python code by Gabriel Ebner may be found here:

http://trac.sagemath.org/sage_trac/attachment/ticket/3132/trac3132-2.diff

I believe that this is a very natural way to compute the multinomial, and it would completely remove the problem of unnecessary overflow.