[Numeric-interest] rsqrt(-0) and rsqrt(-inf)
Douglas Priest
priest at mailhost.sfbay.sun.com
Wed Feb 21 16:27:15 PST 2007
A number of math libraries now include a reciprocal square root
function, rsqrt, such that rsqrt(x) delivers an approximation to
x^(-1/2). Some implementations, including HP's and IBM's, have
chosen to define rsqrt so that
rsqrt(-0) delivers -inf and raises division-by-zero
and
rsqrt(-inf) delivers NaN and raises invalid operation.
These choices are consistent with the interpretation that rsqrt(x)
is a substitute for the expression "1.0/sqrt(x)", but since the
actual rsqrt functions generally do not deliver the exact same
values as 1.0/sqrt(x) computed by a correctly rounded square root
followed by a correctly rounded divide, there is no reason a priori
why we must make this interpretation. We could, for example, say
that rsqrt(x) is a substitute for the expression "sqrt(1.0/x)",
which would lead us to choose
rsqrt(-0) delivers NaN and raises invalid operation
and
rsqrt(-inf) delivers -0 and raises no exception
instead.
Does anyone know of any examples of software that could benefit from
a particular choice of result for either rsqrt(-0) or rsqrt(-inf)?
I am not asking for consistency arguments or educated guesses, just
real programs in which the "right" definition would make things simpler
or the "wrong" one make them more complicated.
Thank you,
Doug Priest
More information about the Numeric-interest
mailing list