This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: erroneous claim at sources.redhat.com/gsl/ref/gsl-ref_4.html#SEC32
- From: Achim Gädke <achim at element dot fkp dot physik dot tu-darmstadt dot de>
- To: keith dot briggs at bt dot com
- Cc: gsl-discuss at sources dot redhat dot com
- Date: Tue, 15 Jul 2003 11:19:27 +0200 (CEST)
- Subject: Re: erroneous claim at sources.redhat.com/gsl/ref/gsl-ref_4.html#SEC32
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
>