title: How to do a sum in python
body: <p>I was wondering how one can represent a sum in python without loops like <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html" rel="noreferrer">here</a> </p>
  
  <p>where we have: </p>
  
  <pre><code>def rosen(x):
      """The Rosenbrock function"""
      return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
  </code></pre>
  
  <p>My function is the following: <code>V(theta) = Sum(i=1-&gt;N)[a0*(cos(i*theta)]</code></p>
  
  <p>Thank you in advance for your help :):)</p>