Hello, On Thu, 3 Jul 2025, Joseph Myers wrote:
> > > Isn't the whole raison d'etre for the trig-pi functions that the internal > > > argument reduction against multiples of pi becomes trivial and hence (a) > > > performant, and (b) doesn't introduce rounding artifacts? Expressing the > > > trig-pi functions in terms of their counterparts completely defeats this > > > purpose. The other way around would be more sensible for the cases where > > > it works, but the above doesn't seem very attractive. > > > x = M_FABS (x - M_LIT (2.0) * M_SUF (round) (M_LIT (0.5) * x)); > > In particular, this is what trivial range reduction looks like: no need to > do multiple-precision multiplication with the relevant bits of a > multiple-precision value of 1/pi, just round to the nearest integer > (typically a single instruction). Yes. And then the above is multiplied by PI, passed to cos/sin and that one then tries to figure out the multiple of PI (i.e. the 'x' above) again via range reduction (not a _terribly_ slow one anymore in a good implementation, because of the limited input range, but still). That's backwards. Ciao, Michael.