John, Thank you for the patient and thorough explanation. I think I understand what you are saying, and I see how people who can specify their arithmetic operations precisely might get good mileage from +/-0.
I don't see a reasonable way to modify J do that, but like you I don't see it as a major deficiency. Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of John Randall > Sent: Wednesday, April 25, 2007 7:24 PM > To: General forum > Subject: RE: [Jgeneral] zero > > Henry Rich wrote: > > > > My puzzlement is: -0 is such a tiny sliver of the number > > range. How can the treatment of -0 in the language/hardware > > be the thing that makes code robust or not? > > Of course it does not make the code more robust: the aim is to plug > the obvious leaks. The +/-0 issue is particularly important in > libraries for elementaray functions. For example > > - Complex square root (conventionally) has a branch cut on the > negative real axis, and it is discontinuous as you cross it. > > - Forgetting about the complex numbers, the same thing happens with > real functions. They are conventionally evaluated by argument > reduction. For example, with tangent, you could reduce to > (-pi/2,pi/2). For a value of x close to a multiple of pi/2, it > matters a lot which side it is on. > > - In general, anything subject to argument reduction has the same > problem. > > Much of the issue comes from misinterpretations of inverse functions. > A function f:A->B has an inverse if and only if f is 1-1 and onto. > Most functions are not, so we choose (conventionally and somewhat > arbitrarily) a subset C of A on which f is 1-1. Then we let > g:C->f(C) be the restriction of f. Now g is invertible, and we call > its inverse the "inverse" of f. In general, g is only a one-sided > inverse, and it depends on the choice of C. > > For example, if f:R->R is given by f(x)=x^2, we choose C={x>:0}=f(C), > and g:C->f(C) has square root as its inverse. > > > > For example: you say you want sqrt(_1j_0) = 0j_1, but > > sqrt (_1j+0) = 0j1 . OK. But what is sqrt(_0.5j_0 + _0.5j+0)? > > > This is not intended to be an extension of arithmetic. You cannot > consistently extend real arithmetic by adding +/-0, _, etc. The only > real division algebras are the real numbers, the complex numbers, the > quaternions (which are not commutative) and the Cayley numbers (which > are not associative). It is intended rather to give a representation > of one-sided limits. > > > Are the computations carefully arranged so that numbers > > that are known to approach close to 0 are allowed as > > operands only to a restricted set of functions that are > > known not to push them over the boundary? > > > In a word, yes. One of the key problems is solving boundary value > problems, where you have a region on which a differential equation > holds, and some condition on the solution on the boundary. For a > 2-dimensional region, you can transform it so that the boundary is the > y-axis and the equation holds on the right half-plane. Now you can > assume x>0, and you are interested in the limit as x->0. The equation > may not even make sense for x<0, or x=0 and even if it does, the > solution may not be continuous across the boundary. The presence of > +/-0 allows the expression of these one-sided limits > > If you think this is an abstruse application, most uses of complex > numbers and floating-point arithmetic (at least in terms of CPU > cycles) are for generalization this type of problem. It is why > Fortran had complex and floating-point arithmetic from very early on. > > > > > > Changing the subject slightly: my mastery of complex > > variables could be charitably described as skeletal, but > > my understanding is that the branch cut could be anywhere > > in the complex plane; that it is chosen for convenience, > > being a way to treat the four-dimensional Riemann surface > > in three dimensions. > > > I would say that the branch cut is equivalent to the selection of the > principal domain C described above. > > > If that's not off base, then the choice of the negative > > real axis for the branch cut is just an arbitrary programming > > decision. Wherever you put the branch cut, you should expect > > to have trouble that you will have to program around. Hoping that > > hardware support for -0 will bail you out of that trouble seems > > like wishful thinking to me: prone to disaster if you step > > over the line, and kludgy even if you get it to work somehow. > > You're right. It's probably better to think of local inverses. > However, most people don't want to use, say, the inverse of f(x)=x^2 > on the interval [_2,_1], they just want %: . Hardware support > ultimately does not replace thinking. > > > > > I'm thinking this is what Pepe meant when he said > > "This is like deja vu all over again." > > > And he's right. > > > > If people are really finding -0 to be the solution to real > > problems, I'd like to understand better how they arrange their > > processing to be sure they get good results. > > > > I hope I have given some kind of rationale: -/+0 are important for > expressing one-sided limits, a frequent consideration in some > important problems. If you are not involved with these problems, it > may seem unnecessary, slipshod, etc. I do not think there is anything > wrong with the way J handles it (by ignoring it). For the specialized > community which does a lot of floating-point calculations, it matters > more. > > Best wishes, > > John > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
