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

sqrt(Mod(,),all=True) should raise more informative NotImplmentedError #38802

Open
2 tasks done
maxale opened this issue Oct 11, 2024 · 3 comments
Open
2 tasks done

sqrt(Mod(,),all=True) should raise more informative NotImplmentedError #38802

maxale opened this issue Oct 11, 2024 · 3 comments

Comments

@maxale
Copy link
Contributor

maxale commented Oct 11, 2024

Steps To Reproduce

Check this out:

sage: is_square(Mod(2, 101010))
False
sage: sqrt(Mod(2, 101010),all=True)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

Expected Behavior

Sage should simply return [], ie. an empty list of roots (as there are none exist). In fact, a reason (which I believe is tested by is_squre()) is very simple: the modulus 101010 is divisible by 3, while 2 is not a square modulo 3.

Actual Behavior

Raises NotImplemented, while is_square() easily establishes that there are no solutions.

Additional Information

Btw, sqrt(Mod(2, 101010)) (ie. without all=True) returns a weird/incorrect result, which I submit as another issue #38803.

Environment

  • OS: Ubuntu 24.04.1 LTS
  • Sage Version: 10.5.beta6

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@maxale maxale added the t: bug label Oct 11, 2024
@maxale maxale changed the title sqrt(Mod(,),all=True) raises NotImplmentedError in trivial cases with no solutions (should raise ValueError instead) sqrt(Mod(,),all=True) raises NotImplmentedError in trivial cases with no solutions (should simply return []) Oct 11, 2024
@maxale
Copy link
Contributor Author

maxale commented Oct 12, 2024

As suggested in the discussion of #38803, the requested behavior can be obtained with parameter extend=False:

sage: sqrt(Mod(2, 101010),all=True,extend=False)
[]

The question is then whether extend=True should really be the default.

@maxale
Copy link
Contributor Author

maxale commented Oct 12, 2024

While it's NotImplemented, should the error message suggest to use extend=False? Example from polynomial roots:

sage: x = polygen(Zmod(101010))
sage: (x^2 - 2).roots()
[...]
NotImplementedError: root finding with multiplicities for this polynomial not implemented (try the multiplicities=False option)

@yyyyx4 yyyyx4 added c: algebra and removed t: bug labels Oct 12, 2024
@yyyyx4
Copy link
Member

yyyyx4 commented Oct 12, 2024

(I've removed the "bug" label since some part of this is documented behaviour, and the other part is just a lack of functionality, which isn't usually considered a bug.)

@maxale maxale changed the title sqrt(Mod(,),all=True) raises NotImplmentedError in trivial cases with no solutions (should simply return []) sqrt(Mod(,),all=True) should raise more informative NotImplmentedError Oct 16, 2024
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