Opened 9 years ago

Last modified 9 years ago

#11411 closed defect

some q binomial coefficients should be zero — at Version 9

Reported by: chapoton Owned by: sage-combinat
Priority: minor Milestone: sage-4.7.2
Component: combinatorics Keywords:
Cc: chapoton, sage-combinat Merged in:
Authors: Frédéric Chapoton Reviewers: Florent Hivert
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by hivert)

I have found the following behaviour:

sage: import sage.combinat.q_analogues as qa
sage: qa.q_binomial(2,-1)
1/(q^2 + q + 1)
sage: binomial(2,-1)
0
sage: qa.q_binomial(2,3)
1/(q^2 + q + 1)
sage: binomial(2,3)
0

I think these q-binomials should rather be zero. The q-binomial is based on the q-factorial, where one finds the following behaviour

sage: [qa.q_factorial(-i) for i in range(6)]
[1, 1, 1, 1, 1, 1]

This seems to be rather wrong, as the factorial itself is infinite for negative integers.

The patch restricts the q-factorial to nonnegative arguments and defines q-binomials outside of the correct range to be zero.

Apply:

Change History (10)

Changed 9 years ago by chapoton

comment:1 Changed 9 years ago by chapoton

  • Status changed from new to needs_review

comment:2 Changed 9 years ago by chapoton

  • Description modified (diff)

comment:3 Changed 9 years ago by chapoton

  • Cc sage-combinat added

comment:4 Changed 9 years ago by chapoton

  • Description modified (diff)

comment:5 Changed 9 years ago by chapoton

  • Description modified (diff)

comment:6 Changed 9 years ago by chapoton

  • Authors set to Frederic Chapoton

comment:7 Changed 9 years ago by chapoton

  • Authors changed from Frederic Chapoton to Frédéric Chapoton

comment:8 Changed 9 years ago by hivert

  • Reviewers set to Florent Hivert

Hi Frédéric,

When you write a patch which fixes a bug, you should add a doctest checking that the bug is indeed fixed, together with the ticket number.

I wrote a small review patch which does that. Your patch is Ok with me but someone must review mine. If you can do that and if my modification are Ok, you can put a positive review on that one !

comment:9 Changed 9 years ago by hivert

  • Description modified (diff)
Note: See TracTickets for help on using tickets.