#6870: [with patch, needs review] Bug in binomial
------------------------------+---------------------------------------------
Reporter: hgranath | Owner: somebody
Type: defect | Status: new
Priority: minor | Milestone: sage-4.1.2
Component: basic arithmetic | Keywords: binomial
Reviewer: | Author:
Merged: |
------------------------------+---------------------------------------------
Here are two cases where binomial fails. I think it is not
properly converting its arguments to Integers in all cases where
it should.
{{{
sage: binomial(1/2,1/1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/home/hakan/.sage/temp/joker/27910/_home_hakan__sage_init_sage_0.py in
<module>()
/media/megadisk/sage-4.1.1/local/lib/python2.6/site-
packages/sage/rings/arith.py in binomial(x, m)
2602 except AttributeError:
2603 pass
-> 2604 raise TypeError, 'Either m or x-m must be an integer'
2605 if isinstance(x, (int, long, integer.Integer)):
2606 if x >= 0 and (m < 0 or m > x):
TypeError: Either m or x-m must be an integer
}}}
{{{
sage: binomial(10^20+1/1,10^20)
---------------------------------------------------------------------------
OverflowError Traceback (most recent call
last)
/home/hakan/.sage/temp/joker/27910/_home_hakan__sage_init_sage_0.py in
<module>()
/media/megadisk/sage-4.1.1/local/lib/python2.6/site-
packages/sage/rings/arith.py in binomial(x, m)
2625 from sage.functions.all import gamma
2626 return gamma(x+1)/gamma(P(m+1))/gamma(x-m+1)
-> 2627 return misc.prod([x-i for i in xrange(m)]) / P(factorial(m))
2628
2629 def multinomial(*ks):
OverflowError: long int too large to convert to int
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6870>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---