Exact real algebraic numbers¶
For the array workflow, see algebraic coefficients. Values are exact real roots of monic rational polynomials, isolated by Descartes' rule of signs: the polynomial changes sign across the open interval and its Descartes bound there is 1, which also excludes a repeated root inside. Factories choose irreducible definitions, narrowing an interval until the bound certifies it, and represent rationals by a linear polynomial and equal endpoints. Checkers also accept nonminimal definitions whose root in the interval is simple; they do not assert irreducibility. Comparisons prove equality by a common factor with a single sign-changing root, Descartes bound 1, on an interval inside both witnesses.
Arithmetic returns certificates whose value is the answer. Binary operations
retain a resultant ideal identity, a nonzero annihilator, operand refinements,
and a Descartes window selecting the intended conjugate: the annihilator's
only root there is the result's. Unary operations
verify the direct polynomial transformation. Independent checkers use those
identities and interval bounds without factoring, computing gcds or isolating
roots. Negation and inversion pass None as the checker's second operand.
algebraic_sign is a certified comparison against real_rational(0).
algebraic_roots accepts coefficients in ascending degree and returns every
distinct real root. It eliminates independent coefficient variables to obtain
a nonzero rational annihilator, accounts for all its real roots, and
filters each candidate by certified evaluation of the original polynomial.
The annihilator's real roots are counted by an AlgebraicDescartesCertificate,
a complete Descartes isolation that check_algebraic_descartes verifies. With
rational coefficients the annihilator is the polynomial itself, and each
candidate is accepted by its definition dividing it, without evaluation.
Algebraically dependent coefficients are valid. Constants have no roots;
the zero polynomial raises DOMAIN because it has no finite root list.
Sparse evaluation and partial specialization retain a fixed arithmetic
schedule. Specialization keeps even coefficients which become zero so its
checker can verify that none was omitted. algebraic_roots_at specializes all
variables except the designated root variable and checks both specialization
and completeness. A vanished leading coefficient is allowed; an identically
zero specialization raises DOMAIN.
All operations share the supplied budget and leave borrowed inputs unchanged on failure. See the extension mathematics.
"""Construct and independently check exact algebraic arithmetic."""
from std.testing import assert_true
from apn_mojo import Rational
from polynomials import Budget, DensePoly, QQ, NoContext, real_root, algebraic_multiply, check_algebraic_arithmetic
def main() raises:
var budget = Budget()
var f = DensePoly[QQ].from_coefficients(0, NoContext(), [QQ(Rational(-2)), QQ(Rational(0)), QQ(Rational(1))], budget)
var sqrt2 = real_root(f, QQ(Rational(1)), QQ(Rational(2)), budget)
var square = algebraic_multiply(sqrt2, sqrt2, budget)
assert_true(check_algebraic_arithmetic(sqrt2, sqrt2.copy(), square, budget))
assert_true(square.value.rational and square.value.low.value == Rational(2))
print("sqrt(2) squared: 2")
print("Arithmetic certificate checked")
Run from the repository root pixi run mojo run -I build docs/examples/algebraic_numbers.mojo
Output
sqrt(2) squared: 2
Arithmetic certificate checked
AlgebraicArithmeticCertificate¶
@fieldwise_init
struct AlgebraicArithmeticCertificate(Copyable, Movable, Writable)
An arithmetic result proved by elimination and unique-root selection.
Defined in src/polynomials/algebraic_arithmetic.mojo.
| Field | Type | |
|---|---|---|
operation |
Int |
Zero for add, one for subtract, two for multiply, three for negate, four for inverse. |
left |
RealAlgebraic |
A normalized and refined witness for the left operand. |
right |
RealAlgebraic |
A normalized right operand, unused for unary operations. |
left_factor |
DensePoly[QQ] |
Multiplier recovering the original left defining polynomial. |
right_factor |
DensePoly[QQ] |
Multiplier recovering the original right definition, unused for unary operations. |
value |
RealAlgebraic |
The certified arithmetic result. |
annihilator |
DensePoly[QQ] |
A nonzero polynomial vanishing at the intended arithmetic result. |
value_factor |
DensePoly[QQ] |
Multiplier expressing the annihilator as a multiple of the result definition. |
elimination |
Optional[ResultantResult[QQ]] |
The binary elimination identity, absent for direct rational and unary cases. |
selection |
Optional[RootInterval] |
An open window holding the operand-image bounds and the result interval, where the annihilator has a single root. The annihilator is nonzero at its ends; the result's polynomial p changes sign across it with Descartes bound 1; and value_factor with every factor p divided out, q, has Descartes bound 0 on it. |
AlgebraicComparisonCertificate¶
@fieldwise_init
struct AlgebraicComparisonCertificate(Copyable, Movable, Writable)
Interval separation or a shared-root proof of exact comparison.
Defined in src/polynomials/algebraic_types.mojo.
| Field | Type | |
|---|---|---|
relation |
Int |
Negative one, zero, or positive one for the certified comparison. |
left |
RealAlgebraic |
A refined witness for the left operand. |
right |
RealAlgebraic |
A refined witness for the right operand. |
common |
DensePoly[QQ] |
A common factor for irrational equality. |
left_cofactor |
DensePoly[QQ] |
The quotient of the left definition by the common factor. |
right_cofactor |
DensePoly[QQ] |
The quotient of the right definition by the common factor. |
shared |
Optional[RootInterval] |
An open interval inside both refined intervals where the common factor has Descartes bound 1 and changes sign. |
AlgebraicDescartesCertificate¶
@fieldwise_init
struct AlgebraicDescartesCertificate(Copyable, Movable, Writable)
A complete Descartes isolation of every distinct real root of a rational polynomial.
The squarefree part and cofactor are recomputed by the checker; every leaf of the certificate is resolved, so its brackets and exact roots are all the real roots, each once.
Defined in src/polynomials/descartes.mojo.
| Field | Type | |
|---|---|---|
squarefree |
DensePoly[ZZ] |
The primitive positive-leading squarefree part g = f / gcd(f, f'). |
cofactor |
DensePoly[ZZ] |
The primitive gcd(f, f'), one for a squarefree input. |
bound_exponent |
Int |
The k with every root of g in (-2^k, 2^k). |
certificate |
DescartesCertificate |
The resolved leaves partitioning (-2^k, 2^k), with brackets and exact roots. |
AlgebraicDescartesCertificate.write_to¶
def write_to[W: Writer](self, mut writer: W)
Write the squarefree part, the bound exponent, the leaf count and every root.
Parameters.
W: The writer type.
Arguments.
writer: The destination.
AlgebraicEvaluationCertificate¶
@fieldwise_init
struct AlgebraicEvaluationCertificate(Copyable, Movable, Writable)
A complete sequence of Horner multiplication and addition witnesses.
Defined in src/polynomials/algebraic_evaluation.mojo.
| Field | Type | |
|---|---|---|
products |
List[AlgebraicArithmeticCertificate] |
Multiplications by the evaluation point, from highest coefficient down. |
sums |
List[AlgebraicArithmeticCertificate] |
Additions of the corresponding coefficients after each multiplication. |
value |
RealAlgebraic |
The final exact value, or rational zero for an empty coefficient list. |
AlgebraicPolynomialEvaluation¶
@fieldwise_init
struct AlgebraicPolynomialEvaluation(Copyable, Movable, Writable)
A fixed sparse evaluation schedule with one certificate per arithmetic step.
Defined in src/polynomials/algebraic_specialization.mojo.
| Field | Type | |
|---|---|---|
steps |
List[AlgebraicArithmeticCertificate] |
Binary powering, term multiplication and summation witnesses in traversal order. |
value |
RealAlgebraic |
The exact evaluation result. |
witness |
List[RealAlgebraic] |
For a direct proof without steps, a refined witness of the one irrational coordinate or of a generator; empty otherwise. |
representations |
List[DensePoly[QQ]] |
With a generator witness, each point coordinate as a polynomial in it; empty for one irrational coordinate. |
AlgebraicRootFilter¶
@fieldwise_init
struct AlgebraicRootFilter(Copyable, Movable, Writable)
The proof that one annihilator candidate is, or is not, a root.
Defined in src/polynomials/algebraic_roots.mojo.
| Field | Type | |
|---|---|---|
kind |
Int |
Zero for the next exact evaluation, one for interval exclusion, two for a representation zero proof. |
coefficients |
List[RealAlgebraic] |
Refined witnesses of every coefficient, for kinds one and two. |
candidate |
RealAlgebraic |
A refined witness of the candidate, for kinds one and two. |
representations |
List[DensePoly[QQ]] |
Kind two: q_i with c_i = q_i(candidate) and sum q_i(y) y^i divisible by its definition. Kind three: r_i with c_i = r_i(element), then a monic divisor's coefficients in the candidate's field. |
element |
RealAlgebraic |
Kind three: an algebraic number generating every coefficient. |
AlgebraicRootsAtCertificate¶
@fieldwise_init
struct AlgebraicRootsAtCertificate(Copyable, Movable, Writable)
Complete real roots after certified specialization of all other variables.
Defined in src/polynomials/algebraic_specialization.mojo.
| Field | Type | |
|---|---|---|
specialization |
AlgebraicSpecializationCertificate |
The exact coefficient specialization. |
isolation |
AlgebraicRootsCertificate |
Every real root of the specialized nonzero polynomial. |
AlgebraicRootsCertificate¶
@fieldwise_init
struct AlgebraicRootsCertificate(Copyable, Movable, Writable)
A nonzero rational annihilator, all its real roots, and exact filtering proofs.
Defined in src/polynomials/algebraic_roots.mojo.
| Field | Type | |
|---|---|---|
coefficients |
List[RealAlgebraic] |
Normalized representatives of every supplied coefficient, in ascending degree. |
coefficient_factors |
List[DensePoly[QQ]] |
Multipliers binding the normalized coefficient definitions to the originals. |
eliminations |
List[ResultantResult[QQ]] |
Successive identities eliminating the nonrational coefficient variables. |
annihilator |
DensePoly[QQ] |
A nonzero rational polynomial containing every possible real root. |
candidates |
List[RealAlgebraic] |
Every distinct real root of the annihilator, in strictly increasing order. |
candidate_factors |
List[DensePoly[QQ]] |
Multipliers proving each candidate definition divides the annihilator. |
all_roots |
AlgebraicDescartesCertificate |
A complete Descartes isolation of the annihilator's real roots, counting the candidates. |
evaluations |
List[AlgebraicEvaluationCertificate] |
Exact evaluations of the original polynomial at the candidates whose filter has kind zero. |
accepted |
List[Int] |
Increasing candidate indices whose evaluations are zero. |
roots |
List[RealAlgebraic] |
The selected real roots in strictly increasing order. |
filters |
List[AlgebraicRootFilter] |
One acceptance or rejection proof per candidate. |
element |
RealAlgebraic |
For a tower elimination, an algebraic number with c_i = r_i(element). |
representations |
List[DensePoly[QQ]] |
For a tower elimination, the r_i; empty for one elimination per irrational coefficient. |
AlgebraicSpecializationCertificate¶
@fieldwise_init
struct AlgebraicSpecializationCertificate(Copyable, Movable, Writable)
Exact algebraic coefficients after assigning a subset of polynomial variables.
Defined in src/polynomials/algebraic_specialization.mojo.
| Field | Type | |
|---|---|---|
monomials |
List[Monomial] |
The remaining monomials, including those whose coefficients become zero. |
evaluations |
List[AlgebraicPolynomialEvaluation] |
The coefficient evaluations aligned with the remaining monomials. |
RealAlgebraic¶
@fieldwise_init
struct RealAlgebraic(Copyable, Movable, Writable)
An exact real root isolated by Descartes' rule of signs.
An irrational value's polynomial has nonzero values of opposite sign at the endpoints and Descartes bound 1 on the open interval between them, which also excludes a repeated root there.
Defined in src/polynomials/algebraic_types.mojo.
| Field | Type | |
|---|---|---|
polynomial |
DensePoly[QQ] |
The monic defining polynomial in internal variable zero. |
low |
QQ |
The lower endpoint, equal to high for a rational value. |
high |
QQ |
The upper endpoint of the root interval. |
rational |
Bool |
Whether the endpoints specify an exact rational value. |
algebraic_add¶
def algebraic_add(a: RealAlgebraic, b: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicArithmeticCertificate
Add exact algebraic values with a complete arithmetic certificate.
Arguments.
a: The left operand.b: The right operand.budget: The shared work allowance.
Returns. The arithmetic result and its independent polynomial witnesses.
Raises.
PolyError: DOMAIN for invalid operands or inverse of zero, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_compare¶
def algebraic_compare(a: RealAlgebraic, b: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicComparisonCertificate
Compare exact real algebraic values with an independent witness.
Arguments.
a: The left root witness, with a possibly nonminimal definition.b: The right root witness.budget: The shared work allowance.
Returns. A certificate whose relation is negative one, zero or positive one.
Raises.
PolyError: DOMAIN for invalid value witnesses, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_evaluate¶
def algebraic_evaluate(coefficients: List[RealAlgebraic], x: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicEvaluationCertificate
Evaluate an algebraic-coefficient polynomial with complete arithmetic proofs.
Arguments.
coefficients: The coefficient list in ascending degree, including optional trailing zeros.x: The exact real evaluation point.budget: The shared work allowance.
Returns. The value and every multiplication and addition witness in Horner order.
Raises.
PolyError: DOMAIN for invalid value witnesses, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_evaluation.mojo.
algebraic_evaluate_sparse¶
def algebraic_evaluate_sparse(f: SparsePoly[QQ], point: List[Tuple[Int64, RealAlgebraic]], mut budget: Budget) raises PolyError -> AlgebraicPolynomialEvaluation
Evaluate a sparse polynomial at exact algebraic coordinates with arithmetic proofs.
Arguments.
f: The rational polynomial.point: Distinct assignments covering every variable of the polynomial.budget: The shared work allowance.
Returns. The exact result and its complete arithmetic transcript.
Raises.
PolyError: DOMAIN for missing, duplicate or invalid assignments, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
algebraic_inverse¶
def algebraic_inverse(a: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicArithmeticCertificate
Invert exact algebraic values with a complete arithmetic certificate.
Arguments.
a: The left operand.budget: The shared work allowance.
Returns. The arithmetic result and its independent polynomial witnesses.
Raises.
PolyError: DOMAIN for invalid operands or inverse of zero, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_multiply¶
def algebraic_multiply(a: RealAlgebraic, b: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicArithmeticCertificate
Multiply exact algebraic values with a complete arithmetic certificate.
Arguments.
a: The left operand.b: The right operand.budget: The shared work allowance.
Returns. The arithmetic result and its independent polynomial witnesses.
Raises.
PolyError: DOMAIN for invalid operands or inverse of zero, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_negate¶
def algebraic_negate(a: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicArithmeticCertificate
Negate exact algebraic values with a complete arithmetic certificate.
Arguments.
a: The left operand.budget: The shared work allowance.
Returns. The arithmetic result and its independent polynomial witnesses.
Raises.
PolyError: DOMAIN for invalid operands or inverse of zero, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_roots¶
def algebraic_roots(coefficients: List[RealAlgebraic], mut budget: Budget) raises PolyError -> AlgebraicRootsCertificate
Find every distinct real root of an algebraic-coefficient polynomial.
Arguments.
coefficients: Exact real coefficients in ascending degree, including optional trailing zeros.budget: The shared work allowance.
Returns. Sorted distinct real roots with elimination, completeness and filtering witnesses.
Raises.
PolyError: DOMAIN for zero or invalid value witnesses, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_roots.mojo.
algebraic_roots_at¶
def algebraic_roots_at(f: SparsePoly[QQ], variable: Int64, point: List[Tuple[Int64, RealAlgebraic]], mut budget: Budget) raises PolyError -> AlgebraicRootsAtCertificate
Isolate every real root after assigning all variables except one.
Arguments.
f: The rational multivariate polynomial.variable: The unassigned root variable.point: Distinct assignments for every other occurring variable.budget: The shared work allowance.
Returns. The specialization and complete root certificates.
Raises.
PolyError: DOMAIN for zero specialization or invalid assignments, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
algebraic_sign¶
def algebraic_sign(value: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicComparisonCertificate
Determine the sign of an exact real algebraic value with a comparison proof.
Arguments.
value: The exact real value.budget: The shared work allowance.
Returns. A comparison against rational zero, with relation minus one, zero or one.
Raises.
PolyError: DOMAIN for an invalid witness, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
algebraic_specialize¶
def algebraic_specialize(f: SparsePoly[QQ], point: List[Tuple[Int64, RealAlgebraic]], mut budget: Budget) raises PolyError -> AlgebraicSpecializationCertificate
Specialize any subset of variables with exact algebraic coefficient proofs.
Arguments.
f: The rational polynomial.point: Distinct exact assignments for a subset of its variables.budget: The shared work allowance.
Returns. Remaining monomials and their certified algebraic coefficients, including zeros.
Raises.
PolyError: DOMAIN for invalid assignments, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
algebraic_subtract¶
def algebraic_subtract(a: RealAlgebraic, b: RealAlgebraic, mut budget: Budget) raises PolyError -> AlgebraicArithmeticCertificate
Subtract exact algebraic values with a complete arithmetic certificate.
Arguments.
a: The left operand.b: The right operand.budget: The shared work allowance.
Returns. The arithmetic result and its independent polynomial witnesses.
Raises.
PolyError: DOMAIN for invalid operands or inverse of zero, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
check_algebraic_arithmetic¶
def check_algebraic_arithmetic(a: RealAlgebraic, b: Optional[RealAlgebraic], certificate: AlgebraicArithmeticCertificate, mut budget: Budget) raises PolyError -> Bool
Verify algebraic arithmetic without computing resultants or isolating roots.
Arguments.
a: The original left operand.b: The original right operand, absent for negate and inverse.certificate: The operation, result and complete polynomial witnesses.budget: The shared work allowance.
Returns. Whether the certificate proves its stated arithmetic result.
Raises.
PolyError: DOMAIN for malformed polynomials, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_arithmetic.mojo.
check_algebraic_descartes¶
def check_algebraic_descartes(f: DensePoly[QQ], certificate: AlgebraicDescartesCertificate, mut budget: Budget) raises PolyError -> Bool
Check a complete Descartes isolation of the real roots of a rational polynomial.
Recomputes the squarefree part and cofactor, checks the interval against the root bound, verifies the certificate without searching, and requires every leaf resolved.
Arguments.
f: The nonzero polynomial.certificate: The proposed complete isolation.budget: The shared work allowance.
Returns. Whether the certificate isolates every distinct real root of f.
Raises.
PolyError: DOMAIN for malformed polynomial data, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/descartes.mojo.
check_algebraic_comparison¶
def check_algebraic_comparison(a: RealAlgebraic, b: RealAlgebraic, certificate: AlgebraicComparisonCertificate, mut budget: Budget) raises PolyError -> Bool
Check interval separation or common-root identities without gcd or isolation.
Arguments.
a: The original left value.b: The original right value.certificate: The comparison witness to check.budget: The shared work allowance.
Returns. Whether the stated relation follows from the witnesses.
Raises.
PolyError: DOMAIN for malformed polynomials, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
check_algebraic_evaluate_sparse¶
def check_algebraic_evaluate_sparse(f: SparsePoly[QQ], point: List[Tuple[Int64, RealAlgebraic]], certificate: AlgebraicPolynomialEvaluation, mut budget: Budget) raises PolyError -> Bool
Verify a sparse evaluation by checking its fixed arithmetic schedule.
Arguments.
f: The original rational polynomial.point: The original exact assignments.certificate: The proposed evaluation transcript.budget: The shared work allowance.
Returns. Whether every arithmetic witness and the final value are valid.
Raises.
PolyError: LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
check_algebraic_evaluation¶
def check_algebraic_evaluation(coefficients: List[RealAlgebraic], x: RealAlgebraic, certificate: AlgebraicEvaluationCertificate, mut budget: Budget) raises PolyError -> Bool
Check all Horner steps without computing algebraic arithmetic results.
Arguments.
coefficients: The original ascending coefficient list.x: The original exact evaluation point.certificate: The proposed arithmetic chain and final value.budget: The shared work allowance.
Returns. Whether the chain proves the stated polynomial evaluation.
Raises.
PolyError: DOMAIN for malformed polynomials, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_evaluation.mojo.
check_algebraic_roots¶
def check_algebraic_roots(coefficients: List[RealAlgebraic], certificate: AlgebraicRootsCertificate, mut budget: Budget) raises PolyError -> Bool
Verify root completeness and filtering without elimination or root isolation.
Arguments.
coefficients: The original ascending coefficient list.certificate: All elimination, count, candidate and evaluation witnesses.budget: The shared work allowance.
Returns. Whether the supplied roots are exactly all distinct real roots.
Raises.
PolyError: DOMAIN for malformed polynomials, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_roots.mojo.
check_algebraic_roots_at¶
def check_algebraic_roots_at(f: SparsePoly[QQ], variable: Int64, point: List[Tuple[Int64, RealAlgebraic]], certificate: AlgebraicRootsAtCertificate, mut budget: Budget) raises PolyError -> Bool
Verify both specialization and completeness of the resulting real roots.
Arguments.
f: The original rational polynomial.variable: The unassigned root variable.point: The original exact assignments.certificate: The coefficient and root witnesses.budget: The shared work allowance.
Returns. Whether the proposed list is exactly the distinct real roots at the point.
Raises.
PolyError: DOMAIN for malformed assignments, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
check_algebraic_specialization¶
def check_algebraic_specialization(f: SparsePoly[QQ], point: List[Tuple[Int64, RealAlgebraic]], certificate: AlgebraicSpecializationCertificate, mut budget: Budget) raises PolyError -> Bool
Verify every coefficient of a partial algebraic specialization.
Arguments.
f: The original rational polynomial.point: The exact assignments.certificate: The proposed remaining monomials and coefficient proofs.budget: The shared work allowance.
Returns. Whether the certificate contains exactly the specialized coefficients.
Raises.
PolyError: DOMAIN for malformed assignments, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic_specialization.mojo.
check_real_algebraic¶
def check_real_algebraic(value: RealAlgebraic, mut budget: Budget) raises PolyError -> Bool
Verify an algebraic value by exact evaluation or a Descartes root bound.
Arguments.
value: The proposed rational value or unique real root witness.budget: The shared work allowance.
Returns. Whether the witness defines exactly one real number.
Raises.
PolyError: DOMAIN for malformed polynomials, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
real_rational¶
def real_rational(value: QQ, mut budget: Budget) raises PolyError -> RealAlgebraic
Embed an exact rational as a real algebraic value.
Arguments.
value: The rational number.budget: The shared work allowance.
Returns. A linear defining polynomial and exact rational endpoints.
Raises.
PolyError: LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.
real_root¶
def real_root(f: DensePoly[QQ], low: QQ, high: QQ, mut budget: Budget) raises PolyError -> RealAlgebraic
Select the unique real root in an exact rational interval.
Arguments.
f: A nonconstant rational polynomial, with repetitions allowed.low: The lower endpoint, or the exact root when endpoints agree.high: The upper endpoint; open intervals require nonroot endpoints.budget: The shared work allowance.
Returns. A monic irreducible defining polynomial and a checked root witness.
Raises.
PolyError: DOMAIN for invalid root selection, LIMIT or CAPACITY on work limits.
Defined in src/polynomials/algebraic.mojo.