About sqrt_exact...

marco.bodrato at tutanota.com marco.bodrato at tutanota.com
Thu Jun 25 10:34:31 CEST 2026


Ciao Paul,

24 giu 2026, 17:39 da Paul.Zimmermann at inria.fr:

>> I have to say that in MPFR I tried to implement Newton's method for
>>  1/sqrt(x),
>>  which is theoretically faster than mpn_sqrtrem, by implementing
>>  Algorithm
>>  ApproximateRecSquareRoot from Modern Computer Arithmetic, but I failed
>>  miserably.
>>

By the way, the 2-adic implementation is working smoothly.
But it is faster than mpn_sqrtrem only for small sizes.

I just added the use of Halley's method, for tiny sizes, with a further small speed up.
https://gmplib.org/repo/gmp/rev/255cfe47703a

And I also experimented the use of mulmid, with no gain at all.
https://gmplib.org/repo/gmp/rev/2a809d700679


> the result was correct, so that I did not have to bother the authors of
> the book, but it was slower than using mpn_sqrtrem.
>
With no mulhi, and your experience, I think I'll not even try to implement
the function for 1/sqrt(x). :-)
Ĝis,m

--
DC: https://vado.li/dc-bodrato


More information about the gmp-devel mailing list