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: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
)) wheres
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 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 sameb
andd
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 numberx
into a complex floating point representation with the currently set precision.
- integerRootFactor: AlgebraicNumber -> AlgebraicNumber
integerRootFactor(x)
factors any expression inx
of the form nthRoot(z
,n
) wherez
is an integer into the product of nthRoot(f
,n
) for all factorsf
ofz
. 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)
returnsz
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)
istrue
ifx
has a “simpler” structure thany
. We neglect the denominator (which is supposed to be an integer). It istrue
ifx
andy
are integers andx
<y
;true
ifx
is an integer andy
a polynomial;false
ify
is an integer andx
a polynomial;true
ifx
has less variables thany
;false
ify
has less variables thanx
;false
ifx
(ory
) has more than 1 term;true
ifx
has less variables thany
;false
ify
has less variables thanx
; nx<ny ifx
andy
aren
-th root expression and nx~=ny; simpler?(argument(x
),argument(y
)).
- simplifyRadicals: AlgebraicNumber -> AlgebraicNumber
simplifyRadicals(x)
applies recursiveRootSimplification tox
and some other transformations to make the radical more “canonical”.
- sqrtArgument: Kernel AlgebraicNumber -> Integer
sqrtArgument(k)
returnsz
ifk
is nthRoot(z
,2) for some integerz
and 0 if that is not the case.
- sqrtSum: AlgebraicNumber -> List List Integer
sqrtSum(x)
returns a list of pairs [ai
,ci
] ifx
is of the form $sum_{i=1
}^n
ci*sqrt(ai
)$ withci~=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, ifx
is not of the above form, it is [[numer(x
),1]] ifx
is rational.
- sqrtSumArguments: AlgebraicNumber -> List Integer
sqrtSumArguments(x)
returns a list of theai
ifx
is of the form $sum_{i=1
}^n
ci*sqrt(ai
)$ withci~=0
, (ai=1
for 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, ifx
is not of the above form, it is [1] ifx
is rational.