IntegerRoots IΒΆ

intfact.spad line 202

The IntegerRoots package computes square roots and nth roots of integers efficiently.

approxNthRoot: (I, NonNegativeInteger) -> I
approxRoot(n, r) returns an approximation x to n^(1/r) such that -1 < x - n^(1/r) < 1
approxSqrt: I -> I
approxSqrt(n) returns an approximation x to sqrt(n) such that -1 < x - sqrt(n) < 1. A variable precision Newton iteration is used. The running time is O( log(n)^2 ).
perfectNthPower?: (I, NonNegativeInteger) -> Boolean
perfectNthPower?(n, r) returns true if n is an rth power and false otherwise
perfectNthRoot: (I, NonNegativeInteger) -> Union(I, failed)
perfectNthRoot(n, r) returns the rth root of n if n is an rth power and returns “failed” otherwise
perfectNthRoot: I -> Record(base: I, exponent: NonNegativeInteger)
perfectNthRoot(n) returns [x, r], where n = x\^r and r is the largest integer such that n is a perfect rth power
perfectSqrt: I -> Union(I, failed)
perfectSqrt(n) returns the square root of n if n is a perfect square and returns “failed” otherwise
perfectSquare?: I -> Boolean
perfectSquare?(n) returns true if n is a perfect square and false otherwise