Bill Allombert on Sat, 16 Dec 2023 17:26:29 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Powers too slow? |
On Thu, Dec 14, 2023 at 08:12:22PM -0800, Ilya Zakharevich wrote: > On Thu, Dec 14, 2023 at 06:40:37PM -0800, Ilya Zakharevich wrote: > > It seems that some powers take 2x the time they should take: > > > > (18:31) gp > localprec(1111111); 1111111^(31/10); > > time = 453 ms. > > (18:31) gp > localprec(1111111); 1111111.^(1/10)*1111111^3; > > time = 234 ms. > > Oups, this mixes integers and floating point bases! However, with pure > integer bases this only becomes slightly more pronounced. ? localprec(1111111); (1111111^(31/10)) *** _^_: Warning: increasing stack size to 16000000. time = 197 ms. %5 = 5518843593084694525.5922480458188863341 ? localprec(1111111); (1111111^(1/10))^31 *** _^_: Warning: increasing stack size to 16000000. time = 202 ms. %6 = 5518843593084694525.5922480458188863341 ? localprec(1111111); (1111111^(1/10))*(1111111^3) *** _^_: Warning: increasing stack size to 16000000. time = 122 ms. %7 = 5518843593084694525.5922480458188863341 So maybe we could change powfrac to use %6 instead of %7, assuming the base is much smaller than the precision, because otherwise this is slower: ? A=(10^1111111-1)/9; time = 17 ms. ? localprec(11); A^(31/10) %10 = 1.3862712636533488637941870000827053413E3444441 *** last result computed in 0 ms. ? localprec(11); A^(1/10)*A^3 time = 50 ms. %11 = 1.3862712636533488638E3444441 Cheers, Bill.