On 01/13/2015 09:25 PM, Chris Barker - NOAA Federal wrote:
On Jan 13, 2015, at 6:58 PM, Ron Adam
wrote:
maybe we could specify an absolute tolerance near zero, and a relative tolerance elsewhere, both at once. Tricky to document, even if possible.
Doesn't this problem come up at any boundary comparison, and not just zero?
Zero is special because you lose the ability to use a relative tolerance. Everything is huge compared to zero.
After I posted I realised that when you compare anything you subtract what you are comparing to, and if it's equal to zero, then it's equal to what you are comparing to. So testing against zero is fundamental to all comparisons, is this is correct? Wouldn't a relative tolerance be set relative to some value that is *not* zero? And then used when comparing any close values, including zero.
So isn't the issue about any n distance from any floating point number that is less than 1 ulp? I'm still a bit fuzzy on Ulps, but it seems the goal here is to define a tolerance larger than an ulp. This is for the use case where we expect multiple rounding errors -- many more than one ulp,
That's why I think the use case for ulp comparisons is more about assessment of accuracy of algorithms than "did I introduce a big old bug?" or, "is this computed value close enough to what I measured?"
I haven't looked into the finer aspects of ulps myself. It seems to me ulps only matter if the exponent part of two floating point numbers are equal and the value part is within 1 (or a small few) ulps of each other. Then there may be problems determining if they are equal, or one is greater or less than the other. And only if there is no greater tolerance value set. A couple of thoughts come to mind. I'm not sure if they are relevant though. I think for math algorithms that are hard coded in a program, it isn't much of an issue as the author would have a feel for the size of a delta if needed, and output of an appropriate number of significant digits. and can calculate the error range if needed as well. That probably fits most situations and is what is typically done. It seems to me, that automated tracking and/or use of these things may be wanted with equation solvers. The solver would determine the delta and significant digits from it's initial data. That sounds like it could get very complex, but maybe making this easier to do is the point? Cheers, Ron