Opened 9 years ago
Closed 7 years ago
#11476 closed defect (fixed)
PartitionTuples.cardinality has problems
Reported by: | pdehaye | Owned by: | sage-combinat |
---|---|---|---|
Priority: | major | Milestone: | sage-5.5 |
Component: | combinatorics | Keywords: | PartitionTuple, cardinality, beginner |
Cc: | sage-combinat | Merged in: | sage-5.5.beta2 |
Authors: | Andrew Mathas | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #13072 | Stopgaps: |
Description (last modified by )
It works for smaller values.
sage: PartitionTuples(100,13).cardinality() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Volumes/Scratch/Users/duser1/sage/<ipython console> in <module>() /Users/duser1/sage/local/lib/python2.6/site-packages/sage/combinat/partition.pyc in cardinality(self) 3183 185 3184 """ -> 3185 return ZZ(gp.eval('polcoeff(1/eta(x)^%s, %s, x)'%(self.k, self.n))) 3186 3187 /Users/duser1/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6820)() /Users/duser1/sage/local/lib/python2.6/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3254)() /Users/duser1/sage/local/lib/python2.6/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3157)() /Users/duser1/sage/local/lib/python2.6/site-packages/sage/rings/integer.so in sage.rings.integer.Integer.__init__ (sage/rings/integer.c:7212)() TypeError: unable to convert x (= *** at top-level: polcoeff(1/eta(x)^13 *** ^-------------------- *** polcoeff: non existent component in truecoeff.) to an integer sage:
As noted below, this turned out to just be an issue of increasing the precision in the pari function call. The attached patch fixes the problem:
Attach trac_11476--fixing-partition-tuples_cardinality-am.patch
Attachments (1)
Change History (12)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
I had a reply from Karim Belabas (UMR 5251) on pari-dev and it is just a matter of increasing the precision:
(08:12) gp > 1/eta(x)^2 %1 = 1 + 2*x + 5*x^2 + 10*x^3 + 20*x^4 + 36*x^5 + 65*x^6 + 110*x^7 + 185*x^8 + 300*x^9 + 481*x^10 + 752*x^11 + 1165*x^12 + 1770*x^13 + 2665*x^14 + 3956*x^15 + 5822*x^16 + O(x^17) The series precision is too low, so the 17-th coefficient is unknown. Use 1/eta(x + O(x^101)) if you want to access its 100-th coefficient (for instance). Cheers, K.B.
I'll upload a patch shortly.
comment:3 Changed 7 years ago by
- Cc sage-combinat added
- Dependencies set to #13072
- Keywords PartitionTuple cardinality added
- Status changed from new to needs_review
comment:4 Changed 7 years ago by
- Keywords beginner added
comment:5 Changed 7 years ago by
- Description modified (diff)
comment:6 Changed 7 years ago by
- Reviewers set to Travis Scrimshaw
Looks good, just do an automatic trac link :trac:`11476`
in the doc.
Thanks.
PS - Its somewhat entertaining to me to compute these huge numbers:
sage: PartitionTuples(162,120).cardinality() 414170543784152902405501503878656556915420510510717572175693806227335527665907778197451415072951
comment:7 Changed 7 years ago by
Thanks for catching this...it seems that the version in the queue did this properly but that I hadn't uploaded it here...fixed now.
Cheers, Andrew
ps. I didn't check any of these big numbers by hand:)
comment:8 Changed 7 years ago by
Thanks! I'll double-check everything once #13072 is fixed up, but basically this is a positive review.
comment:9 Changed 7 years ago by
- Status changed from needs_review to positive_review
I believe this needs to be rebased to remove the fuzz:
Hunk #1 succeeded at 1626 with fuzz 1 (offset -1 lines)
but good otherwise so I am setting it to a positive review.
Travis
comment:10 Changed 7 years ago by
- Milestone changed from sage-5.4 to sage-5.5
comment:11 Changed 7 years ago by
- Merged in set to sage-5.5.beta2
- Resolution set to fixed
- Status changed from positive_review to closed
This seems to be problem in the pari function call, or possibly a bug in pari. I have emailed the pari development group to ask them about it.
This failure appears much earlier than the example above suggests:
If you run pari natively you get the error more quickly:
This is a little surprising as the number of 2-tuples of partitions adding to 17 is 8470, which isn't that big.