pete wrote:

>

> John Smith wrote:

> >

> > In a C program I need to do exponentiation where the base is

> > negative and the exponent is a fraction. In standard C this would

> > be something like t = pow(-11.5, .333), but with this combination

> > of arguments there is a domain error and the result is a

> > percolating NaN.
[...]

> > Is there any particular reason for this limitation in the

> > standard library function? Has anyone else had a problem with

> > this and found a better solution?
It's not a "limitation in the standard library function", but rather

a "limitation" of math itself. You cannot express the fractional power

of a negative number as a real number in the general case.

> -11.5 has a third root which is negative,

> if that's what you're really trying to find.
Of course, a power of ".333" is _not_ a third root, as ".333" is only

_close_ to 1/3. (For large enough values of "close".)

> However, if you consider that

> a negative number raised to an even integer power, is positive,

> and that

> a negative number raised to an odd integer power, is negative,

> then it just seems natural that

> the sign of a negative number raised to a non integer,

> should be undefined.
Now, his solution of negating the number, and again negating the result,

does "work" for odd integral roots and odd integral powers, but not in

the general case.

[...]

--

+-------------------------+--------------------+-----------------------------+

| Kenneth J. Brody |

www.hvcomputer.com | |

| kenbrody/at\spamcop.net |

www.fptech.com | #include <std_disclaimer.h> |

+-------------------------+--------------------+-----------------------------+

Don't e-mail me at: <(E-Mail Removed)>