I think that J's tolerant comparison does a fine job under most circumstances, and that it is unreasonable to expect it to do everything.
Mathematical = on the reals is an equivalence relation, and is also translation invariant. J's tolerant = (roughly) compares the relative error in approximating x by y with some tolerance. This is not an equivalence relation (it fails to be transitive) and it is not translation invariant. It necessarily is going to give strange answers near 0. Away from 0, it is an open relation in the sense that for each x, and for all y sufficiently close to x, then x = y. If you want a translation invariant tolerant equals, you need the absolute error in approximating x by y with some tolerance. This is open, well-behaved near zero, but not an equivalence relation. Any equivalence relation R is equivalent to a function f such that x R y if and only if (f x)!.0 (f y). A sensible choice is the "snap to grid" function f=:[: <. epsilon %~ ] for some epsilon. This, however, is neither open nor translation invariant. It is an easy exercise to show that any open equivalence relation on the reals has a single equivalence class, that is, x R y for all x and y. When deciding what it means for two floating point numbers to be equal, you have to think what properties you want to have, and you can't have everything. J's definition is a sensible default. Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
