[Haskell-cafe] C's fmod in Haskell
ok
ok at cs.otago.ac.nz
Tue Sep 25 18:53:30 EDT 2007
[Concerning the fact that fmod(x,y) = -fmod(-x,y)]
I wrote:
>> Interesting, perhaps. Surprising, no. fmod() is basically there for
>> the sake of sin(), cos(), and tan() (or any other periodic and
>> either symmetric or antisymmetric function).
On 25 Sep 2007, at 8:58 pm, Henning Thielemann wrote:
> Why is this particular behaviour useful in connection with
> trigonometric functions?
Range reduction.
sin(x) = sin(fmod(x, M_TWOPI)).
Whether that is the *best* way to handle range reduction is another
matter. (Amongst other things, there are modern algorithms that get
a result as if the range reduction had been done with an infinitely
precise pi. I have no idea how they do that.)
More information about the Haskell-Cafe
mailing list