Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Motion 45



On 2013-08-03 13:00:15 +0200, John Pryce wrote:
> There is another quirk of 754 that annoys me but we can't do
> anything about it. In the reduction operation clause §9.4, it says
> that for sumAbs and sumSquare, Inf "beats" NaN. E.g. sumAbs of the
> vector (1,Inf,NaN) is Inf, not NaN.
> 
> I presume this derives from an interpretation of NaN as "an
> extended-real number that happens to be unknown", which conflicts
> with the interpretation I believe appropriate in 1788 for both NaN
> and NaI, namely "something went wrong earlier!".

Well, it isn't even obvious to differentiate these two interpretations.
For instance, consider:

  sumAbs(1,Inf,sqrt(a*a-b*b))

evaluated with a = b. For some reason (e.g. the use of a FMA),
a*a-b*b may evaluate to a negative number instead of 0. So, sqrt will
be applied on a negative number, and give NaN. And the result Inf
for sumAbs makes sense. Now, do you consider the NaN obtained by
sqrt(negative) as "an extended-real number that happens to be unknown"
or just that "something went wrong"?

What I want to say is that in floating-point arithmetic, if a function
is evaluated on a point that is not in its definition domain, this can
mean that the cause is rounding errors, but in the reality (Level 1),
the result is well-defined. From this point of view, if the programmer
writes only expressions that are well-defined at Level 1, a NaN
necessarily means a number that happens to be unknown.

Note that for interval arithmetic, with what has been chosen in P1788
(e.g. sqrt([-1,4]) = [0,2], that is, not an error), the above problem
cannot occur. And if a NaI or more generally an empty interval is
obtained, this necessarily means that the expression isn't defined
at Level 1 (i.e. one can make a distinction between "undefined" and
"possibly undefined", but such kind of distinction is not possible
in IEEE 754, possibly except by the use of signalling NaN's).

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)