title: Accuracy of Math.Sin() and Math.Cos() in C#
body: <p>I am terribly annoyed by the inaccuracy of the intrinsic trig functions in the CLR. It is well know that </p>
  
  <pre><code>Math.Sin(Math.PI)=0.00000000000000012246063538223773
  </code></pre>
  
  <p>instead of 0. Something similar happens with <code>Math.Cos(Math.PI/2)</code>. </p>
  
  <p>But when I am doing a long series of calculations that on special cases evaluate to </p>
  
  <pre><code>Math.Sin(Math.PI/2+x)-Math.Cos(x)
  </code></pre>
  
  <p>and the result is zero for x=0.2, but not zero for x=0.1 (try it). Another issue is when the argument is a large number, the inaccuracy gets proportionally large. </p>
  
  <p>So I wonder if anyone has coded some better representation of the trig functions in C# for sharing with the world. Does the CLR call some standard C math library implementing CORDIC or something similar? link:<a href="http://en.wikipedia.org/wiki/CORDIC" rel="noreferrer">wikipedia CORDIC</a></p>