isqrt -- integer square root
Introductionisqrt(n) computes an integer approximation
to the square root of the integer n.
Call(s)isqrt(n)
Parametersn |
- | an arithmetical expression representing an integer |
Returnsa nonnegative integer, an integral
multiple of I, or a symbolic
isqrt call.
n
Related
Functions_power, icontent, ifactor, igcd, ilcm, numlib::ispower, numlib::issqr, sqrt, trunc
Detailsn is a perfect square, then isqrt
returns the unique nonnegative integer whose square is n.
More generally, if n is a nonnegative integer, then isqrt computes trunc(sqrt(n)). Thus the approximation error is less
than 1.n is a negative integer, then isqrt
computes trunc(sqrt(-n))*I.isqrt returns an error message if its argument is a
number but not an integer. isqrt
returns a symbolic isqrt call if the argument is not a number.isqrt is a function of the system kernel.
Example
1We compute some integer square roots:
>> isqrt(4), isqrt(5)
2, 2
The approximation error is less than 1:
>> isqrt(99), float(sqrt(99))
9, 9.949874371
The integer square root of a negative integer is an
integral multiple of I:
>> isqrt(-4), isqrt(-5)
2 I, 2 I
If the argument is not a number, the result is a
symbolic isqrt call:
>> delete n: isqrt(n)
isqrt(n)
>> type(%)
"isqrt"