Skip to content

feat: [AI] add polynomial algebra (factor / sqrfree / discriminant / resultant)#1843

Draft
s-celles wants to merge 1 commit into
JuliaSymbolics:masterfrom
s-celles:001-poly-factor-resultant
Draft

feat: [AI] add polynomial algebra (factor / sqrfree / discriminant / resultant)#1843
s-celles wants to merge 1 commit into
JuliaSymbolics:masterfrom
s-celles:001-poly-factor-resultant

Conversation

@s-celles
Copy link
Copy Markdown

@s-celles s-celles commented Apr 21, 2026

Adds four user-facing primitives for univariate polynomial algebra over ℚ (or with symbolic coefficients treated as transcendentals):

  • resultant(f, g, var; algorithm = :euclid | :sylvester) — single entry point exposing both the extended-Euclidean PRS and the Sylvester-matrix determinant; the two algorithms are guaranteed to agree on every valid input.
  • discriminant(f, var) — derived via the classical identity (-1)^(n*(n-1)/2) * Res(f, f') / lc(f). disc(a*x + b) = 1, disc(c) = 0.
  • sqrfree(f, var) — Yun's square-free decomposition in characteristic 0; returns (unit, Vector{(Num, Int)}) satisfying unit * prod(p_i^e_i) == f.
  • Symbolics.factor(f, var) — rational factorisation. Not exported to avoid shadowing Base.factor / Primes.factor. Pure-Julia pipeline handles content + square-free + rational-roots; a new _factor_with_nemo extension hook in SymbolicsNemoExt delegates higher-degree residuals to Nemo.factor when Nemo is loaded, producing the full ℚ-irreducible decomposition.

Tidies SymbolicsNemoExt.nemo_crude_evaluate with explicit dispatches for Nemo.QQFieldElem and Nemo.ZZRingElem so integer-valued coefficients render as plain Int/BigInt rather than n//1. The existing Symbolics.factor_use_nemo (used by the solver) is untouched at the call-site level and gains the same cosmetic cleanup.

Documentation: new manual page docs/src/manual/polynomial_algebra.md registered in docs/make.jl under the Algebra group.

Testing: 86 polynomial-algebra tests pass without Nemo, 102 with Nemo loaded (16 additional Nemo-oracle tests guarded by the extension).

Version bump to 7.20.0 (MINOR — purely additive).

Be aware it's AI generated code from Claude Opus 4.7 ... it may be imperfect.
And is given as a draft for future work.

May help #59

Free to maintainers to edit.

…resultant)

Adds four user-facing primitives for univariate polynomial algebra over ℚ
(or with symbolic coefficients treated as transcendentals):

- `resultant(f, g, var; algorithm = :euclid | :sylvester)` — single entry
  point exposing both the extended-Euclidean PRS and the Sylvester-matrix
  determinant; the two algorithms are guaranteed to agree on every
  valid input.
- `discriminant(f, var)` — derived via the classical identity
  `(-1)^(n*(n-1)/2) * Res(f, f') / lc(f)`. `disc(a*x + b) = 1`,
  `disc(c) = 0`.
- `sqrfree(f, var)` — Yun's square-free decomposition in
  characteristic 0; returns `(unit, Vector{(Num, Int)})` satisfying
  `unit * prod(p_i^e_i) == f`.
- `Symbolics.factor(f, var)` — rational factorisation. Not exported to
  avoid shadowing `Base.factor` / `Primes.factor`. Pure-Julia pipeline
  handles content + square-free + rational-roots; a new
  `_factor_with_nemo` extension hook in `SymbolicsNemoExt` delegates
  higher-degree residuals to `Nemo.factor` when Nemo is loaded,
  producing the full ℚ-irreducible decomposition.

Tidies `SymbolicsNemoExt.nemo_crude_evaluate` with explicit dispatches
for `Nemo.QQFieldElem` and `Nemo.ZZRingElem` so integer-valued
coefficients render as plain `Int`/`BigInt` rather than `n//1`. The
existing `Symbolics.factor_use_nemo` (used by the solver) is untouched
at the call-site level and gains the same cosmetic cleanup.

Documentation: new manual page `docs/src/manual/polynomial_algebra.md`
registered in `docs/make.jl` under the Algebra group.

Testing: 86 polynomial-algebra tests pass without Nemo, 102 with Nemo
loaded (16 additional Nemo-oracle tests guarded by the extension).

Version bump to 7.20.0 (MINOR — purely additive).
@s-celles s-celles marked this pull request as draft April 21, 2026 17:39
@s-celles s-celles changed the title feat: [AI] add polynomial algebra (factor / sqrfree / discriminant / resultant feat: [AI] add polynomial algebra (factor / sqrfree / discriminant / resultant) Apr 21, 2026
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.

1 participant