Calculating Square Roots
What is a square root?
In its most simple form, a square root is a number times itself that yields a given number, known as its argument. In computer science, the square root function is typically denoted as sqrt(x), where x is the argument.
Some arguments yield rational numbers. For example, consider sqrt(4). The result of this calculation is 2 which is an integer and, by extension, a rational number, which makes its usage in various calculations quite easy.
However, consider a calculation like sqrt(11). What number times itself equals 11? Well the answer isn't very simple. The square root of 11 is what is known as an irrational number, a decimal that repeats forever with no pattern. How, then, can we evaluate a calculation such as sqrt(11)? The short answer is that we can't. However, throughout history, great mathematicians like Isaac Newton have devised methods to generate approximations of these unfathomable values.
How Cygnus/X Approximates Square Roots
Cygnus/X calculates square roots using a rather simple version of Newton's method. The implementation of the method can be broken down into a few steps:
- Generate an integer approximation of the square root, known as x
- Improve the accuracy of x by letting it equal x-(f(x)/f'(x))
- Repeat step 2 until the desired level of precision is achieved.
*In this case, f(x) = x2 + 3 and f'(x) = 2x
A similar method was implemented by NASA on a VAX alpha-class machine in 1994 and used to estimate the irrational square roots up to sqrt(10) out to over a million digits. However, as far as anyone knows, no one has bothered the calculate irrational roots beyond sqrt(10) to similar precision. And for good reason.
Why don't more people approximate square roots?
For one thing, a rather quick CPU and a lot of memory are required to undergo the necessary calculations. This kind of computing puts the CPU through heavy stress and generates a lot of heat, and most people who own capable systems aren't willing to put them through that. Also, a certain understanding of both calculus and programming is required.
However, probably the most important reason that people don't perform these type of calculations is that square root approximations of infinitesimal precision are not necessary. It has been said of the constant π that only 39 decimal places are required to represent the location of every atom in the universe; presumably, the same holds true with square roots. And modern pocket calculators can give useful approximations in the order of tens of digits.
Then why bother?
Well, in my humble opinion, there are a few reasons why calculating square roots is worth the time.
- It's fascinating
This is, of course, a moot point as different things fascinate different people. But there's something truly unique about seeing strings of digits that no one has ever seen before and realizing that these digits have been hidden in the everyday world around you all along, just waiting to be discovered.
- You view the world a little differently than everyone else
It helps you to appreciate the world a little more, how the infinite is interwoven with the finite in an amazing pattern which I think warrants the presence of a Creator.
There are probably more reasons, if I think of more I'll put them here.
100,000 decimal places
200,000 decimal places
500,000 decimal places
1,000,000 decimal places
2,000,000 decimal places
5,000,000 decimal places
10,000,000 decimal places
More coming soon...
Can I use these digits?
Of course! There's no copyright placed on these digits and it doesn't seem like it would be right to place one on them. They already exist in nature; I've merely discovered and uploaded them.
So feel free to use the digits kept here in any way you wish. And since irrational numbers appear to have no correlation, their digits have plenty of applications.
In case you're wondering, the machines I use to perform these calculations aren't anything particularly special. Here are their specs, sorted by which approximates quickest:
(Surprisingly) Running Windows, orion is the best at approximating roots. It is a custom-built mid-tower machine with a liquid-cooled Intel Core i5-3750K overclocked to 4.6 GHz. I didn't build it to crunch numbers, but it's surprisingly good at the task.
cygnus-x (Dell Optiplex 960)
The server that hosts this site comes in second. It's running Linux, and has an Intel Core 2 Duo E8400 running at 3.0 GHz. It has calculated many of the 100 and 200k entries, and continues to perform well.
mitchs1 (Linux VPS)
This hosted Linux VPS (I don't own it) comes in third. It has 4 QEMU virtual CPUs running at 2 GHz apiece. However, the calcsqrt method I have is single-threaded and cannot be multithreaded, so it only takes advantage of one processor at a time.
arcturus (HP Compaq nx7400)
My dev laptop logically comes in last. It's running Linux and has an Intel Core 2 T5600 running at 1.83 GHz. At one point it was an expensive business class machine, but it's getting old now.
Where can I get the code and do this myself?
Although it goes against the general custom here, I'm actually not going to provide the code for this one. Not because it's particularly difficult to write, but because I want to encourage you to follow in the footsteps of Newton and other great mathematicians and develop your own method. Who knows, maybe yours will become the method for the future...
Questions? Comments? Click here to drop me a line. I'm open to criticism and happy to help you troubleshoot.