Ruud H.G. van Tol on Wed, 29 Nov 2023 23:03:39 +0100


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

Re: log_int_rat



On 2023-11-29 22:41, Ruud H.G. van Tol wrote:
On 2023-11-29 22:15, Ruud H.G. van Tol wrote:
[...]

I was surprised by this performance difference:

? localbitprec(10000); my(L = 1-log(2)/log(3)); [ 1 + floor(n/L) |n<-[0..10^5] ];
cpu time = 1,061 ms, real time = 1,064 ms.

? localbitprec(10000); my(L = log(2)/log(3/2)); [ 1 + n + floor(n*L) |n<-[0..10^5] ];
cpu time = 80 ms, real time = 82 ms.

What would explain that?


Unlooping the division, does the trick:

? localbitprec(10000); my(L = 1/(1-log(2)/log(3))); [ 1 + floor(n*L) |n<-[0..10^5] ];
cpu time = 81 ms, real time = 82 ms.

-- Ruud