Companion for _Surd: the factory, the exact field arithmetic, and the readers.
Every operation answers Option: None means the result is not a quadratic surd over the same radical (√2 + √3, a fractional power of a surd), and the caller leaves the exact set the way it always has, through spire's Real to a working-precision rational (_Surd.approximateOp). A surd is therefore never less exact than the rational that stood in its place before F_0231.
Attributes
Members list
Value members
Concrete methods
x + y, exactly, when both share a radical.
x + y, exactly, when both share a radical.
Attributes
op on two exact values outside the surd field, the way the exact tier always left it: through Real, back to a rational at digits.
op on two exact values outside the surd field, the way the exact tier always left it: through Real, back to a rational at digits.
Attributes
- Returns
-
the approximation, or
Nonewhen either value is not exact
A binary operation on two exact values: the exact field operation when it applies, else approximateOp -- so an operand pair outside one radical is answered exactly as before.
A binary operation on two exact values: the exact field operation when it applies, else approximateOp -- so an operand pair outside one radical is answered exactly as before.
Value parameters
- digits
-
the working precision of the approximation
- exact
-
the field operation,
Noneoutside one radical - real
-
the same operation on
Reals - x
-
the left operand
- y
-
the right operand
Attributes
- Returns
-
the result, or
Nonewhen it is undefined (a division by zero)
The order of two exact values, decided exactly: by the sign of the difference over one radical, else by reading the difference at growing precision, which ends because two exact values that are not combinable are not equal.
The order of two exact values, decided exactly: by the sign of the difference over one radical, else by reading the difference at growing precision, which ends because two exact values that are not combinable are not equal.
Attributes
- Returns
-
-1,0or1, orNonewhen either is not exact
x / y, by the conjugate: x·(a₂ − b₂√d) / (a₂² − b₂²d). The denominator vanishes only for y = 0, since d is not a perfect square.
x / y, by the conjugate: x·(a₂ − b₂√d) / (a₂² − b₂²d). The denominator vanishes only for y = 0, since d is not a perfect square.
Attributes
- Returns
-
the quotient, or
Nonefor a zero divisor or radicals that do not combine
An exact value as a rational at digits places: a rational as itself, a surd as the working-precision approximation it stood for before F_0231. What every computation that needs a rational reads a surd through, so none demotes it to Double.
An exact value as a rational at digits places: a rational as itself, a surd as the working-precision approximation it stood for before F_0231. What every computation that needs a rational reads a surd through, so none demotes it to Double.
Value parameters
- digits
-
the working precision
- v
-
the value
Attributes
- Returns
-
the rational, or
Nonefor a value that is not exact
Whether x and y are both exact and at least one is a surd: the gate on the operator arms, which keep their faster rational-rational arm first.
Whether x and y are both exact and at least one is a surd: the gate on the operator arms, which keep their faster rational-rational arm first.
Attributes
Whether v is exact in the sense of this type: a rational or a surd.
Whether v is exact in the sense of this type: a rational or a surd.
Attributes
x · y = (a₁a₂ + b₁b₂d) + (a₁b₂ + a₂b₁)√d, exactly, when both share a radical.
x · y = (a₁a₂ + b₁b₂d) + (a₁b₂ + a₂b₁)√d, exactly, when both share a radical.
Attributes
a + b·√d as the simplest exact value it equals: the rational a when b = 0 or d = 0, the rational a + b·r when d = r², else a surd with the small square factors of d moved into b.
a + b·√d as the simplest exact value it equals: the rational a when b = 0 or d = 0, the rational a + b·r when d = r², else a surd with the small square factors of d moved into b.
Value parameters
- a
-
the rational part
- b
-
the coefficient of the radical
- d
-
the radicand
Attributes
- Returns
-
the value, or
Nonefor a negative radicand (the complex case, not this type's)
x^k for an integer k, held to maxBits before any product is formed (the _Rational.pow rule): the estimate is the largest part's bit length times |k|.
x^k for an integer k, held to maxBits before any product is formed (the _Rational.pow rule): the estimate is the largest part's bit length times |k|.
Attributes
- Returns
-
the power, or
Nonepast the budget or for a negative power of zero
The sign of an exact value, decided exactly: when a and b disagree, by comparing a² with b²d, which cannot tie since d is not a perfect square.
The sign of an exact value, decided exactly: when a and b disagree, by comparing a² with b²d, which cannot tie since d is not a perfect square.
Attributes
- Returns
-
-1,0or1, orNonefor a value of another kind
The exact square root of a non-negative rational: √(p/q) = √(p·q)/q.
The exact square root of a non-negative rational: √(p/q) = √(p·q)/q.
Value parameters
- r
-
the radicand
Attributes
- Returns
-
a rational for a perfect square, a surd otherwise,
Nonewhenr < 0
x − y, exactly, when both share a radical.
x − y, exactly, when both share a radical.