API reference

Root results and refinement

Root search starts in poly.dense or poly.sparse. Use poly.roots to inspect, verify, and refine the returned evidence.

Every computational operation has a shared Budget overload and a convenience overload with max_steps=. Borrowed evidence is immutable; call .copy() on it when you need independent mutable data for a core checker or serialization.

ExactRoots

@fieldwise_init
struct ExactRoots(_Archive, Copyable, Movable, Iterable, Sized)

All distinct real roots in increasing order, with completeness evidence.

Indexing and iteration return exact Real values. A repeated root appears once. Copies share both the values and the immutable certificate.

Defined in src/poly/roots.mojo.

ExactRoots.IteratorType

comptime IteratorType[iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]]: Iterator = _ExactIterator[ImmOrigin(iterable_origin)]

A borrowing iterator over exact root values.

Parameters.

  • iterable_mut: Whether the source origin permits mutation.
  • iterable_origin: The source lifetime.

ExactRoots.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].proof))] AlgebraicRootsCertificate

Borrow the complete root certificate.

Returns. Immutable completeness, selection, and evaluation evidence.

ComplexRoots

@fieldwise_init
struct ComplexRoots(_Archive, Copyable, Movable, Iterable, Sized)

All distinct exact complex roots, with multiplicities and completeness evidence.

Indexing and iteration return algebraic.Complex values. Copies share the immutable source and certificate. Constants yield an empty result.

Defined in src/poly/_complex_roots.mojo.

ComplexRoots.IteratorType

comptime IteratorType[iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]]: Iterator = _Iterator[ImmOrigin(iterable_origin)]

A borrowing iterator over exact root values.

Parameters.

  • iterable_mut: Whether the source origin permits mutation.
  • iterable_origin: The source lifetime.

ComplexRoots.multiplicity

def multiplicity(self, index: Int) -> Int

Return the multiplicity of the root at a valid index.

Arguments.

  • index: The root's zero-based position.

Returns. A positive algebraic multiplicity.

ComplexRoots.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].proof))] ComplexRootsCertificate

Borrow the immutable roots and multiplicities certificate.

Returns. Evidence verified by roots.check or roots.check_complex.

ComplexRootsCertificate

@fieldwise_init
struct ComplexRootsCertificate(Copyable, Movable)

Exact root witnesses and positive multiplicities for full reconstruction.

Defined in src/poly/_complex_roots.mojo.

Field Type
roots List[Complex] Distinct roots in lexicographic order of real and imaginary components.
multiplicities List[Int] One positive multiplicity per root; their sum is the source degree.

check_complex

def check_complex[I: Iterable](values: I, certificate: ComplexRootsCertificate, mut budget: Budget) raises PolyError -> Bool

Check independently supplied exact complex-root evidence.

Parameters.

  • I: The inferred dense coefficient iterable type.

Arguments.

  • values: The original ascending exact coefficients or dense array.
  • certificate: Component witnesses and claimed root multiplicities.
  • budget: The shared preparation and verification allowance.

Returns. Whether the certificate gives all roots with their exact multiplicities. A certificate for the zero polynomial is always rejected.

Raises.

  • PolyError: DOMAIN for malformed input, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

RootCount

@fieldwise_init
struct RootCount(_Archive, Copyable, Movable)

A distinct-root count and its independently checkable Descartes evidence.

Defined in src/poly/roots.mojo.

RootCount.count

def count(self) -> Int

Return the number of distinct roots in the requested open interval.

Returns. The certified distinct-root count.

RootCount.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].proof))] DescartesCountCertificate

Borrow the root-count certificate.

Returns. Immutable endpoints, count, and the complete Descartes isolation behind it.

AlgebraicCount

@fieldwise_init
struct AlgebraicCount(_Archive, Copyable, Movable)

An open-interval count retaining all real roots and exact endpoints.

Defined in src/poly/roots.mojo.

AlgebraicCount.count

def count(self) -> Int

Return the distinct-root count.

