title: Newtons Method of a User-defined Function
body: <p>I am trying to find the roots of an equation using Newton's method. This is probably a very obvious mistake, but I keep getting an error that states: "TypeError: cannot determine truth value of Relational". Is there something I forgot to import/include? Sorry, I am very new to python. </p>
  
  <pre><code>import sympy
  
  from sympy import *
  x, y, z = symbols('x y z')
  init_printing(use_unicode=True)
  
  def newton(f, n, eps):
      y = f(n)
      delta = diff(eps, x)
      while abs(y) &gt; eps:
          dy = (f(n + delta) - y) / delta
          n = n - y/dy
          y = f(n)
      return n
  
  def f(n):
      return 5 * n + 10
  
  eps = input("input function:")
  
  print(newton(f, 0, eps))
  </code></pre>