title: Python: An iterating function
body: <p>I am trying to write a program that iterates for me in the form of x<sub>n+1</sub> = x<sub>n</sub><sup>2</sup> + c. How do I do this?</p>
  
  <p>For example, for c = 1 and x<sub>0</sub> = 1/2</p>
  
  <p>(1/2)<sup>2</sup> + 1 = 5/4,<br>
  (5/4)<sup>2</sup> + 1 = 25/16 + 1 = 41/16<br>
  ... etc</p>
  
  <p>My code doesn't work here:</p>
  
  <pre><code>def main():
     import math
     print("This program iterates a function of the form x^2 + c:")
     x=complex(input("Enter a seed value:"))
     c=complex(input("Enter a value for c"))
  
  for i in range(50):
     f(0) = x*x + c
     f(i) = f(i-1)*f(i-1) + c
     print(f(i))
  main()
  </code></pre>
  
  <p>Python doesn't allow me to use <code>f(0)</code> or <code>f(i)</code> like matlab, what's the alternative to this?</p>