Returns. The number of roots strictly between the retained endpoints.

AlgebraicCount.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._roots._data[].proof))] AlgebraicRootsCertificate

Borrow the complete real-root evidence.

Returns. The certificate used to establish the interval count.

check

def check(result: ExactRoots, mut budget: Budget) raises PolyError -> Bool

Verify that the result contains exactly all distinct real roots.

Arguments.

  • result: An exact-root result.
  • budget: The shared work allowance for preparation and computation.

Returns. Whether the complete root certificate is valid.

Raises.

  • PolyError: DOMAIN for incompatible input, UNSUPPORTED for an unavailable operation, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

RealCover

@fieldwise_init
struct RealCover[k: Int](_Archive, Copyable, Movable)

A real root cover retaining its polynomial, options, and certificate.

Parameters.

  • k: The inferred exact coefficient kind.

Defined in src/poly/roots.mojo.

RealCover.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].proof))] DescartesRootResult

Borrow the full Descartes evidence, including unresolved leaves.

Returns. The immutable core real-root result and certificate.

RealCover.options

def options(self) -> NumericOptions

Return the precision and accuracy settings that define the claim.

Returns. An independent copy of the retained options.

RealCover.complete

def complete(self) -> Bool

Report whether all roots are accounted for.

Returns. The retained claim or numerical outcome.

RealCover.accurate

def accurate(self) -> Bool

Report whether counted regions meet the requested width.

Returns. The retained claim or numerical outcome.

RealCover.isolated

def isolated(self) -> Bool

Report whether each counted region has count one.

Returns. The retained claim or numerical outcome.

RealCover.outcome

def outcome(self) -> NumericOutcome

Report whether the requested claims succeeded or why they remain unresolved.

Returns. The retained claim or numerical outcome.

refine

def refine[k: Int](result: RealCover[k], options: NumericOptions, mut budget: Budget, *, complete_only: Bool = False) raises PolyError -> RealCover[k]

Refine a real cover while preserving the previous result.

Parameters.

  • k: The inferred coefficient kind.

Arguments.

  • result: The previous cover, including its original options.
  • options: The new accuracy, precision, and subdivision settings.
  • budget: The shared work allowance for preparation and computation.
  • complete_only: Raise unless every requested property succeeds.

Returns. The computed result, with its evidence retained.

Raises.

  • PolyError: DOMAIN for incompatible input, UNSUPPORTED for an unavailable operation, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

ComplexCover

@fieldwise_init
struct ComplexCover[k: Int](_Archive, Copyable, Movable)

A complex root cover retaining its polynomial, options, and certificate.

Parameters.

  • k: The inferred exact coefficient kind.

Defined in src/poly/roots.mojo.

ComplexCover.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].proof))] ComplexRootResult

Borrow the full cover evidence, including unresolved regions.

Returns. The immutable core root-cover certificate.

ComplexCover.options

def options(self) -> NumericOptions

Return the precision and accuracy settings that define the claim.

Returns. An independent copy of the retained options.

ComplexCover.complete

def complete(self) -> Bool

Report whether all roots are accounted for.

Returns. The retained claim or numerical outcome.

ComplexCover.accurate

def accurate(self) -> Bool

Report whether counted regions meet the requested width.

Returns. The retained claim or numerical outcome.

ComplexCover.isolated

def isolated(self) -> Bool

Report whether each counted region has count one.

Returns. The retained claim or numerical outcome.

ComplexCover.outcome

def outcome(self) -> NumericOutcome

Report whether the requested claims succeeded or why they remain unresolved.

Returns. The retained claim or numerical outcome.

intervals

def intervals[k: Int](result: RealCover[k], mut budget: Budget) raises PolyError -> List[Tuple[Rational, Rational, Int]]

Extract real intervals while keeping root counts explicit.

Parameters.

  • k: The inferred coefficient kind.

Arguments.

  • result: A real cover; inspect complete and accurate before using it.
  • budget: The shared work allowance for preparation and computation.

