help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: approximatino non trancedental numbers


From: Jordi Gutiérrez Hermoso
Subject: Re: approximatino non trancedental numbers
Date: Tue, 16 Oct 2007 11:39:41 -0500

On 16/10/2007, Willem Hendriks <address@hidden> wrote:
> What methods / algorithms does octave use when i type:
>
> 34.25^(0.3) for instance?
>
> does it create an polynomial and find it roots?

Wow, you get a prize for coming up with the worst possible method for
for implementing the power operator. :-)

No, seriously, like Herr Bateman said, the implementation is in the
GNU C library, on which Octave depends. The actual implementation of
the function is system dependent, so it depends on the platform for
which Octave is compiled (the libc6 Makefiles will choose the right
implementation at compile time). After digging around a little, I
found e.g. the following description, from the
sysdeps/ieee754/ldbl-128/e_powl.c file in the glibc6 source tree:


/* __ieee754_powl(x,y) return x**y
 *
 *                    n
 * Method:  Let x =  2   * (1+f)
 *      1. Compute and return log2(x) in two pieces:
 *              log2(x) = w1 + w2,
 *         where w1 has 113-53 = 60 bit trailing zeros.
 *      2. Perform y*log2(x) = n+y' by simulating muti-precision
 *         arithmetic, where |y'|<=0.5.
 *      3. Return x**y = 2**n*exp(y'*log2)
 *
 * Special cases:
 *      1.  (anything) ** 0  is 1
 *      2.  (anything) ** 1  is itself
 *      3.  (anything) ** NAN is NAN
 *      4.  NAN ** (anything except 0) is NAN
 *      5.  +-(|x| > 1) **  +INF is +INF
 *      6.  +-(|x| > 1) **  -INF is +0
 *      7.  +-(|x| < 1) **  +INF is +0
 *      8.  +-(|x| < 1) **  -INF is +INF
 *      9.  +-1         ** +-INF is NAN
 *      10. +0 ** (+anything except 0, NAN)               is +0
 *      11. -0 ** (+anything except 0, NAN, odd integer)  is +0
 *      12. +0 ** (-anything except 0, NAN)               is +INF
 *      13. -0 ** (-anything except 0, NAN, odd integer)  is +INF
 *      14. -0 ** (odd integer) = -( +0 ** (odd integer) )
 *      15. +INF ** (+anything except 0,NAN) is +INF
 *      16. +INF ** (-anything except 0,NAN) is +0
 *      17. -INF ** (anything)  = -0 ** (-anything)
 *      18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
 *      19. (-anything except 0 and inf) ** (non-integer) is NAN
 *
 */

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]