Algebraic

Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

@SerialVersionUID(0L)
case
object BFMSS extends ZeroBoundFunction

An implementation of "A Separation Bound for Real Algebraic Expressions", by Burnikel, Funke, Mehlhorn, Schirra, and Schmitt. This provides a good ZeroBoundFunction for use in sign tests.

An implementation of "A Separation Bound for Real Algebraic Expressions", by Burnikel, Funke, Mehlhorn, Schirra, and Schmitt. This provides a good ZeroBoundFunction for use in sign tests.

Unlike the paper, we use log-arithmetic instead of working with exact, big integer values. This means our bound isn't technically as good as it could be, but we save the cost of working with arithmetic. We also perform all log arithmetic using Longs and check for overflow (throwing ArithmeticExceptions when detected). In practice we shouldn't hit this limit, but in case we do, we prefer to throw over failing silently.

final
class BitBound(val bitBound: Long) extends AnyVal

A bit bound represents either an upper or lower bound as some power of 2. Specifically, the bound is typically either 2^bitBound or 2^-bitBound.

A bit bound represents either an upper or lower bound as some power of 2. Specifically, the bound is typically either 2^bitBound or 2^-bitBound.

Companion
object
object BitBound
Companion
class
sealed abstract
class Expr extends Serializable

The Algebraic expression AST. Algebraic simply stores an expression tree representing all operations performed on it. We then use this tree to deduce certain properties about the algebraic expression and use them to perform exact sign tests, compute approximations, etc.

The Algebraic expression AST. Algebraic simply stores an expression tree representing all operations performed on it. We then use this tree to deduce certain properties about the algebraic expression and use them to perform exact sign tests, compute approximations, etc.

Generally, this should be regarded as an internal implementation detail of Algebraic.

Companion
object
object Expr
Companion
class
@SerialVersionUID(0L)
case
object LiYap extends ZeroBoundFunction

An implementation of "A New Constructive Root Bound for Algebraic Expressions" by Chen Li & Chee Yap.

An implementation of "A New Constructive Root Bound for Algebraic Expressions" by Chen Li & Chee Yap.

sealed abstract

A zero bound function, defined over an algebraic expression algebra.

A zero bound function, defined over an algebraic expression algebra.

Value members

Concrete methods

def apply(n: Long): Algebraic

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

def apply(n: Float): Algebraic

Returns an Algebraic expression equivalent to n, if n is finite. If n is either infinite or NaN, then an IllegalArgumentException is thrown.

Returns an Algebraic expression equivalent to n, if n is finite. If n is either infinite or NaN, then an IllegalArgumentException is thrown.

def apply(n: BigInt): Algebraic

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

def apply(n: BigDecimal): Algebraic

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

def apply(n: String): Algebraic

Returns an Algebraic expression equivalent to BigDecimal(n). If n is not parseable as a BigDecimal then an exception is thrown.

Returns an Algebraic expression equivalent to BigDecimal(n). If n is not parseable as a BigDecimal then an exception is thrown.

final
def nroot(value: BigDecimal, n: Int, mc: MathContext): BigDecimal

Returns a relative approximation of the n-th root of value, up to the number of digits specified by mc. This only uses the rounding mode to chop-off the few remaining digits after the approximation, so may be inaccurate.

Returns a relative approximation of the n-th root of value, up to the number of digits specified by mc. This only uses the rounding mode to chop-off the few remaining digits after the approximation, so may be inaccurate.

final
def nroot(value: BigDecimal, n: Int, scale: Int, roundingMode: RoundingMode): BigDecimal

Returns an absolute approximation of the n-th root of value, up to scale digits past the decimal point. This only uses the rounding mode to chop-off the few remaining digits after the approximation, so may be inaccurate.

Returns an absolute approximation of the n-th root of value, up to scale digits past the decimal point. This only uses the rounding mode to chop-off the few remaining digits after the approximation, so may be inaccurate.

final
def nrootApprox(x: BigDecimal, n: Int): BigDecimal

Returns a number that is approximately equal to x.pow(1/n). This number is useful as initial values in converging n-root algorithms, but not as a general purpose n-root algorithm. There are no guarantees about the accuracy here.

Returns a number that is approximately equal to x.pow(1/n). This number is useful as initial values in converging n-root algorithms, but not as a general purpose n-root algorithm. There are no guarantees about the accuracy here.

def root(poly: Polynomial[Rational], i: Int): Algebraic

Returns an Algebraic expression whose value is equivalent to the i-th real root of the Polynomial poly. If i is negative or does not an index a real root (eg the value is greater than or equal to the number of real roots) then an ArithmeticException is thrown. Roots are indexed starting at 0. So if there are 3 roots, then they are indexed as 0, 1, and 2.

Returns an Algebraic expression whose value is equivalent to the i-th real root of the Polynomial poly. If i is negative or does not an index a real root (eg the value is greater than or equal to the number of real roots) then an ArithmeticException is thrown. Roots are indexed starting at 0. So if there are 3 roots, then they are indexed as 0, 1, and 2.

Value Params
i

the index (0-based) of the root

poly

the polynomial containing at least i real roots

Returns

an algebraic whose value is the i-th root of the polynomial

def roots(poly: Polynomial[Rational]): Vector[Algebraic]

Returns all of the real roots of the given polynomial, in order from smallest to largest.

Returns all of the real roots of the given polynomial, in order from smallest to largest.

Value Params
poly

the polynomial to return the real roots of

Returns

all the real roots of poly

def unsafeRoot(poly: Polynomial[BigInt], i: Int, lb: Rational, ub: Rational): Algebraic

Returns an Algebraic whose value is the real root within (lb, ub). This is potentially unsafe, as we assume that exactly 1 real root lies within the interval, otherwise the results are undetermined.

Returns an Algebraic whose value is the real root within (lb, ub). This is potentially unsafe, as we assume that exactly 1 real root lies within the interval, otherwise the results are undetermined.

Value Params
i

the index of the root in the polynomial

lb

the lower bound of the open interval containing the root

poly

a polynomial with a real root within (lb, ub)

ub

the upper bound of the open interval containing the root

Concrete fields

Returns an Algebraic expression equal to 1.

Returns an Algebraic expression equal to 1.

Returns an Algebraic expression equal to 0.

Returns an Algebraic expression equal to 0.

Implicits

Implicits

implicit
def apply(n: Int): Algebraic

Returns an Algebraic expression equivalent to n.

Returns an Algebraic expression equivalent to n.

implicit
def apply(n: Double): Algebraic

Returns an Algebraic expression equivalent to n, if n is finite. If n is either infinite or NaN, then an IllegalArgumentException is thrown.

Returns an Algebraic expression equivalent to n, if n is finite. If n is either infinite or NaN, then an IllegalArgumentException is thrown.