[9] RFR of 8032027: Add BigInteger square root methods
Andrew Haley
aph at redhat.com
Sat Oct 3 09:38:38 UTC 2015
On 02/10/15 21:41, Brian Burkhalter wrote:
> Any suggestions as to the improvement of the approach concerning
> memory use or any other aspect of the algorithm would be
> appreciated, as would be suggestions regarding the test.
This algorithm doesn't look like the best to me because it's got this
slow division in the middle. If we calculate 1/sqrt(x) instead we can
use a version of Newton's iteration which requires no division.
Starting with an approximation y = 1/sqrt(x) using the first few digits,
y = y * (3 - x*y^2)
---------------
2
... and fix it all up with a single iteration of Heron's algorithm at the
end.
But even better is Karatsuba Square Root:
https://hal.inria.fr/inria-00072854/document
I guess it all depends on how much work we think this deserves. In
general the core algorithms in BigInteger are among the best, and it
would be nice to continue this tradition.
Andrew.
More information about the core-libs-dev
mailing list