T
Thomas Lumley
What does the standard guarantee about the accuracy of eg the
trigonometric functions? There is obviously an implementation-dependent
upper bound on the accuracy, since the answer is stored in a double,
but is this bound actually achieved?
First, a simple example
Suppose I want the arc cosine of -1, and use acos(-1.0) to compute it.
The correct answer to 25 hexadecimal digits is
-3.243F6A8885A308D313198A2E. This falls between two exactly
representable doubles, call them A and B. Does the standard guarantee
that I get one of A and B as the answer (or even better, than I get the
one that is closer to the right answer)?
A more difficult example.
Suppose I want sin(exp(100)). The value of exp(100) is not exactly
representable in a double, and in fact, all numbers in the range
exp(100)-pi to exp(100)+pi have the same closest representation as a
double. Does this authorize the implementation to give any answer it
likes (in the interval [-1,1]), or is it required to give a value close
to the sine of the number it uses to represent exp(100)? Requiring the
right answer here would be a lot of work.
Thomas Lumley (thomas at drizzle dot net)
trigonometric functions? There is obviously an implementation-dependent
upper bound on the accuracy, since the answer is stored in a double,
but is this bound actually achieved?
First, a simple example
Suppose I want the arc cosine of -1, and use acos(-1.0) to compute it.
The correct answer to 25 hexadecimal digits is
-3.243F6A8885A308D313198A2E. This falls between two exactly
representable doubles, call them A and B. Does the standard guarantee
that I get one of A and B as the answer (or even better, than I get the
one that is closer to the right answer)?
A more difficult example.
Suppose I want sin(exp(100)). The value of exp(100) is not exactly
representable in a double, and in fact, all numbers in the range
exp(100)-pi to exp(100)+pi have the same closest representation as a
double. Does this authorize the implementation to give any answer it
likes (in the interval [-1,1]), or is it required to give a value close
to the sine of the number it uses to represent exp(100)? Requiring the
right answer here would be a lot of work.
Thomas Lumley (thomas at drizzle dot net)