Tolerant equality in J is exactly as it is in SHARP APL.
Its current definition is derived after some missteps 
and has been studied by people whose expertise I respect.
Implementations based on it have been in continuous use
since 1977.

It is incorrect to call the exact comparision of 0 an 
"unintended misidentification".  There is nothing unintended 
about it.  It is well-known within SHARP APL circles since 
1977; I had known about it since the same date.  It is not
always spelled out because it is a pretty simple and
direct consequence of the definition.



----- Original Message ----- 
From: "Oleg Kobchenko" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Monday, May 29, 2006 11:58 PM
Subject: RE: [Jprogramming] Equal tolerance fit conjunction -- again

So the difference is in the intent. A pragmatical
aspect of as the linguistical paradigm of J
continuing the analogy of Parts of Speech, Idioms, etc.

1 = 2. Looks like their difference of 1 is huge and
they do not seem to be identifiable. Now let's shift them
together away from zero a little,
   1 =&(+&(2^43)) 2
0
   1 =&(+&(2^44)) 2  NB. Oops, two points with
1                    NB. the same difference became one

   1 -&(+&(2^43)) 2  NB. difference is still the same = 1
_1

The above is an example of unintended identifivation.

Near zero we have the opposite situation, no matter
how close we move to zero or how stringent we make
the tolerance, we fail to identify anything close
with zero itself.

   0 = 2^_44
0
   0 = 2^_84
0
   0 =!.(2^_300) 2^_84
0

This can be called unintended misidentification.

Any such examples can result in rounding
errors in calculations and not necessarily
based on some unusual application requirements.

There are alternative implementations of
relative tolerance. For example in "Safe Comparisons"
section of http://www.lahey.com/float.htm
it also can be:
  x=y if (|x-y)<:(t*|x+y)
Though it does not resolve the problem with zero.
  0=y if (|0-y)<:(t*|0+y)  NB. x=0
  0=y if y<:(t*y)          NB. assume y>0
We get the same problem.


P.S. I stated or implied that either J worked incorrectly or that
any changes needed. The problem is that this topic
has been shrouded by a cloud of mystery and not
described with enough detail in the documentaion.
For example, how to deal with the artifacts of relative
tolerance; other aspects of tolerance -- so called absolute, 
which deseves a better name, maybe uniform tolerance.


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to