title: Euler method (explicit and implicit)
body: <p>I'd like to implement Euler's method (the explicit and the implicit one)
   (<a href="https://en.wikipedia.org/wiki/Euler_method" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Euler_method</a>) for the following model:</p>
  
  <pre class="lang-none prettyprint-override"><code>x(t)' = q(x_M -x(t))x(t)
  x(0) = x_0 
  </code></pre>
  
  <p>where q, x_M and x_0 are real numbers. </p>
  
  <p>I know already the (theoretical) implementation of the method. But I couldn't figure out where I can insert / change the model.
  Could anybody help? </p>
  
  <p>EDIT: You were right. I didn't understand correctly the method. Now, after a few hours, I think that I really got it! With the explicit method, I'm pretty sure (nevertheless: could anybody please have a look at my code? )</p>
  
  <p>With the implicit implementation, I'm not very sure if it's correct. Could please anyone have a look at the implementation of the implicit method and give me a feedback what's correct / not good? </p>
  
  <pre><code>def explizit_euler():
      ''' x(t)' = q(xM -x(t))x(t)
      x(0) = x0'''
      q = 2. 
      xM = 2
      x0 = 0.5 
      T = 5 
      dt = 0.01 
      N = T / dt 
      x = x0
      t = 0.
      for i in range (0 , int(N)):
          t = t + dt
          x = x + dt * (q * (xM - x) * x)
          print '%6.3f %6.3f' % (t, x)
  
  
  
  def implizit_euler():
      ''' x(t)' = q(xM -x(t))x(t)
      x(0) = x0'''
      q = 2.
      xM = 2
      x0 = 0.5
      T = 5
      dt = 0.01
      N = T / dt
      x = x0
      t = 0.
      for i in range (0 , int(N)):
          t = t + dt
          x = (1.0 / (1.0 - q *(xM + x) * x))
          print '%6.3f %6.3f' % (t, x)
  </code></pre>