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.
- 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:xis 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:xis 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)) wheresis 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 listl, 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 samebanddare 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 numberxinto a complex floating point representation with the currently set precision.
- integerRootFactor: AlgebraicNumber -> AlgebraicNumber
integerRootFactor(x)factors any expression inxof the form nthRoot(z,n) wherezis an integer into the product of nthRoot(f,n) for all factorsfofz. This does not change the value ofx.
integerRootFactorK: Kernel AlgebraicNumber -> AlgebraicNumber
integerRootKernel?: Kernel AlgebraicNumber -> Boolean
integerRootKernels: List Kernel AlgebraicNumber -> List Kernel AlgebraicNumber
- isSqrt: AlgebraicNumber -> Union(AlgebraicNumber, failed)
isSqrt(x)returnszif 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,zis 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)istrueifxhas a “simpler” structure thany. We neglect the denominator (which is supposed to be an integer). It istrueifxandyare integers andx<y;trueifxis an integer andya polynomial;falseifyis an integer andxa polynomial;trueifxhas less variables thany;falseifyhas less variables thanx;falseifx(ory) has more than 1 term;trueifxhas less variables thany;falseifyhas less variables thanx; nx<ny ifxandyaren-th root expression and nx~=ny; simpler?(argument(x),argument(y)).
- simplifyRadicals: AlgebraicNumber -> AlgebraicNumber
simplifyRadicals(x)applies recursiveRootSimplification toxand some other transformations to make the radical more “canonical”.
- sqrtArgument: Kernel AlgebraicNumber -> Integer
sqrtArgument(k)returnszifkis nthRoot(z,2) for some integerzand 0 if that is not the case.
- sqrtSum: AlgebraicNumber -> List List Integer
sqrtSum(x)returns a list of pairs [ai,ci] ifxis of the form $sum_{i=1}^nci*sqrt(ai)$ withci~=0and ai<aj if i<j. We expect the denominator to be an integer and only consider the numerator. The returned list is empty, ifxis not of the above form, it is [[numer(x),1]] ifxis rational.
- sqrtSumArguments: AlgebraicNumber -> List Integer
sqrtSumArguments(x)returns a list of theaiifxis of the form $sum_{i=1}^nci*sqrt(ai)$ withci~=0, (ai=1for at most onei) and ai<aj if i<j. We expect the denominator to be an integer and only consider the numerator. The returned list is empty, ifxis not of the above form, it is [1] ifxis rational.