Returns. (low, high, 1) for each distinct root in increasing order: an open interval containing it, or low == high for an exact rational root. Unresolved pieces appear as (low, high, -1).

Raises.

  • PolyError: DOMAIN for incompatible input, UNSUPPORTED for an unavailable operation, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

rectangles

def rectangles[k: Int](result: ComplexCover[k], mut budget: Budget) raises PolyError -> List[Tuple[Rational, Rational, Rational, Rational, Int]]

Extract complex rectangles with counts including multiplicity.

Parameters.

  • k: The inferred coefficient kind.

Arguments.

  • result: A complex cover; inspect its completeness and accuracy.
  • budget: The shared work allowance for preparation and computation.

Returns. (real low, real high, imaginary low, imaginary high, count) tuples.

Raises.

  • PolyError: DOMAIN for incompatible input, UNSUPPORTED for an unavailable operation, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

NumericCover

@fieldwise_init
struct NumericCover[D: NumericDomain, complex: Bool](_Archive, Copyable, Movable)

A validated numerical root cover, including unresolved cells and accuracy status.

Parameters.

  • D: The APN numerical domain associated with the stored scalars.
  • complex: Whether this cover uses complex rectangles rather than real intervals.

Defined in src/poly/roots.mojo.

NumericCover.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._proof[]))] _NumericProof[Self.complex]

Borrow the full cover, including exclusions and unresolved regions.

Returns. An immutable reference to the retained core evidence.

NumericCover.options

def options(self) -> NumericOptions

Copy the requested precision, accuracy and subdivision settings.

Returns. A copy of the retained numerical requirements.

NumericCover.complete

def complete(self) -> Bool

Report whether all roots are accounted for.

Returns. Whether all roots are accounted for.

NumericCover.accurate

def accurate(self) -> Bool

Report whether counted regions meet the requested width.

Returns. Whether counted regions meet the requested width.

NumericCover.isolated

def isolated(self) -> Bool

Report whether every counted region isolates one root.

Returns. Whether every counted region contains one root.

NumericCover.outcome

def outcome(self) -> NumericOutcome

Report the requested numerical guarantee or unresolved outcome.

Returns. The retained numerical outcome.

Multiplicities

@fieldwise_init
struct Multiplicities[k: Int](_Archive, Copyable, Movable)

Exact multiplicities aligned with the root intervals of a real root cover.

Parameters.

  • k: The inferred exact coefficient kind.

Defined in src/poly/roots.mojo.

Multiplicities.counts

def counts(self) -> Values[Int, 0]

Return shared multiplicities in the same order as roots.intervals.

Returns. Multiplicities aligned with the intervals returned by roots.intervals.

Multiplicities.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._proof[]))] RootMultiplicityCertificate

Borrow the squarefree decomposition and the block of each root.

Returns. An immutable reference to the retained core evidence.

multiplicities

def multiplicities[k: Int](cover: RealCover[k], mut budget: Budget) raises PolyError -> Multiplicities[k]

Attach exact multiplicities to a complete isolated real root cover.

Parameters.

  • k: The inferred exact coefficient kind.

Arguments.

  • cover: A complete real root cover isolating each distinct root.
  • budget: The shared work allowance, including preparation, computation, and result storage.

Returns. A result retaining the exact multiplicity counts and their witnesses.

Raises.

  • PolyError: DOMAIN for invalid or incompatible input, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

Diagnostics

@fieldwise_init
struct Diagnostics[P: Iterable & Copyable & Deinitable](_Archive, Copyable, Movable)

Residual and local sensitivity bounds retaining the polynomial and test point.

Parameters.

  • P: The sparse power shape or retained source array type, inferred from the input.

Defined in src/poly/roots.mojo.

Diagnostics.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._proof[]))] RootDiagnostics

Borrow residual, derivative, backward-error and sensitivity bounds.

Returns. An immutable reference to the retained core evidence.

diagnostics

