Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large exponents overflow to negative in polydict ring #6428

Closed
sagetrac-broune mannequin opened this issue Jun 26, 2009 · 16 comments
Closed

Large exponents overflow to negative in polydict ring #6428

sagetrac-broune mannequin opened this issue Jun 26, 2009 · 16 comments

Comments

@sagetrac-broune
Copy link
Mannequin

sagetrac-broune mannequin commented Jun 26, 2009

Large exponents overflow to negative in polydict ring:

sage: from sage.rings.polynomial.multi_polynomial_ring import \
...       MPolynomialRing_polydict
sage: ring = MPolynomialRing_polydict(ZZ, 3, ['a','b','c'], "lex")
sage: a = ring.gens()[0]

sage: a^(2^31-1)
a^2147483647

sage: a^(2^31)
a^-2147483648

sage: a^(2^32)
1

Component: commutative algebra

Author: Willem Jan Palenstijn

Reviewer: Sebastian Pancratz

Merged: sage-4.3.2.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/6428

@sagetrac-broune

This comment has been minimized.

@sagetrac-broune
Copy link
Mannequin Author

sagetrac-broune mannequin commented Jun 26, 2009

comment:1

Fixed layout.

@aghitza aghitza added this to the sage-4.3 milestone Nov 15, 2009
@williamstein
Copy link
Contributor

comment:3

This is still a bug. Ick!

sage: R.<y,z> =Frac(QQ['x'])[]
sage: y^(2^32)
1
sage: y^(2^32-1)
y^-1
sage: y^(2^31)
y^-2147483648

@williamstein
Copy link
Contributor

comment:4

Here is better input to replicate what is at the core of the problem:

sage: a = sage.rings.polynomial.polydict.PolyDict({(2147483647r,):1r})
sage: a*a
PolyDict with representation {(-2,): 1}

@williamstein
Copy link
Contributor

Attachment: trac_6428.patch.gz

@sagetrac-broune
Copy link
Mannequin Author

sagetrac-broune mannequin commented Jan 18, 2010

comment:6

This patch simply reports an error if this happens. I thought the polydict ring was supposed to allow arbitrary precision exponents.

@williamstein
Copy link
Contributor

comment:7

This patch simply reports an error if this happens. I thought the polydict
ring was supposed to allow arbitrary precision exponents.

Since in the entire Cython implementation of polydict, the exponents are represented internally as C ints there is no way it is supposed to represent arbitrary precision exponents. One could write something that does arbitrary exponents, but that ETuple stuff simply isn't such a thing.

@williamstein
Copy link
Contributor

comment:8

By the way, for basic arithmetic, the symbolic ring supports arbitrary exponents.

sage: var('y')
y
sage: y^(2^32)
y^4294967296
sage: y^(2^50)
y^1125899906842624
sage: y^(2^50+y)
y^(y + 1125899906842624)

@wjp
Copy link
Mannequin

wjp mannequin commented Jan 21, 2010

comment:9

Attachment: 6428_ETuple_overflow.patch.gz

I added a new patch (to be applied instead of the old one) that also handles negative exponents. (The previous patch broke LaurentPolynomials).

@wjp wjp mannequin modified the milestones: sage-4.3.1, sage-4.3.2 Jan 21, 2010
@sagetrac-spancratz
Copy link
Mannequin

sagetrac-spancratz mannequin commented Jan 21, 2010

comment:10

This now passes all doctests.

@sagetrac-spancratz
Copy link
Mannequin

sagetrac-spancratz mannequin commented Jan 21, 2010

Author: wjp

@sagetrac-spancratz
Copy link
Mannequin

sagetrac-spancratz mannequin commented Jan 21, 2010

Reviewer: spancratz

@wjp
Copy link
Mannequin

wjp mannequin commented Jan 21, 2010

Changed author from wjp to Willem Jan Palenstijn

@wjp
Copy link
Mannequin

wjp mannequin commented Jan 21, 2010

Changed reviewer from spancratz to Sebastian Pancratz

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jan 23, 2010

comment:14

Merged 6428_ETuple_overflow.patch.

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jan 23, 2010

Merged: sage-4.3.2.alpha0

@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Jan 23, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants