title: Euler's method in python
body: <p>I'm trying to implement <a href="http://en.wikipedia.org/wiki/Euler_method" rel="nofollow">euler's method</a> to approximate the value of e in python. This is what I have so far:</p>
  
  <pre><code>def Euler(f, t0, y0, h, N):
      t = t0 + arange(N+1)*h
      y = zeros(N+1)
      y[0] = y0
      for n in range(N):
          y[n+1] = y[n] + h*f(t[n], y[n])
          f = (1+(1/N))^N
      return y
  </code></pre>
  
  <p>However, when I try to call the function, I get the error "ValueError: shape &lt;= 0". I suspect this has something to do with how I defined f? I tried inputting f directly when euler is called, but gave me errors related to variables not being defined.  I also tried defining f as its own function, which gave me a division by 0 error.</p>
  
  <pre><code>def f(N):
      for n in range(N): 
          return (1+(1/n))^n
  </code></pre>
  
  <p>(not sure if N was the appropriate variable to use here...)</p>