From: already5chosen@yahoo.com   
      
   On Wed, 17 Dec 2025 07:59:10 -0000 (UTC)   
   Thomas Koenig wrote:   
      
   > BGB schrieb:   
   >   
   > > double sin(double ang)   
   > > {   
   > > double t, x, th, th2;   
   > > int i;   
   > > i=ang*M_TAU_R;   
   > > th=ang-(i*M_TAU);   
   > > th2=th*th;   
   >   
   > That leaves a lot of room for improvement; you would be better   
   > off reducing to [-pi/4,+pi/4].   
      
   It's not what I'd do in practice. The degree of poly required after   
   reduction to [-pi/4,+pi/4] is way too high. It seems, you would need   
   Chebyshev poly of 15th degree (8 odd terms) just to get what Mitch   
   calls 'faithful rounding'. For something better, like 0.51 ULP, you   
   would need one more term.   
      
   There are better methods. Like reducing to much smaller interval, e.g.   
   to [-1/64,+1/64]. May be, even to [-1/128,+1/128]. The details of trade   
   off between size of reduction table and length of polynomial depend on   
   how often do you plan to use your sin() function.   
      
   > See   
   > https://userpages.cs.umbc.edu/phatak/645/supl/Ng-ArgReduction.pdf   
   > for a random reference grabbed off the net how to do it.   
   >   
   > [...]   
   >   
   > > Time cost: roughly 450 clock cycles (penalties are steep on this   
   > > one).   
   >   
   > What is your accuracy?   
      
   Before asking that it's worth to ask about an expected range of the   
   argument.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|