On Aug 16, 2016, at 1:45 PM, Anton Shterenlikht <[log in to unmask]> wrote:
>> "A result of type complex is the principal value
>> with the real part greater than or equal to zero."
>
> Sorry I missed that.
>
> I read a bit more. I note that Sec. 1.6.5 [27:14-16]
> says that f2008 differs from f95 when the processor
> distinguishes between positive and negative zero.
> Perhaps some vendors provide switches to use f95 or f08 behaviour.
> Perhaps this explains my different results with different compilers.
>
> However...
>
> I might be completely wrong, but I understand that
> the whole point of having +0 and -0
> is that the branch cut is now "between" +pi and -pi.
> Hence the description of LOG(X), Sec. 13.9.118 [394:32],
> now has "...the principal value with imaginary part omega
> in the range -pi <= omega <= pi."
> There is the equality sign on both sides.
> The ability to distinguish -pi from +pi comes from
> the ability to distinguish +0 and -0.
Good point. The math types might cringe at including -pi (or at the concept of -0.0). And, of course, a FP value “equal” to pi is nonsense anyway. However, if you try the SQRT test with a limit approach, then it is more clear why the rule is the way stated:
> cat test.f90
do i = 9, 0, -1
print *, sqrt(cmplx(-4.0, -4.0*i*epsilon(0.0)))
end do
print *, sqrt( (-4.0, -0.0) )
end
> ./a.out
(1.0728836E-06,-2.000000)
(9.5367432E-07,-2.000000)
(8.3446503E-07,-2.000000)
(7.1525574E-07,-2.000000)
(5.9604645E-07,-2.000000)
(4.7683716E-07,-2.000000)
(3.5762787E-07,-2.000000)
(2.3841858E-07,-2.000000)
(1.1920929E-07,-2.000000)
(0.0000000E+00,-2.000000)
(0.0000000E+00,-2.000000)
You would like to have the last 2 lines of output be the same.
Cheers,
Bill
>
> So when the processor can distinguish +0 and -0,
> then the imaginary part of
> log( cmplx( -4.0, -0.0 ) ) must be -pi (approx.)
> and the imaginary part of
> log( cmplx( -4.0, 0.0 ) ) must be pi (approx.)
> both being the *principal* values.
>
> So I wonder whether in the presence of +0 and -0
> both branches of SQRT become principal.
>
> Am I completely wrong?
>
> Perhaps I need to read IEEE 754 to better
> understand the consequences of +0 and -0.
>
> Anton
Bill Long [log in to unmask]
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
|