R/MRatCalcpowered by RiX

RiX walkthrough 14 k

Certified algebraic reals in RiX

Build exact real roots, inspect Sturm certificates, refine rational intervals, and compare sqrt(2) without floating point.

The algebraic-real plugin is written entirely in RiX and delegates polynomial work to the pure-RiX .poly dependency. Its algorithms use exact Integer and Rational arithmetic, so the same certificate path runs in the CLI, RiX Web, and RiX Notebook without a JavaScript plugin boundary or duplicate Polynomial representation.

Construct an isolated root

Coefficient arrays start with the constant term:

Runnable RiX

This identifies the positive root of x^2 - 2: the interval 1:2 contains one real root and one real root lies to its left, so its certified index is 2. Try changing the index to 1. Construction fails rather than retaining inconsistent metadata.

Inspect the exact certificate machinery

Runnable RiX

Content normalization changes [-4, 0, 2] to [-2, 0, 1]. The Sturm sequence is [-2, 0, 1], [0, 2], [2]. Sign-variation differences count roots in any rational interval:

p is an ordinary rix.polynomial@1 callable. It can be passed directly to other polynomial-aware plugins; algebraic-real adds no private polynomial type.

Runnable RiX

Repeated factors are rejected for stored algebraic reals:

Runnable RiX

Compare sqrt(2) exactly

Runnable RiX

No decimal approximation is needed. Polynomial evaluation proves equality when the comparator is a rational root; otherwise a Sturm count tells which side of that rational contains the isolated root.

Refine with bounded work

Runnable RiX

Ten exact bisections shrink 1:2 to width 1/1024. Set maxWork=2 to see a :budgetExhausted result that still carries the best certified interval.

Save and restore

Runnable RiX

Import recomputes normalization, square-freeness, isolation, and root index. The serialized evidence is provenance, not an unchecked authority.

Exact resultant arithmetic

Phase 2 field operations return newly isolated algebraic reals. Each result has an exact square-free integer polynomial, rational isolating interval, and fresh Sturm certificate:

Runnable RiX

The elimination polynomial may contain roots arising from other pairs of conjugates. Exact interval arithmetic on the selected operands identifies the intended root; refinement continues until its interval contains exactly one resultant root. x+x, for example, has square-free polynomial z(z^2-8), but the interval 2:4 selects 2*sqrt(2).

Runnable RiX

Comparison between algebraic values is exact subtraction followed by exact sign determination. Cross-family arithmetic still uses Oracle, preserving the representation-neutral real protocol.