1
$\begingroup$

I'm looking for an efficient tool that can help me approximate the square roots of large numbers to the nearest integer. (By large, I'm talking about numbers with several hundred digits.) Other than that, I don't really have any further constraints - it could be online or available as a download. Does anyone know where I could find one?

I've seen methods listed online, but those can get quite tedious after a while. I've also seen algorithms listed online, but I don't have the software needed to run the code and I don't want to spend money on it.

Thanks in advance!

$\endgroup$
  • $\begingroup$ How quickly does it need to work? $\endgroup$ – Mark Dec 31 '16 at 0:26
  • $\begingroup$ I don't really care, to be honest - as long as it's something semi-reasonable. $\endgroup$ – NotAShoeStore Dec 31 '16 at 0:29
  • 2
    $\begingroup$ Try bc. Its sqrt function should do exactly what you want. $\endgroup$ – Rob Arthan Dec 31 '16 at 0:41
2
$\begingroup$

Try gnu bc.

It's a free, arbitrary precision calculator.

There are versions for various operating systems.

For a Windows version, here's a link:

http://gnuwin32.sourceforge.net/packages/bc.htm

$\endgroup$
  • $\begingroup$ Seems to work very well. Was already installed on my Ubuntu distro, and sqrt(5.283*10^(400)) returned 22984777571253544762896494402042951152028698330270828253442904899267\ 65026536638690484532480170934622222009873755304493891106534146892915\ 95196934610411476360351881398226440125266282644932860973368880127.82\ 9 very quickly (well under a second). $\endgroup$ – Mark Dec 31 '16 at 0:47
3
$\begingroup$

If you have access to Maple, the built-in function isqrt does what you want.

Syntax:

y = isqrt(x)

x must be a nonnegative integer, but size is arbitrary (no limit)

y is the closest nonnegative integer to sqrt(x)

From Maple Help:

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.

However Maple isn't free -- far from it, but if you have access rights to a university, you should be able to find a lab which has Maple.

$\endgroup$
  • $\begingroup$ Thanks, but unfortunately, I don't have access to Maple or access rights to a university. $\endgroup$ – NotAShoeStore Dec 31 '16 at 0:32
  • $\begingroup$ @NotAShoeStore For an online calculator you can use the free Wolfram Alpha. Here is for example the nearest integer to the square root of $\lfloor \pi \cdot 10^{500} \rfloor$. $\endgroup$ – dxiv Dec 31 '16 at 1:36
0
$\begingroup$

Try this. http://www.azillionmonkeys.com/qed/sqroot.html

It's free and works fine.

$\endgroup$
  • $\begingroup$ Thanks for the link, but that doesn't seem to approximate to the nearest integer - it only provides a certain amount of digits for large roots. $\endgroup$ – NotAShoeStore Dec 31 '16 at 0:31
  • $\begingroup$ You can always calculate it mechanically :) $\endgroup$ – TripleA Dec 31 '16 at 0:36
  • $\begingroup$ Like I said, that gets a bit tedious after a while - I'm doing this for more than one large number. $\endgroup$ – NotAShoeStore Dec 31 '16 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.