Skip to content
Prev 26915 / 63434 Next

Friday question: negative zero

Hello everyone
On 1 Sep 2007, at 01:39, Duncan Murdoch wrote:

            
I have been pondering branch cuts and branch points
for some functions which I am implementing.

In this area, it is very important to know whether one has
+0 or -0.

Take the log() function, where it is sometimes
very important to know whether one is just above the
imaginary axis or just below it:



(i).  Small y

 > y <- 1e-100
 > log(-1 +  1i*y)
[1] 0+3.141593i
 > y <- -y
 > log(-1 +  1i*y)
[1] 0-3.141593i


(ii)  Zero y.


 > y <- 0
 > log(-1 +  1i*y)
[1] 0+3.141593i
 > y <- -y
 > log(-1 +  1i*y)
[1] 0+3.141593i
 >


[ie small imaginary jumps have  a discontinuity, infinitesimal jumps  
don't].

This behaviour is undesirable (IMO): one would like log (-1+0i) to be  
different from log(-1-0i).

Tony Plate's example shows that
even though  y<- 0 ;  identical(y, -y) is TRUE,  one has identical(1/ 
y, 1/(-y)) is FALSE,
  so the sign is not discarded.

My complex function does have a branch cut that follows a portion of  
the negative real axis
but the other cuts follow absurdly complicated implicit equations.

At this point
one needs the IEEE requirement that x=x == +0  [ie not -0] for any  
real x; one then finds that
(s-t) and -(t-s) are numerically equal but not necessarily  
indistinguishable.

One of my earlier questions involved branch cuts for the inverse trig  
functions but
(IIRC) the patch I supplied only tested for the imaginary part being  
 >0; would it be
possible to include information about signed zero in these or other  
functions?
--
Robin Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743