title: Newtons Method in Python
body: <p>I'm writing a program in python that will solve for zeros using newtons method. I finished writing the rough version of it,  then realized a couple different things and was wondering if I need to impement/change this. (knowledge of the subject may help) </p>
  
  <pre><code>def main():
  
     dir(sympy)
  
     print ("NEWTONS METHOD")
     print ("Write your expression in terms of 'x' ") 
  
     e = sympy.sympify(raw_input("input expression here: "))  
     f = sympy.Symbol('x')
  
  
     func1 = e
     func1d = sympy.diff(e,f) 
  
  
     print ("the dirivative of your function = "), func1d
  
     x = input("number to substitude for x: ")
  
  
     func1sub = func1.subs({'x':x})
     func1dsub = func1d.subs({'x':x})
     n = x - float(func1sub/func1dsub)
  
  
  
     while n != x:
        func1sub = func1.subs({'x':x})
        func1dsub = func1d.subs({'x':x})
        n = x - float(func1sub/func1dsub)
        print n
  
  
  
  main()
  </code></pre>
  
  <p>1) Well first I was wondering since the values of <code>n</code> and <code>x</code> may not always be exactly the same I would have to round using the round function.</p>
  
  <p>2) After looking at this I feel that my while loop is not solving for what it should be solving, it should be solving for what is the <code>x</code> that you can plug it into <code>x</code> in the function and the output will be <code>x</code>. Could I do this by appending the values to a array then seeing where their are multiples instances of one number?</p>