Bill Allombert on Mon, 11 Sep 2023 15:59:18 +0200


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

Re: Power (^) function speed depending on argument types


On Mon, Sep 11, 2023 at 03:33:47PM +0200, Denis Simon wrote:
> Hi Karim and Bill,
> 
> An increase of 64 bits ??? 
> I find it a little optimistic.
> I would understand 1 or 2, or up to 14 when I compute 20000 + s
> (because log_2(i) ~= 14 and log_2(s) ~= 0), but not 64.

Alas, PARI t_REAL precision is always a multiple of 64 bits.

Whether this is pessimistic or optimistic is a matter of perspective:
Compare this:

? s=0.;n=20;t=100.;for(i=1,n,s=(s+t)^(1/5));forstep(i=n,1,-1,s=s^5-t);s
%38 = -3.3995948126355403614265653237903756818E64
? s=0.;n=20;t=100;for(i=1,n,s=(s+t)^(1/5));forstep(i=n,1,-1,s=s^5-t);s
%39 = -4.3414201952566371428595921256072201009E-56

%38 is completly wrong while %39 is quite accurate.

Cheers,
Bill