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

py3: hash collisions of Laurent polynomials #27914

Closed
mwageringel opened this issue Jun 1, 2019 · 7 comments
Closed

py3: hash collisions of Laurent polynomials #27914

mwageringel opened this issue Jun 1, 2019 · 7 comments

Comments

@mwageringel
Copy link

This ticket adjusts the hash of multivariate Laurent polynomials, so that it agrees with the hash of univariate Laurent polynomials.

This solves the following problem: Using Python 3, this doctest in laurent_polynomial.pyx fails about 1 out of 4 times.

            sage: L.<w,z> = LaurentPolynomialRing(QQ)
            sage: len({hash(w^i*z^j) for i in [-2..2] for j in [-2..2]})
            25

Due to hash collisions, the result can be smaller than 25 (such as 23 or 21). This gets even worse when using a larger range of monomials.

Regardless of that, it is desirable that univariate and multivariate Laurent polynomials have the same hash anyway. The univariate hash implementation does not seem to have these collisions, so adopting that implementation solves this problem.

For reference, the univariate and multivariate hashes were implemented in #21272 and #23864.

Component: python3

Author: Markus Wageringel

Branch/Commit: 26eb5fd

Reviewer: Frédéric Chapoton

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

@mwageringel mwageringel added this to the sage-8.8 milestone Jun 1, 2019
@mwageringel
Copy link
Author

Branch: u/gh-mwageringel/py3_hash_laurent

@mwageringel
Copy link
Author

Author: Markus Wageringel

@mwageringel
Copy link
Author

New commits:

26eb5fdTrac #27914. py3: fix hash of multivariate Laurent polynomials

@mwageringel
Copy link
Author

Commit: 26eb5fd

@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

@fchapoton
Copy link
Contributor

comment:2

ok, let it be

@vbraun
Copy link
Member

vbraun commented Jun 5, 2019

Changed branch from u/gh-mwageringel/py3_hash_laurent to 26eb5fd

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

3 participants