title: Can someone explain why scipy.integrate.quad gives different results for equally long ranges while integrating sin(X)?
body: <p>I am trying to numerically integrate an arbitrary (known when I code) function in my program
  using numerical integration methods. I am using Python 2.5.2 along with SciPy's numerical integration package. In order to get a feel for it, i decided to try integrating sin(x) and observed this behavior-</p>
  
  <pre><code>&gt;&gt;&gt; from math import pi
  &gt;&gt;&gt; from scipy.integrate import quad
  &gt;&gt;&gt; from math import sin
  &gt;&gt;&gt; def integrand(x):
  ...     return sin(x)
  ... 
  &gt;&gt;&gt; quad(integrand, -pi, pi)
  (0.0, 4.3998892617846002e-14)
  &gt;&gt;&gt; quad(integrand, 0, 2*pi)
  (2.2579473462709165e-16, 4.3998892617846002e-14)
  </code></pre>
  
  <p>I find this behavior odd because -<br>
  1. In ordinary integration, integrating over the full cycle gives zero.<br>
  2. In numerical integration, this (1) isn't necessarily the case, because you may just be 
     approximating the total area under the curve.</p>
  
  <p>In any case, either assuming 1 is True or assuming 2 is True, I find the behavior to be inconsistent. Either both integrations (-pi to pi and 0 to 2*pi) should return 0.0 (first value in the tuple is the result and the second is the error) or return 2.257...</p>
  
  <p>Can someone please explain why this is happening? Is this really an inconsistency? Can someone also tell me if I am missing something really basic about numerical methods?</p>
  
  <p>In any case, in my final application, I plan to use the above method to find the arc length of a function. If someone has experience in this area, please advise me on the best policy for doing this in Python.</p>
  
  <p><strong>Edit</strong><br>
  <strong>Note</strong><br>
  I already have the first differential values at all points in the range stored in an array.<br>
  Current error is tolerable.<br>
  <strong>End note</strong></p>
  
  <p>I have read Wikipaedia on this. As Dimitry has pointed out, I will be integrating sqrt(1+diff(f(x), x)^2) to get the Arc Length. What I wanted to ask was - is there a better approximation/ Best practice(?) / faster way to do this. If more context is needed, I'll post it separately/ post context here, as you wish.</p>