An alias for mod.
An alias for quot.
Return a non-negative Algebraic with the same magnitude as this one.
Returns the cube root of this number.
Returns an integer with the same sign as this - that.
Returns an integer with the same sign as this - that. Specifically, if
this < that, then the sign is negative, if this > that, then the
sign is positive, otherwise this == that and this returns 0.
Returns a Double that approximates this value.
Returns a Double that approximates this value. If the exponent is too
large to fit in a double, the Double.PositiveInfinity or
Double.NegativeInfinity is returned.
Evaluates this algebraic expression with a different number type.
Evaluates this algebraic expression with a different number type. All
Algebraic numbers store the entire expression tree, so we can use this
to *replay* the stored expression using a different type. This will
accumulate errors as if the number type had been used from the beginning
and is only really suitable for more exact number types, like Real.
TODO: Eq/ClassTag come from poly.map - would love to get rid of them.
Returns a Float that approximates this value.
Returns a Float that approximates this value. If the exponent is too
large to fit in a float, the Float.PositiveInfinity or
Float.NegativeInfinity is returned.
Returns the nearest, valid Int value to this Algebraic, without going
further away from 0 (eg.
Returns the nearest, valid Int value to this Algebraic, without going
further away from 0 (eg. truncation).
If this Algebraic represented 1.2, then this would return 1. If this
represented -3.3, then this would return -3. If this value is greater than
Int.MaxValue, then Int.MaxValue is returned. If this value is less
than Int.MinValue, then Int.MinValue is returned.
Returns true iff this is a rational expression (ie contains no n-root
expressions).
Returns true iff this is a rational expression (ie contains no n-root
expressions). Otherwise it is a radical expression and returns false.
Returns true if this Algebraic number is a whole number (no fractional
part) and fits within the bounds of an Int.
Returns true if this Algebraic number is a whole number (no fractional
part) and fits within the bounds of an Int. That is, if x.isValidInt,
then Algebraic(x.toInt) == x.
Returns true if this Algebraic number is a whole number (no fractional
part) and fits within the bounds of an Long.
Returns true if this Algebraic number is a whole number (no fractional
part) and fits within the bounds of an Long. That is, if x.isValidLong,
then Algebraic(x.toLong) == x.
Returns true iff this Algebraic exactly represents a valid BigInt.
Returns true iff this Algebraic exactly represents a valid BigInt.
Returns true iff this Algebraic number is exactly 0.
Returns the nearest, valid Long value to this Algebraic, without going
further away from 0 (eg.
Returns the nearest, valid Long value to this Algebraic, without going
further away from 0 (eg. truncation).
If this Algebraic represented 1.2, then this would return 1. If this
represented -3.3, then this would return -3. If this value is greater than
Long.MaxValue, then Long.MaxValue is returned. If this value is less
than Long.MinValue, then Long.MinValue is returned.
Returns an Algebraic whose value is the difference between this and
(this /~ that) * that -- the modulus.
Returns the k-th root of this number.
Raise this number to the k-th power.
Returns an Algebraic whose value is just the integer part of
this / that.
Returns an Algebraic whose value is just the integer part of
this / that. This operation is exact.
Returns the sign of this Algebraic number.
Returns the sign of this Algebraic number. Algebraic numbers support exact sign tests, so this is guaranteed to be accurate.
Returns an Int with the same sign as this algebraic number.
Returns an Int with the same sign as this algebraic number. Algebraic
numbers support exact sign tests, so this is guaranteed to be accurate.
Returns the square root of this number.
Relative approximation to the precision specified in mc with the given
rounding mode.
Relative approximation to the precision specified in mc with the given
rounding mode. Rounding is always exact. The sign is always correct; the
sign of the returned BigDecimal matches the sign of the exact value this
Algebraic represents.
the precision and rounding mode of the final result
an approximation to the value of this algebraic number
Absolute approximation to scale decimal places with the given rounding
mode.
Absolute approximation to scale decimal places with the given rounding
mode. Rounding is always exact.
Returns the nearest, valid BigInt value to this Algebraic, without going
further away from 0 (eg.
Returns the nearest, valid BigInt value to this Algebraic, without going
further away from 0 (eg. truncation).
If this Algebraic represented 1.2, then this would return 1. If this
represented -3.3, then this would return -3.
If this is a rational expressions, then it returns the exact value as a Rational.
If this is a rational expressions, then it returns the exact value as a
Rational. Otherwise, this is a radical expression and None is
returned.
Returns an exact Real representation of this number.
Algebraic provides an exact number type for algebraic numbers. Algebraic numbers are roots of polynomials with rational coefficients. With it, we can represent expressions involving addition, multiplication, division, n-roots (eg.
sqrtorcbrt), and roots of rational polynomials. So, it is similar Rational, but adds roots as a valid, exact operation. The cost is that this will not be as fast as Rational for many operations.In general, you can assume all operations on this number type are exact, except for those that explicitly construct approximations to an Algebraic number, such as
toBigDecimal.For an overview of the ideas, algorithms, and proofs of this number type, you can read the following papers: