On Thu, Jul 03, 2025 at 02:43:43PM +0200, Michael Matz wrote:
> Hello,
> 
> On Thu, 3 Jul 2025, Yuao Ma wrote:
> 
> > This patch adds the required function for Fortran trigonometric functions to
> > work with glibc versions prior to 2.26. It's based on glibc source commit
> > 632d895f3e5d98162f77b9c3c1da4ec19968b671.
> > 
> > I've built it successfully on my end. Documentation is also included.
> > 
> > Please take a look when you have a moment.
> 
> +__float128
> +cospiq (__float128 x)
> +{
> ...
> +  if (__builtin_islessequal (x, 0.25Q))
> +    return cosq (M_PIq * x);
> 
> 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.
> 

It's more than just easier range reduction.  There are special
cases that give exact results.  For example, if x is integer,
then sinpi(x) = +-0, exactly.

It's also telling when looking at reported accuracy
https://members.loria.fr/PZimmermann/papers/accuracy.pdf

-- 
Steve

Reply via email to