Help page for sqrt

alec's picture

I'd like to see the following examples in the help page for sqrt,

sqrt(149^3);

                        149*sqrt(149);

sqrt(151^3);

                        sqrt(3442951);

Alec

Robert Israel's picture

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);

 

alec's picture

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

JacquesC's picture

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}