Karim Belabas on Mon, 22 Oct 2012 22:36:20 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: exp is faster the second time round


* Karim Belabas [2012-10-22 22:31]:
> * Dirk Laurie [2012-10-22 22:19]:
> > With \p 1000000, it takes about a minute to compute exp
> > on my laptop.  Immediate afterwards, it takes about 30 seconds.
> > 
> > Obviously some constants are being memoized.  Which
> > constants are these?
> 
> log(2)     
> 
> Since exp(x - k log(2)) = x / 2^k, argument reduction allows us to
> assume that |x| <= log(2)/2

And Pi as well. In this range, we compute exp() via log() + Newton,
and compute log itself via an AGM that requires Pi  
[ Pi / 2AGM(1, 4/Q) ~ log Q for large Q ]].

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`