hex

29.4. Polynomials with algebraic coefficients🔗

An Hex.AlgebraicPoly has canonical algebraic numbers as coefficients; trailing coefficients equal to zero are dropped by value, not by representation. Its roots are lazy roots with multiplicities: the polynomial X² − √2 has the two real fourth roots of 2, each simple, each with minimal polynomial X⁴ − 2.

def quarticRoots : Array RootCount := (AlgebraicPoly.ofArray #[-sqrt2, 0, 1]).roots.toArray #guard quarticRoots.size = 2 #guard quarticRoots.all fun r => r.multiplicity = 1 && r.root.exact.p = #p[-2, 0, 0, 0, 1]

The .all case of a root set is the zero polynomial, every number being a root of it.

🔗def
Hex.AlgebraicPoly.roots (f : Hex.AlgebraicPoly) : Hex.RootSet
Hex.AlgebraicPoly.roots (f : Hex.AlgebraicPoly) : Hex.RootSet

Total roots of a polynomial with canonical algebraic coefficients.