def diagnostics[I: Iterable, X: Copyable & Deinitable](values: I, point: X, mut budget: Budget, *, context: Optional[BallContext] = None) raises PolyError -> Diagnostics[_dense.Array[_Kind[_Element[I]]]] where _Kind[_Element[I]] >= 0

Bound the residual, coefficient backward error and local sensitivity at a point.

Parameters.

  • I: The inferred input iterable type.
  • X: The evaluation point or seed type.

Arguments.

  • values: Input coefficients, sparse terms, or prepared values as required by this overload.
  • point: The evaluation scalar or ordered coordinate tuple.
  • budget: The shared work allowance, including preparation, computation, and result storage.
  • context: Explicit ball precision for algebraic coefficients; unused for rational coefficients.

Returns. Residual, derivative, backward-error, and local sensitivity evidence, with the source and point retained.

Raises.

  • PolyError: DOMAIN for invalid or incompatible input, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

Polished

@fieldwise_init
struct Polished[P: Iterable & Copyable & Deinitable](_Archive, Copyable, Movable)

A Newton candidate with a one-root enclosure when independent validation succeeds.

Parameters.

  • P: The sparse power shape or retained source array type, inferred from the input.

Defined in src/poly/roots.mojo.

Polished.candidate

def candidate(self) -> Complex

Copy the advisory complex approximation.

Returns. The advisory complex approximation.

Polished.outcome

def outcome(self) -> NumericOutcome

Report the validation and requested-width outcome.

Returns. The retained numerical outcome.

Polished.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._proof[]))] PolishedRootResult

Borrow the Newton candidate and optional contour certificate.

Returns. An immutable reference to the retained core evidence.

polish

def polish[I: Iterable, X: Copyable & Deinitable](values: I, seed: X, mut budget: Budget, *, context: ComplexContext, radius: Rational, iterations: Int = 8, options: NumericOptions = NumericOptions()) raises PolyError -> Polished[_dense.Array[_Kind[_Element[I]]]] where _Kind[_Element[I]] >= 0

Polish a candidate with explicit precision and attempt a one-root contour proof.

Parameters.

  • I: The inferred input iterable type.
  • X: The evaluation point or seed type.

Arguments.

  • values: Input coefficients, sparse terms, or prepared values as required by this overload.
  • seed: A finite scalar starting point for advisory Newton iteration.
  • budget: The shared work allowance, including preparation, computation, and result storage.
  • context: Explicit output precision, rounding settings, or ball working precision.
  • radius: A positive exact radius for the final validation rectangle.
  • iterations: The nonnegative Newton iteration limit; defaults to eight.
  • options: Precision, accuracy, isolation, and subdivision requirements.

Returns. An advisory Newton candidate and optional independent one-root certificate.

Raises.

  • PolyError: DOMAIN for invalid or incompatible input, or LIMIT/CAPACITY on resource limits.

Defined in src/poly/roots.mojo.

SpecializedRoots

@fieldwise_init
struct SpecializedRoots[P: Copyable & Deinitable, k: Int = 1](_Archive, Copyable, Movable, Iterable, Sized)

All distinct real roots after specialization, retaining both proofs.

Parameters.

  • P: The original sparse power shape.
  • k: The specialization domain; QQ by default, or AA.

Defined in src/poly/roots.mojo.

SpecializedRoots.IteratorType

comptime IteratorType[iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]]: Iterator = _SpecializedIterator[Self.P, Self.k, ImmOrigin(iterable_origin)]

Borrow the sorted exact roots.

Parameters.

  • iterable_mut: Whether the source origin is mutable.
  • iterable_origin: The source origin.

SpecializedRoots.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._roots._data[].proof))] AlgebraicRootsCertificate

Borrow the complete root certificate.

Returns. The elimination, completeness and filtering evidence.

SpecializedRoots.specialization

def specialization(self) -> _Specialization[Self.P, Self.k]

Return the retained specialization with its coefficient evidence.

Returns. A value sharing the immutable specialization.

