Re: Sine code for ANSI C

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 05/16/04


Date: Sun, 16 May 2004 21:21:22 GMT

Joe Wright wrote:
>
... snip ...
>
> 2. Large Angles. The circle is 360 degrees or '2 pi radians'.
> Why is something like..
>
> double r = 52147.3, s;
> s = sin(fmod(r,2*PI));
>
> ..not the solution for large angle argument reduction?

That depends highly on how you compute the fmod. Say you compute
r/(2*PI), truncate it to an integer, multiply by (2*PI), and
subtract that from r. Now you have the difference of two
comparable magnitudes, with attendant loss of significant bits.

Compare with methods of computing sigma f(n) for n = 1 ....
infinity. If you start with n=1 (using the normally available
floating point system) you will end up with something quite
divergent from the true answer, regardless of whether the series
actually converges or not. A reasonably accurate computation
requires starting with the smallest terms.

-- 
"I'm a war president.  I make decisions here in the Oval Office
 in foreign policy matters with war on my mind." -         Bush.
"Churchill and Bush can both be considered wartime leaders, just
 as Secretariat and Mr Ed were both horses." -     James Rhodes.


Relevant Pages

  • Re: Bipedalism in different substrates
    ... why doesn't parsimony suggest that human ancestors too ... hair must be completely eliminated from the body. ... of hairlessness in drag reduction. ...
    (sci.anthropology.paleo)
  • Re: program output?
    ... Joe Wright wrote: ... snip ... ... even if the requirement for trailing new-line is documented ... who exactly is the requirement binding ...
    (comp.lang.c)
  • Re: GPS vs. Source Dependency
    ... No matter how highly red-shifted or blue-shifted the light, ... emerges from a prism at the exact same angle as light from a stationary ... emerges from a diffraction grating at the exact same angle as light ...
    (sci.physics)
  • Re: GPS vs. Source Dependency
    ... No matter how highly red-shifted or blue-shifted the light, ... emerges from a prism at the exact same angle as light from a stationary ... emerges from a diffraction grating at the exact same angle as light ...
    (sci.physics.relativity)
  • Re: modern popular concept of magic
    ... Romauld wrote: ... > a definite reduction in the number of people who genuinely believe ... > the campaign to educate the stupid is slowly having effects. ...
    (uk.religion.pagan)

Loading