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

IntegerMod sqrt() doesn't work for non-prime moduli #268

Closed
sagetrac-dmharvey mannequin opened this issue Feb 17, 2007 · 1 comment
Closed

IntegerMod sqrt() doesn't work for non-prime moduli #268

sagetrac-dmharvey mannequin opened this issue Feb 17, 2007 · 1 comment

Comments

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Feb 17, 2007

This one's tricky; not sure the best way to proceed. The problem is that IntegerMod's sqrt() function uses PARI for the underlying functionality, but PARI doesn't work when the modulus is not a prime, even though you would hope it still works when the modulus is a prime power.

Relevant reading is the sqrt function at

http://www.skalatan.de/pariguide/doc/Transcendental_functions.html#sqrt

e.g. some weirdness:

sage: Mod(4, 5).sqrt()
 2

sage: Mod(4, 25).sqrt()
...
<type 'exceptions.ValueError'>: self must be a square.

sage: pari(Mod(4, 25)).sqrt()
...
<class 'gen.PariError'>:  (8)

sage: pari(Mod(4, 125)).sqrt()
...
<class 'gen.PariError'>: non quadratic residue in gsqrt (51)

It would be possible I guess to cast to a pari p-adic, but that would involve testing the modulus of the ring for being a prime power on every sqrt() invocation... seems horribly inefficient.

Component: basic arithmetic

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

@williamstein
Copy link
Contributor

comment:1

It works now in age-2.8.1.

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

1 participant