Interval queries accept real algebraic coefficients and endpoints. For AA or QQbar coefficients, roots.diagnostics requires context=BallContext(...); roots.polish uses its explicit complex context. Both retain and check the coefficient-conversion witnesses.

A real cover of integer or rational coefficients carries a DescartesRootResult as its evidence: roots.check verifies its certificate, roots.refine tightens its brackets without searching again, and roots.intervals lists one interval per root, with exact rational roots as points. Its streams go to a DescartesRootSink, such as the checker real_root_checker returns for integer or rational input.

Use poly.io to archive complete root results, accepted covers, multiplicities, diagnostics, and successful polishing evidence. An incomplete cover or an unverified polishing result is rejected by the archive writer and reader.

Algebraic covers bind the numerical regions to their exact AA or QQbar coefficients. Conversion uses max_precision; refinement encloses the original coefficients again under the new options. Streaming checkers prepare and verify the same coefficient family without retaining completed local proofs.

AlgebraicCover

@fieldwise_init
struct AlgebraicCover[k: Int, z: Bool](_Archive, Copyable, Movable)

A numerical cover bound to exact algebraic coefficients and conversion witnesses.

Parameters.

  • k: The inferred exact algebraic coefficient kind.
  • z: Whether the cover contains complex rectangles.

Defined in src/poly/_algebraic_covers.mojo.

AlgebraicCover.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._proof[]))] _Proof[Self.z]

Borrow the cover certificate, including unresolved regions.

Returns. The immutable numerical root evidence.

AlgebraicCover.options

def options(self) -> NumericOptions

Copy the requested numerical guarantees.

Returns. The retained precision and root-cover options.

AlgebraicCover.complete

def complete(self) -> Bool

Report whether all roots are accounted for.

Returns. The retained claim.

AlgebraicCover.accurate

def accurate(self) -> Bool

Report whether regions meet the requested width.

Returns. The retained claim.

AlgebraicCover.isolated

def isolated(self) -> Bool

Report whether every counted region has count one.

Returns. The retained claim.

AlgebraicCover.outcome

def outcome(self) -> NumericOutcome

Report whether the requested guarantees succeeded.

Returns. The retained numerical outcome.

AlgebraicRealRootChecker

@fieldwise_init
struct AlgebraicRealRootChecker[k: Int](RealRootSink, Movable)

Check a numerical root stream against exact algebraic coefficients.

Parameters.

  • k: The inferred exact algebraic coefficient kind.

Defined in src/poly/_algebraic_covers.mojo.

AlgebraicRealRootChecker.begin

def begin(mut self, sequence: Optional[SturmSequence], mut budget: Budget) raises PolyError

Accept the shared real-root stream header.

Arguments.

  • sequence: The optional rational Sturm witness.
  • budget: The shared checking allowance.

Raises.

  • PolyError: DOMAIN on invalid headers, or LIMIT/CAPACITY.

AlgebraicRealRootChecker.accept

def accept(mut self, var witness: RealRootCell, mut budget: Budget) raises PolyError -> Bool

Check and consume the next local root witness.

Arguments.

  • witness: The next owned numerical root certificate.
  • budget: The shared checking allowance.

Returns. Whether the witness is valid; rejection invalidates the checker.

Raises.

  • PolyError: DOMAIN on invalid evidence, or LIMIT/CAPACITY on resource limits.

AlgebraicRealRootChecker.write

def write(mut self, var witness: RealRootCell, mut budget: Budget) raises PolyError

Check and consume the next local root witness.

Arguments.

  • witness: The next owned numerical root certificate.
  • budget: The shared checking allowance.

Raises.

  • PolyError: DOMAIN on invalid evidence, or LIMIT/CAPACITY on resource limits.

AlgebraicRealRootChecker.finish

def finish(self, receipt: RootStreamReceipt, mut budget: Budget) raises PolyError -> Bool

Verify conversion, coverage, and the producer's completion claims.

Arguments.

  • receipt: The final receipt after all local witnesses.
  • budget: The shared final checking allowance.

