iroot - Maple Help

isqrt

integer square root

iroot

integer n^th root

 Calling Sequence isqrt(x) iroot(x, n, 'exact')

Parameters

 x - integer n - integer exact - (optional) name

Description

 • The isqrt function computes an integer approximation to the square root of x. The approximation is exact for perfect squares, and the error is less than 1 otherwise. Note: if $x<0$, isqrt(x) returns 0.
 • The iroot function computes an integer approximation to the n^th root of x. The approximation is exact for perfect powers, and the error is less than 1 otherwise. If the optional third argument is given, it is set to true or false to show whether the root is exact or not. Note: if $x<0$, and n is even, iroot(x, n) returns 0; if $x<0$, and n is odd, iroot(x, n) returns - iroot(- x, n).

 • The isqrt command is thread-safe as of Maple 15.

Examples

 > $\mathrm{isqrt}\left(4\right)$
 ${2}$ (1)
 > $\mathrm{isqrt}\left(5\right)$
 ${2}$ (2)
 > $\mathrm{isqrt}\left(8\right)$
 ${3}$ (3)
 > $\mathrm{isqrt}\left(10\right)$
 ${3}$ (4)
 > $\mathrm{iroot}\left(100,3\right)$
 ${5}$ (5)
 > $\mathrm{iroot}\left(10,2,'\mathrm{exact}'\right);$$\mathrm{exact}$
 ${3}$
 ${\mathrm{false}}$ (6)
 > $\mathrm{iroot}\left(50653,3,'\mathrm{exact}'\right);$$\mathrm{exact}$
 ${37}$
 ${\mathrm{true}}$ (7)
 > $\mathrm{iroot}\left(200,8\right)$
 ${2}$ (8)

If x<0, isqrt(x) returns 0.

 > $\mathrm{isqrt}\left(-4\right)$
 ${0}$ (9)

The iroot command will calculate odd roots of negative numbers.

 > $\mathrm{iroot}\left(-27,3,'\mathrm{exact}'\right);$$\mathrm{exact}$
 ${-3}$
 ${\mathrm{true}}$ (10)
 > $\mathrm{iroot}\left(-500,5,'\mathrm{exact}'\right);$$\mathrm{exact}$
 ${-3}$
 ${\mathrm{false}}$ (11)