title: ZeroDivisionError: float division by zero?
body: <pre><code>def fx(x):
      v = float(x*x*x - 5*x - 7)
      return v
  
  
  err = int(input("Enter zeroes in approxiamtion in solution: "))
  b = float(input("Enter upper limit for root: "))
  a = float(input("Enter lower limit for root: "))
  c = 0.0
  while fx(c) &gt; (1 * 10 ** -err):
      c = b - ((b - a)/(fx(b) - fx(a))) * fx(b)
      print(a, b, c, sep=', ')
      a = b
      b = c
      # c = 0
      print()
  print("The root is approximately = ", b)
  </code></pre>
  
  <p>Why am I getting a zero division error on executing this code even though the loop gives the correct values in spite of the error?</p>
  
  <p>Edit: I changed the ^ operator to ** and removed the c = 0 but now the answer is not even close to the actual answer. ^ operator was giving me the correct answer strangely.</p>
  
  <p>Output with ** operator:</p>
  
  <pre><code>Enter zeroes in approxiamtion in solution: 3
  Enter upper limit for root: 2
  Enter lower limit for root: 1
  The root is approximately =  2.0
  </code></pre>
  
  <p>Output with ^ operator:</p>
  
  <pre><code>Enter zeroes in approxiamtion in solution: 3
  Enter upper limit for root: 2
  Enter lower limit for root: 1
  1.0, 2.0, 6.5
  Traceback (most recent call last):
  
  2.0, 6.5, 2.1658986175115205
    File "C:/Users/anves/PycharmProjects/nt/nt.py", line 46, in &lt;module&gt;
  
      c = b - (((b - a)/(fx(b) - fx(a))) * fx(b))
  6.5, 2.1658986175115205, 2.302797651275858
  
  ZeroDivisionError: float division by zero
  2.1658986175115205, 2.302797651275858, 2.934211734811194
  
  2.302797651275858, 2.934211734811194, 2.705017710718186
  
  2.934211734811194, 2.705017710718186, 2.7438299655247143
  
  2.705017710718186, 2.7438299655247143, 2.7474171932954787
  
  2.7438299655247143, 2.7474171932954787, 2.7473464241055843
  
  2.7474171932954787, 2.7473464241055843, 2.7473465403033757
  
  2.7473464241055843, 2.7473465403033757, 2.747346540307211
  
  2.7473465403033757, 2.747346540307211, 2.747346540307211
  </code></pre>
  
  <p>The last value is the correct value which is not getting printed?</p>