intfact.spad line 201 [edit on github]
The IntegerRoots package computes square roots and n
th roots of integers efficiently.
approxRoot(n, r)
returns an approximation x
to n^(1/r)
such that -1 < x - n^(1/r) < 1
approxSqrt(n)
returns an approximation x
to sqrt(n)
such that -1 < x - sqrt(n) < 1
. Returns 0 if n
is negative. A variable precision Newton iteration is used. The running time is O( log(n)^2 )
.
perfectNthPower?(n, r)
returns true
if n
is an r
th power and false
otherwise
perfectNthRoot(n)
returns [x, r]
, where n = x^r
and r
is the largest integer such that n
is a perfect r
th power
perfectNthRoot(n, r)
returns the r
th root of n
if n
is an r
th power and returns "failed" otherwise
perfectSqrt(n)
returns the square root of n
if n
is a perfect square and returns "failed" otherwise
perfectSquare?(n)
returns true
if n
is a perfect square and false
otherwise