Opened 7 years ago

Closed 3 years ago

#16726 closed defect (fixed)

Binomial Coefficient of Real- or ComplexIntervalField

Reported by: skropf Owned by:
Priority: major Milestone: sage-8.2
Component: basic arithmetic Keywords: RIF, CIF
Cc: dkrenn, cheuberg Merged in:
Authors: Clemens Heuberger Reviewers: Ralf Stephan
Report Upstream: N/A Work issues:
Branch: aa86dd8 (Commits) Commit: aa86dd894f407818670ea1206e49d775b301a4e5
Dependencies: Stopgaps:


The computation of the binomial coefficient of a RIF or CIF (choosing an integer) gives an error:

sage: binomial(CIF(1),2)
Traceback (click to the left of this block for traceback)
TypeError: Either m or x-m must be an integer

This worked well in a previous Sage version (it was 5.13 or later).

Change History (11)

comment:1 Changed 7 years ago by ppurka

I suspect it is #9634 that introduced the change.

comment:2 Changed 6 years ago by cheuberg

  • Cc cheuberg added

Yes, it works until commit 2202e18 and fails to work with commit d2c82ff, i.e. the merge of #9634.

comment:3 Changed 6 years ago by cheuberg

The second argument 2 is converted into a CIF when Function_binomial._evalf_ is called. Therefore, it is no longer recognized as an integer in sage.rings.arith.binomial.

Actually, sage.rings.arith.binomial(CIF(1), 2) yields 0, as expected.

comment:4 Changed 6 years ago by ppurka

One can take this opportunity to clean up the binomial function itself and make it clearer what it does. It is in a bit of a mess.

comment:5 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:6 follow-up: Changed 4 years ago by cheuberg

  • Milestone changed from sage-6.4 to sage-7.6

The following is probably related:

sage: R.<n> = ZZ[]
sage: binomial(n, 3).parent()
Symbolic Ring

is annoying; however,

sage: R.<n> = AsymptoticRing('n^QQ', QQ)
sage: binomial(n, 3)
Traceback (most recent call last):
TypeError: cannot coerce arguments: no canonical coercion from Asymptotic Ring <n^QQ> over Rational Field to Symbolic Ring

throws an error because aysmptotic rings intentionally do not coerce into the symbolic ring.

comment:7 Changed 4 years ago by cheuberg

  • Branch set to u/cheuberg/16726-binomial-cif

comment:8 in reply to: ↑ 6 Changed 4 years ago by cheuberg

  • Authors set to Clemens Heuberger
  • Commit set to aa86dd894f407818670ea1206e49d775b301a4e5
  • Status changed from new to needs_review

Replying to cheuberg:

The following is probably related:

It turns out that this is unrelated; in fact, the problem described in this ticket has been fixed at some stage.

I added a doctest.

sage: R.<n> = ZZ[]
sage: binomial(n, 3).parent()
Symbolic Ring

In fact, this works for polynomials over the rationals, so this is not a real issue.

New commits:

aa86dd8Trac #16726: Add doctest

comment:9 Changed 4 years ago by cheuberg

I opened #22314 for the issue concerning the asymptotic ring. Sorry for the noise here.

comment:10 Changed 3 years ago by rws

  • Milestone changed from sage-7.6 to sage-8.2
  • Reviewers set to Ralf Stephan
  • Status changed from needs_review to positive_review


comment:11 Changed 3 years ago by vbraun

  • Branch changed from u/cheuberg/16726-binomial-cif to aa86dd894f407818670ea1206e49d775b301a4e5
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.