Returns. Whether the complete stream certifies the retained algebraic input.

Raises.

  • PolyError: DOMAIN on invalid input, or LIMIT/CAPACITY on resource limits.

AlgebraicComplexRootChecker

@fieldwise_init
struct AlgebraicComplexRootChecker[k: Int](ComplexRootSink, Movable)

Check a numerical root stream against exact algebraic coefficients.

Parameters.

  • k: The inferred exact algebraic coefficient kind.

Defined in src/poly/_algebraic_covers.mojo.

AlgebraicComplexRootChecker.accept

def accept(mut self, var witness: ComplexRootRegion, mut budget: Budget) raises PolyError -> Bool

Check and consume the next local root witness.

Arguments.

  • witness: The next owned numerical root certificate.
  • budget: The shared checking allowance.

Returns. Whether the witness is valid; rejection invalidates the checker.

Raises.

  • PolyError: DOMAIN on invalid evidence, or LIMIT/CAPACITY on resource limits.

AlgebraicComplexRootChecker.write

def write(mut self, var witness: ComplexRootRegion, mut budget: Budget) raises PolyError

Check and consume the next local root witness.

Arguments.

  • witness: The next owned numerical root certificate.
  • budget: The shared checking allowance.

Raises.

  • PolyError: DOMAIN on invalid evidence, or LIMIT/CAPACITY on resource limits.

AlgebraicComplexRootChecker.finish

def finish(self, receipt: RootStreamReceipt, mut budget: Budget) raises PolyError -> Bool

Verify conversion, coverage, and the producer's completion claims.

Arguments.

  • receipt: The final receipt after all local witnesses.
  • budget: The shared final checking allowance.

Returns. Whether the complete stream certifies the retained algebraic input.

Raises.

  • PolyError: DOMAIN on invalid input, or LIMIT/CAPACITY on resource limits.

ExactComplexRootEvent

@fieldwise_init
struct ExactComplexRootEvent(Copyable, Movable)

One distinct exact root and its positive multiplicity.

Defined in src/poly/_complex_roots.mojo.

Field Type
value Complex The exact complex root, with component witnesses.
multiplicity Int The root's algebraic multiplicity.

ExactComplexRootReceipt

@fieldwise_init
struct ExactComplexRootReceipt(Copyable, Movable)

Completion metadata; accept only after checking every root event.

Defined in src/poly/_complex_roots.mojo.

Field Type
items Int The number of distinct roots emitted.
degree Int The sum of the emitted multiplicities.

ExactComplexRootSink

trait ExactComplexRootSink(Movable)

Consume exact root events under the caller's shared work allowance.

Defined in src/poly/_complex_roots.mojo.

ExactComplexRootSink.write

def write(mut self, var event: ExactComplexRootEvent, mut budget: Budget) raises PolyError

Consume one owned root witness.

Arguments.

  • event: The exact root and its positive multiplicity.
  • budget: The shared production and consumption allowance.

Raises.

  • PolyError: Consumer failures, including LIMIT or CAPACITY.

ExactComplexRootChecker

@fieldwise_init
struct ExactComplexRootChecker(ExactComplexRootSink, Movable)

Check roots incrementally through exact factor reconstruction.

Completed root witnesses are discarded. The checker retains the original polynomial and a growing product, so its storage still depends on degree.

Defined in src/poly/_complex_roots.mojo.

ExactComplexRootChecker.accept

def accept(mut self, var event: ExactComplexRootEvent, mut budget: Budget) raises PolyError -> Bool

Validate and consume one distinct root; rejection invalidates the checker.

Arguments.

  • event: The exact root and its positive multiplicity.
  • budget: The shared validation allowance.

Returns. Whether the event is valid and the partial reconstruction remains sound.

Raises.

  • PolyError: LIMIT or CAPACITY on resource limits; failure invalidates the checker.

ExactComplexRootChecker.write

