title: Why is numpy's sine function so inaccurate at some points?
body: <p>I just checked <code>numpy</code>'s <code>sine</code> function. Apparently, it produce highly inaccurate results around pi. </p>
  
  <pre><code>In [26]: import numpy as np
  
  In [27]: np.sin(np.pi)
  Out[27]: 1.2246467991473532e-16
  </code></pre>
  
  <p>The expected result is 0.  Why is <code>numpy</code> so inaccurate there?</p>
  
  <p>To some extend, I feel uncertain whether it is acceptable to regard the calculated result as inaccurate: Its absolute error comes within one machine epsilon (for binary64), whereas the relative error is <code>+inf</code> -- reason why I feel somewhat confused. Any idea?</p>
  
  <p>[Edit] I fully understand that floating-point calculation can be inaccurate. But most of the floating-point libraries can manage to deliver results within a small range of error. Here, the relative error is +inf, which seems unacceptable. Just imagine that we want to calculate </p>
  
  <pre><code>1/(1e-16 + sin(pi)) 
  </code></pre>
  
  <p>The results would be disastrously wrong if we use numpy's implementation. </p>