Skip to content

Separate complex root enclosures across square-free factors - #440

Draft
Aurantium-47 wants to merge 1 commit into
flintlib:mainfrom
Aurantium-47:fix/disjoint-complex-root-enclosures
Draft

Aurantium-47 wants to merge 1 commit into
flintlib:mainfrom
Aurantium-47:fix/disjoint-complex-root-enclosures

Conversation

@Aurantium-47

Copy link
Copy Markdown

Summary

Address the overlapping-enclosure example in #62 for fmpz_poly.complex_roots, also inherited by fmpq_poly.complex_roots through its integer numerator.

At the default precision, the current implementation returns overlapping balls for distinct roots with different multiplicities:

from flint import fmpz_poly, ctx

ctx.prec = 53
x = fmpz_poly([0, 1])
a = 10**100
roots = ((x - a) * (x - a - 1)**2).complex_roots()
assert not roots[0][0].overlaps(roots[1][0])

The assertion fails on the released baseline and passes with this change. Multiplicities remain 1 and 2, and ctx.prec stays 53.

Approach

Keep FLINT's certified isolation of each exact square-free factor. Check the resulting enclosures against every other factor group, and double the working precision only for groups participating in an overlap. Repeat until the complete root set is pairwise disjoint.

Exact factorization supplies multiplicities; no numerical multiplicity classification is needed. Within-factor isolation plus the exhaustive cross-factor check certifies global separation. Coprime factors have distinct roots with positive separation, so increasing the precision eventually separates their certified enclosures, subject to available resources. Precision overflow is guarded and allocated root/factor objects are cleared on exit.

The existing factor grouping and already-separated outputs are preserved. This avoids multiplying all factors into a radical and solving the larger root problem. The cross-factor check adds pairwise comparisons; this is a correctness change, not a general speedup claim.

This addresses the cross-factor isolation problem, not the broader root-method API and real_roots proposals in #62.

Validation

Native Linux development build with Python 3.12 and FLINT 3.6.0:

  • Full python -m pytest --pyargs flint -q against the local Meson build: 1,099 passed, including doctests; independently rerun with the same result.
  • Project cython-lint src/ and git diff --check: passed.
  • Four regression functions cover exact Gaussian-integer roots with 100-digit centers, near real/nonreal roots, unequal multiplicities, nonmonic dyadic-rational factors, rational content, zero/constants, single-factor cases and irrational roots. They check disjointness, completeness, multiplicity and unchanged precision context.
  • Additional independent native checks passed for 40 exact-factor integer/rational cases at precisions 2, 15, 53, 128 and 300. Exact algebraic oracles are used rather than floating-point reference roots.

No sanitizer or cross-platform run is claimed.

AI assistance was used for investigation, implementation, tests and review. The cross-factor problem and earlier radical-based proposal were identified in the linked maintainer discussion; this change uses adaptive factorwise refinement.

@oscarbenjamin

Copy link
Copy Markdown
Collaborator

Firstly are you a human or are you a bot?

Secondly if you are a human can you write the pull request description like a human. Don't just dump LLM output and expect others to read this. Write all messages as a human or I will not talk to you.

Thirdly the code change is overengineered and not something that we would usually do in python-flint. There will be some simpler/better approach to fixing the problem if someone thinks about it rather than having an LLM spew out code.

This branch has not been deployed

No deployments
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