Charles Greathouse on Wed, 24 Jan 2024 17:17:46 +0100


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

Re: log_int_rat


I'm sure it could be made much faster by using an approximation of the power of 3 and tracking the error carefully. I'd need to brush up on my numerical analysis.

On Wed, Jan 24, 2024 at 11:08 AM Ruud H.G. van Tol <rvtol@isolution.nl> wrote:

On 2024-01-24 15:39, Charles Greathouse wrote:
> You can make it faster by storing only the exponent.
>
> first(n)=my(a=-1,b=1,r=-1); vector(n, i, a+=2; b*=3; if(b>>a, , a++;
> b*=3; r++); 2*i+r)
>
> On my system this is about twice as fast.

Hello Charles, thanks!

   first(2^17);

took 609ms here, and

   alist(2^17);

took 1013 ms.

-- Ruud