Fortraneers,
I'm wrestling with compiler differences in the way exponentiation
is handled in borderline cases, and I'd like some input from others
on what the reasonable expectations should be.
Exponentiation with integer exponents is defined algebraically
without any need to refer to transcendental functions (how the
exponential result is ultimately calculated is quite aside the
point): x**3 means x*x*x, x**(-2) means 1.0/(x*x) provided
x/=0, and
o it is mathematical convention that x**0 is defined to be 1
for ANY x, including x=0.0 (Whether 0.0**0.0 means anything
is a different question.)
Exponentiation with floating exponents is entirely different.
I have some sympathy with the choice to exclude a common branch
cut x<=0 from the valid domain for x**y. Consider though:
o When y = real(n) for some integer n/=0, x**y is well-defined
(mathematically) for x<0 (and x=0 if y>0), and so then
shouldn't x**y return the result for x**n?
o If one grants the above point, then I see no reason that the
above reasoning wouldn't apply equally well to the case n=0
(i.e., y = 0.0), so that x**0.0 is 1 for any x/=0, but also
that 0.0**0.0 is 1. This last bit is disturbing though
because x**y has no limit as x,y->0.
I have compilers that give either NaN or 1.0 for (-1.0)**2.0,
and either NaN or 1.0 for 0.0**0.0. Comments?
-Neil
--
Neil N. Carlson <[log in to unmask]>
|