AlgebraicNumberTool

antool.spad line 89 [edit on github]

AlgebraicNumberTool provides functions to find better/easier representations of algebraic numbers. We try to guarantee that the value of the input algebraic number equals to the output algebraic number within the precision of Float.

absList: List Integer -> List Integer

absList(l) returns removeDuplicates sort(map(abs, x)).

approximateNestedRadical: (AlgebraicNumber, Fraction Integer) -> AInterval Fraction Integer

approximateNestedRadical(x,eps) returns an interval iv with width(iv)<=eps such that contains?(iv,x::Float) (where Float is taken with enough precision. Input condition: x is a nested radicals with each expression under an nthRoot being positive. If the input condition is not fulfilled then sup(iv)<0.

approximateNthRoot: (AlgebraicNumber, PositiveInteger, Fraction Integer) -> AInterval Fraction Integer

approximateNthRoot(x,n,eps) returns a positive interval iv such that width(iv)<=eps and contains?(iv,nthRoot(x::Float,n)) where Float is set with enough precision. Input condition: x is a nested radicals with each expression under an nthRoot being positive. If the input condition is not fulfilled then the error interval [0,-1] is returned.

combineCommonSqrt: AlgebraicNumber -> AlgebraicNumber

combineCommonSqrt(x) finds expressions of the form (a*sqrt(r)+b)*sqrt(u*sqrt(r)+v) and combines it to s*sqrt((a*sqrt(r)+b)^2*sqrt(u*sqrt(r)+v)) where s is a compensating factor to make both expression have the same complex value when taking the branch cut along the negative real axes.

combineIntegerRoot?: (AlgebraicNumber, AlgebraicNumber) -> Boolean

combinePositiveIntegerRoot?: (AlgebraicNumber, AlgebraicNumber) -> Boolean

combineSameRoot?: (AlgebraicNumber, AlgebraicNumber) -> Boolean

combineSqrtFactors: List AlgebraicNumber -> AlgebraicNumber

combineSqrtFactors(l) forms the product over all elements of the list l, but combines factors of the form (a*sqrt(b)+c*sqrt(d)) (that may appear with a sqrt in front of such an expression. Only factors with the same b and d are combined. We ensure that the resulting expression gives the same complex value as the product of the list elements.

complexValue: AlgebraicNumber -> Complex Float

complexValue(x) converts the algebraic number x into a complex floating point representation with the currently set precision.

integerRootFactor: AlgebraicNumber -> AlgebraicNumber

integerRootFactor(x) factors any expression in x of the form nthRoot(z,n) where z is an integer into the product of nthRoot(f,n) for all factors f of z. This does not change the value of x.

integerRootFactorK: Kernel AlgebraicNumber -> AlgebraicNumber

integerRootKernel?: Kernel AlgebraicNumber -> Boolean

integerRootKernels: List Kernel AlgebraicNumber -> List Kernel AlgebraicNumber

isSqrt: AlgebraicNumber -> Union(AlgebraicNumber, failed)

isSqrt(x) returns z if x=nthRoot(z,2) and failed otherwise.

mapOverFactors: (SparseMultivariatePolynomial(Integer, Kernel AlgebraicNumber), BasicOperator, PositiveInteger) -> AlgebraicNumber

recursiveRootSimplification: AlgebraicNumber -> AlgebraicNumber

recursiveRootSimplification(x) applies rsimp from the leaves of the expression to the top of the expression tree. If rsimp(z) returns “failed” for a subexpression, z is used for further computation.

recursiveRootSimplificationPoly: SparseMultivariatePolynomial(Integer, Kernel AlgebraicNumber) -> AlgebraicNumber

rootCombine: (AlgebraicNumber, (AlgebraicNumber, AlgebraicNumber) -> Boolean) -> AlgebraicNumber

rootFactor: AlgebraicNumber -> AlgebraicNumber

rootFactor(x) factors expressions under the root kernels and returns factors of roots. It multiplies a certain compensating root of unity such that the value of the input agrees with that of the output taking into account that the branch cut of the root is the negative real axix.

rootFactorK: (List Kernel AlgebraicNumber, List AlgebraicNumber, Kernel AlgebraicNumber) -> AlgebraicNumber

rootFactorPol: (SparseMultivariatePolynomial(Integer, Kernel AlgebraicNumber), BasicOperator, PositiveInteger) -> AlgebraicNumber

simpler?: (AlgebraicNumber, AlgebraicNumber) -> Boolean

simpler?(x,y) is true if x has a “simpler” structure than y. We neglect the denominator (which is supposed to be an integer). It is true if x and y are integers and x < y; true if x is an integer and y a polynomial; false if y is an integer and x a polynomial; true if x has less variables than y; false if y has less variables than x; false if x (or y) has more than 1 term; true if x has less variables than y; false if y has less variables than x; nx<ny if x and y are n-th root expression and nx~=ny; simpler?(argument(x),argument(y)).

simplifyRadicals: AlgebraicNumber -> AlgebraicNumber

simplifyRadicals(x) applies recursiveRootSimplification to x and some other transformations to make the radical more “canonical”.

sqrtArgument: Kernel AlgebraicNumber -> Integer

sqrtArgument(k) returns z if k is nthRoot(z,2) for some integer z and 0 if that is not the case.

sqrtSum: AlgebraicNumber -> List List Integer

sqrtSum(x) returns a list of pairs [ai,ci] if x is of the form $sum_{i=1}^n ci*sqrt(ai)$ with ci~=0 and ai<aj if i<j. We expect the denominator to be an integer and only consider the numerator. The returned list is empty, if x is not of the above form, it is [[numer(x),1]] if x is rational.

sqrtSumArguments: AlgebraicNumber -> List Integer

sqrtSumArguments(x) returns a list of the ai if x is of the form $sum_{i=1}^n ci*sqrt(ai)$ with ci~=0, (ai=1 for at most one i) and ai<aj if i<j. We expect the denominator to be an integer and only consider the numerator. The returned list is empty, if x is not of the above form, it is [1] if x is rational.