(j3.2006) (SC22WG5.5784) edits to clarify SQRT treatment of negative zero, for comments
Anton Shterenlikht
mexas
Wed Aug 24 09:57:09 EDT 2016
>From: Robert Corbett <robert.corbett at oracle.com>
>>
>> and negative zero [394:31-395:3], and SQRT(X)
>> is mathematically equivalent to EXP( 0.5 * LOG(X) ).
>
>They are not mathematically equivalent when X is zero.
>In that case, SQRT(X) is well-defined, but the expression
>EXP( 0.5 * LOG(X) ) is mathematical nonsense, because the
>log of zero is undefined.
The real part of log of zero is well defined - it is minus infinity.
Hence exp( log(x) ) is also well defined - it is zero.
With ieee 754, when infinity is a valid numerical
value, the two expressions are computationally
equivalent too. 3 out of 3 compilers agree with me:
complex :: z
z = cmplx( 0.0, 0.0 )
write (*,*) log( z )
write (*,*) exp( log( z ) )
end
gives:
(-Infinity,0.)
(0.,0.)
Yes, log of zero is not allowed by [394:28-29].
Perhaps this restriction should be relaxed,
e.g. as was suggested in F03/0042:
http://j3-fortran.org/doc/meeting/210/16-006.txt
- for real X, when X is zero, LOG(X) is minus infinity
for both positive and negative zero X.
- for complex X, when X is zero, the real part of LOG(X)
is minus infinity, the imaginary part of LOG(X) is
a processor dependent value between -pi and +pi.
Such addition would help write portable
complex algebra programs for systems supporting ieee 754.
Anton
More information about the J3
mailing list