I've discovered that the same way - looking at the sqrt code and trying to improve it for integers - thus far, the code that I wrote works about twice faster (for integers) than current sqrt , but I'd like to have something, say, 10 times faster, and without using compiled code.
Such magic numbers - in this case, it is the product of prime numbers from 2 to 149, should be mentioned on the help pages, I think.
An additional problem with these magic numbers is that their size were set a very very very long time ago. Computers have changed a lot since, but these have not been revisited. Whatever criteria were used for setting these has likely been forgotten, so I guess no one even knows how to go about adapting them to modern hardware capabilities.
Magic number
This comes from the line
h := igcd(y, `sqrt/primes`);
where `sqrt/primes` is the product of primes from 2 to 149.
Try this:
> `sqrt/primes`:= `sqrt/primes`*151;
sqrt(151^3);
Magic numbers in help pages
I've discovered that the same way - looking at the sqrt code and trying to improve it for integers - thus far, the code that I wrote works about twice faster (for integers) than current sqrt , but I'd like to have something, say, 10 times faster, and without using compiled code.
Such magic numbers - in this case, it is the product of prime numbers from 2 to 149, should be mentioned on the help pages, I think.
Alec
Magic numbers
An additional problem with these magic numbers is that their size were set a very very very long time ago. Computers have changed a lot since, but these have not been revisited. Whatever criteria were used for setting these has likely been forgotten, so I guess no one even knows how to go about adapting them to modern hardware capabilities.