erroneous claim at sources.redhat.com/gsl/ref/gsl-ref_4.html#SEC3 2

Achim Gädke achim@element.fkp.physik.tu-darmstadt.de
Tue Jul 15 11:36:00 GMT 2003


Hi!

I could not believe that, but it's true and a nice logic training:

x2=x*x;
x3=x2*x;
x5=x3*x2;
x15=x5*x5*x5;
with 5 * symbols

instead of:

x2=x*x;
x4=x2*x2;
x8=x4*x4;
x15=x8*x4*x2*x;
here: 6 * symbols.

Keith, do you have a simple approach to the more efficient algorithm, that 
seems to base on a factorization ( 15=5*3 ).

Achim

On Tue, 15 Jul 2003 keith.briggs@bt.com wrote:

> > Function: double gsl_pow_int (double x, int n) 
> 	>This routine computes the power x^n for integer n. The power is
> computed using the minimum number of multiplications. 
> A glance at the source code shows that this is wrong.   It uses repeated
> squaring, so, for example, x^15 is computed
> with 6 multiplies, whereas it can be done with 5.
> Keith
> 



More information about the Gsl-discuss mailing list