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

is_square does not work correctly for Laurent polynomials #35860

Closed
2 tasks done
amithazi opened this issue Jun 30, 2023 · 1 comment · Fixed by #35876
Closed
2 tasks done

is_square does not work correctly for Laurent polynomials #35860

amithazi opened this issue Jun 30, 2023 · 1 comment · Fixed by #35876
Assignees
Labels
Milestone

Comments

@amithazi
Copy link

amithazi commented Jun 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: Debian 12.0
- **Sage Version**: 10.0

Steps To Reproduce

The method "is_square" for finding square roots of (Laurent) polynomials has a subtle bug.

sage: R.<v> = LaurentPolynomialRing(ZZ)
sage: x = is_square(v^2, root=True)[1]
sage: x, x + v^-1

Expected Behavior

We expect x, x + v^-1 to evaluate to (v, v^-1 + v).

Actual Behavior

Instead, we get (v, 5*v^-1).

Additional Information

There is similar behavior when the coefficients are rational or real.

The problem seems to be that is_square for polynomial rings does not always coerce square roots into the correct parent. For example,

sage: S.<x> = PolynomialRing(ZZ)
sage: is_square(S(1), True)[1].parent()
Integer Ring

These square roots come from factorizations/squarefree decompositions of the polynomial in which the unit is explicitly declared to be a member of the base ring. If the square root of the unit doesn't get multiplied by anything polynomial, the resulting square root remains in the base ring.

@DaveWitteMorris
Copy link
Member

Thanks for the bug report, and for your diagnosis of the problem, which was very helpful! A fix is in Pull Request #35876.

@mkoeppe mkoeppe added this to the sage-10.1 milestone Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants