## `isqrt` -- integer square root

#### Introduction

`isqrt(`n`)` computes an integer approximation to the square root of the integer `n`.

#### Call(s)

`isqrt(n)`

#### Parameters

`n` | - | an arithmetical expression representing an integer

#### Returns

a nonnegative integer, an integral multiple of `I`, or a symbolic `isqrt` call.

### Overloadable:

`n`

#### Related Functions

`_power`, `icontent`, `ifactor`, `igcd`, `ilcm`, `numlib::ispower`, `numlib::issqr`, `sqrt`, `trunc`

#### Details

- If `n` 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`.
- If `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 1

We 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"

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000