pub fn factor_multivariate<O: MonomialOrd>(
f: &MultiPoly<O>,
) -> Option<MultiFactorization<O>>Expand description
Factor a multivariate polynomial over ℤ by Kronecker substitution.
Returns Some((content, factors)) with f = content · ∏ gᵢ^mᵢ, every
gᵢ a primitive integer polynomial with positive leading coefficient
(in the monomial order O), sorted for determinism. Returns None if
the polynomial is too large for the method (see
MAX_KRONECKER_SUBSTITUTION_DEGREE) or if the result could not be
verified — a result is never returned without being multiplied back.
§Algorithm
- Remove rational and monomial content.
- If only one variable remains, factor with
factor_zassenhaus. - Otherwise substitute
xⱼ → t^{Dⱼ}with mixed radicesDⱼ₊₁ = Dⱼ · (deg_{xⱼ} f + 1), which is injective on the monomials off, factor the univariate image, and regroup its irreducible factors (with multiplicity) into subsets whose products map back to genuine divisors off(checked by exact multivariate division). All variable orderings are tried, cheapest first.
§Examples
use symplex::factor_zassenhaus::factor_multivariate;
use symplex::multipoly::MultiPoly;
let [x, y]: [MultiPoly; 2] = [MultiPoly::var(2, 0), MultiPoly::var(2, 1)];
// x³ − y³ = (x − y)(x² + xy + y²)
let f = x.mul(&x).mul(&x).sub(&y.mul(&y).mul(&y));
let (content, factors) = factor_multivariate(&f).unwrap();
assert!(content.is_integer());
assert_eq!(factors.len(), 2);
let mut back = MultiPoly::constant(2, content);
for (g, m) in &factors {
for _ in 0..*m { back = back.mul(g); }
}
assert_eq!(back, f);