def write(mut self, var event: ExactComplexRootEvent, mut budget: Budget) raises PolyError

Check an event directly as a producer sink.

Arguments.

  • event: The next owned root witness.
  • budget: The shared allowance.

Raises.

  • PolyError: DOMAIN on rejected evidence, or LIMIT/CAPACITY on resource limits.

ExactComplexRootChecker.finish

def finish(self, receipt: ExactComplexRootReceipt, mut budget: Budget) raises PolyError -> Bool

Verify complete reconstruction and the final event counts.

Arguments.

  • receipt: Metadata returned after successful production.
  • budget: The shared final checking allowance.

Returns. Whether every root is accounted for with its exact multiplicity.

Raises.

  • PolyError: LIMIT or CAPACITY on resource limits.

Prepared Sturm queries

Build a rational plan with dense.sturm_sequence or sparse.sturm_sequence. Repeated counts share its chain, while check verifies the source binding, quotient identities, and endpoint variations. See reusable Sturm chains for a worked example.

SturmPlan

@fieldwise_init
struct SturmPlan(_Archive, Copyable, Movable, Sized)

An immutable rational Sturm chain shared by repeated interval queries.

Construct with dense.sturm_sequence or sparse.sturm_sequence. Integer coefficients promote to QQ. The zero polynomial has no finite root count.

Defined in src/poly/_sturm.mojo.

SturmPlan.evidence

def evidence(self) -> ref[ImmOrigin(origin_of(self._data[].sequence))] SturmSequence

Borrow the recurrence and quotient witnesses.

Returns. The immutable core Sturm certificate.

SturmCount

@fieldwise_init
struct SturmCount(_Archive, Copyable, Movable)

An open-interval root count sharing its prepared Sturm evidence.

Defined in src/poly/_sturm.mojo.

SturmCount.count

def count(self) -> Int

Return the claimed number of distinct roots.

Returns. The root count, excluding multiplicity and interval endpoints.

SturmCount.plan

def plan(self) -> SturmPlan

Return the shared immutable chain used for this query.

Returns. The prepared Sturm plan without copying polynomial buffers.

sign_changes

def sign_changes[T: Copyable & Deinitable](plan: SturmPlan, point: T, mut budget: Budget) raises PolyError -> Int

Count sign variations at an integer or rational point, omitting zeros.

Parameters.

  • T: The integer or rational point type.

Arguments.

  • plan: The immutable prepared Sturm chain.
  • point: An integer or rational; roots of chain members are allowed.
  • budget: The shared work allowance.

Returns. The number of adjacent opposite nonzero signs.

Raises.

  • PolyError: DOMAIN for invalid inputs, or LIMIT/CAPACITY.

Defined in src/poly/roots.mojo.

count_roots

def count_roots[A: Copyable & Deinitable, B: Copyable & Deinitable](plan: SturmPlan, low: A, high: B, mut budget: Budget) raises PolyError -> SturmCount

Count distinct roots in an open interval using a prepared Sturm chain.

Parameters.

  • A: The lower endpoint type.
  • B: The upper endpoint type.

Arguments.

  • plan: The immutable prepared Sturm chain.
  • low: The lower integer or rational endpoint; must not be a root.
  • high: The strictly larger nonroot endpoint.
  • budget: The shared work allowance.

Returns. A checked-result object sharing the plan and retaining both endpoints.

Raises.

  • PolyError: DOMAIN for invalid inputs, or LIMIT/CAPACITY.

Defined in src/poly/roots.mojo.

polynomials

def polynomials(plan: SturmPlan, mut budget: Budget) raises PolyError -> List[_dense.Array[1]]

Copy the prepared chain into ordinary rational coefficient arrays.

Arguments.

  • plan: The immutable prepared Sturm chain.
  • budget: The shared work allowance.

Returns. Independent array values in chain order, starting with the input polynomial.

Raises.

  • PolyError: DOMAIN for invalid inputs, or LIMIT/CAPACITY.

Defined in src/poly/roots.mojo.