NaN - Function Definition

Function Definition

There are differences of opinion about the proper definition for the result of a numeric function that receives a quiet NaN as input. One view is that the NaN should propagate to the output of the function in all cases to propagate the indication of an error. Another view, and the one taken by the IEEE standard in general, is that if the function has multiple arguments and the output is uniquely determined by all the non-NaN inputs including infinity, then that value should be the result. Thus for example the value returned by hypot(±∞, qNaN) and hypot(qNaN, ±∞) is +∞.

The problem is particularly acute for the exponentiation function pow(x,y) = x ** y. The expressions 00, ∞0 and 1∞ are considered indeterminate forms when they occur as limits (just like ∞ × 0), and the question of whether zero to the zero power should be defined as 1 has divided opinion.

If the output is considered as undefined if a parameter is undefined then pow(1,qNaN) should produce a qNaN. However typically math libraries have returned 1 for pow(1,y) for any real number y, and even if y is infinity or -infinity. Similarly they produce 1 for pow(x,0) even when x is 0 or infinity. The rationale for returning the value 1 for the indeterminate forms was that the value of functions at singular points can be taken as a particular value if that value is in the limit the value for all but a vanishingly small part of a ball around the limit value of the parameters. The 2008 version of the IEEE 754 standard says that pow(1,qNaN) and pow(qNaN,0) should both return 1 since they return 1 whatever else is used instead of quiet NaN.

To satisfy those wishing a more strict interpretation of how the power function should act, the 2008 standard defines two additional power functions; pown(x, n) where the exponent must be an integer, and powr(x, y) which returns a NaN whenever a parameter is a NaN or the exponentiation would give an indeterminate form.

Read more about this topic:  NaN

Famous quotes containing the words function and/or definition:

    The intension of a proposition comprises whatever the proposition entails: and it includes nothing else.... The connotation or intension of a function comprises all that attribution of this predicate to anything entails as also predicable to that thing.
    Clarence Lewis (1883–1964)

    One definition of man is “an intelligence served by organs.”
    Ralph Waldo Emerson (1803–1882)