Skip to content

Conversation

@fingolfin
Copy link
Member

Without this, we get in Nemo:

julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
(true, 4*x)

With it, the correct result is produced:

julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
(true, 2*x)

Motivated by #2051 which also contains some tests for this, which requires implementing factorization for some rings in AA... I did not want to go to these lengths, so i run the above and a couple other tests in Nemo... That is:

ZZx, x = ZZ[:x]
#QQx, x = QQ[:x]

@test is_power(x, 2) == (false, x)
@test is_power(x, 3) == (false, x)
@test is_power(x^2, 2) == (true, x)
@test is_power(3 * x^2, 2) == (false, 3 * x^2)
@test is_power(2^2 * x^2, 2) == (true, 2 * x)
@test is_power(2^3 * x^3, 3) == (true, 2 * x)
@test is_power(3^4 * x^4, 2) == (true, 9 * x^2)
@test is_power(-3^4 * x^4, 2) == (false, -81 * x^4)
@test is_power(-3^3 * x^3, 3) == (true, -3 * x)
@test is_power(3^2 * (x + 1)^2 * x^2, 2) == (true, 3 * (x + 1) * x)
@test is_power(-3^2 * (x + 1)^2 * x^2, 2) == (false, -3^2 * (x + 1)^2 * x^2)

Once with the ring over ZZ and once with the one over QQ.

Without this, we get in Nemo:

    julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
    (true, 4*x)

With it, the correct result is produced:

    julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
    (true, 2*x)
@fingolfin fingolfin changed the title Fix is_power for e.g. ZZPolyRing Fix is_power for e.g. ZZPolyRing Dec 10, 2025
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.00%. Comparing base (bee81db) to head (aed9edf).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
src/generic/Misc/Poly.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2241   +/-   ##
=======================================
  Coverage   88.00%   88.00%           
=======================================
  Files         127      127           
  Lines       31803    31803           
=======================================
  Hits        27989    27989           
  Misses       3814     3814           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@SoongNoonien SoongNoonien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fingolfin and I talked about this and this should be correct now.

@fingolfin fingolfin merged commit 86dbbb3 into master Dec 12, 2025
25 of 27 checks passed
@fingolfin fingolfin deleted the mh/fix-is_power branch December 12, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants