On Thu, May 10, 2012 at 8:26 AM, Soegtrop, Michael <
michael.soegtrop at intel.com> wrote:
> Dear Barton,
>
> this isn't a problem of the fsin/fcos implementation. For calculating a
> sine function you need a certain absolute precision. E.g. if you want to
> have 2 decimals output precision, your number must have an absolute
> precision of 2 decimals. Floating point numbers have constant relative
> precision. So the larger the number gets, the worse the absolute precision
> becomes. If the absolute precision is worse than pi, the result is simply
> meaningless. Imagine you have the number 1000000000000 with error +-1000.
> The relative error is quite small (1ppb), but the absolute error is more
> than 100*pi. The result is meaningless.
>
I disagree with this analysis. If I want (cos (scale-float 1d0 120)) (from
one of Kahan's examples), cos should return the correct value. Sure you
can argue that 2^120 (as a float) is some kind of approximation, but, as
I've constructed, I want exactly 2^120, which happens to be exactly
representable in a double-float. I want cos to return the value as
accurately as possible given the input.
Any supposed "error" in a floating-point number is up to the user to
decide, The cos function should accept it as an exact number and produce a
value based on that.
Ray