Optionalvalue: string | Root | Fraction | PolynomRoot | SolutionMultiplicity of the root (always >= 1; defaults to 1). A double root reports 2, etc.
ASCII rendering. Mirrors tex (override precedence, then #compose).
Returns null only when explicitly overridden to null via set display.
ASCIIMath rendering of the current state (terminal output, not chainable).
Whether the value is faithfully exact: true for an exact rational or a
quadratic irrational carried by an index-2 Root, false for a floating
(Cardan / bisection) approximation. Never mark a float value exact.
Rational part of the value.
Radical part of the value: zero for a rational solution.
LaTeX rendering. An explicit override (set tex) takes precedence; otherwise the value is composed from its
parts: the fraction or the radical alone in the simple cases, else (numerator ± radical)/denominator.
With withDigits, the decimal value.
LaTeX rendering of the current state (terminal output, not chainable).
Decimal value: the rational part plus the radical part.
Full duplicate of this Solution, including the display state (#display/#tex).
Copy the math state of another Solution into this (parts are cloned).
Display overrides are not transferred, and any stale #display/#tex
on this is dropped so the getters recompute from the new state.
True when both the rational part and the radical part are zero.
Router that builds a Solution from a supported input by delegating to the
matching factory: string → fromString, Fraction → fromFraction,
Root → fromRoot, PolynomRoot → fromPolynomRoot, Solution → copy.
Reduce the radical and rational parts to their canonical form, in place,
and return this. Deliberate exception to the clone-and-commit atomicity
convention: Root.reduce / Fraction.reduce are total (never throw), so
the receiver cannot be left half-mutated.
Flag the solution as exact (default) or approximate.
Show the numeric value as a decimal with digits digits, whatever the exact form (a
radical included: (1+sqrt(2))/2 becomes 1.21). null goes back to the exact form.
Takes precedence over a tex / display override.
StaticfromBuild an exact solution from a rational value.
StaticfromWrap a raw PolynomRoot (fraction + radical parts) into a Solution, mapping its multiplicity to count.
StaticfromSolve A·x² + B·x + C = 0. Returns [] when the discriminant is negative,
a single solution (with count === 2) for a double root, otherwise the two
solutions. Irrational roots are kept exact (index-2 Root).
StaticfromStaticfromParse a string representation of a solution. Three strict forms:
2/5, -3, 1.23sqrt(5), -2sqrt(3), sqrt(5)/3, 2sqrt(3)/5(-1+sqrt(5))/2, (3-2sqrt(7))/4
An equation / polynomial root as an exact decomposed value: a rational part (
#fraction) plus a radical part (#root).Invariant (maintained by the producers, not enforced by the type):
#fractioncarries every rational part, and#rootis either zero or a genuinely irrational radical — never a perfect-power radical that would reduce to a rational.EquationSolver/fromQuadraticonly build a radical on the non-square-discriminant branch, so a non-zero#rootalways accompanies a truly irrational value.The
tex/displaycomposition relies on this: it runs the two-part(numerator ± radical)/denominatorlayout only when both parts are non-zero, i.e. on a real irrational. It does not re-simplify a manually built perfect-power radical (e.g.#fraction = 1,#root = √4), which would render as the unsimplified1 +2— an incoherent state the producers never create.