syntax - Python: The code I typed isn't doing anything -


i'm trying bisection method using python , when try run it, nothing happens. here's code used:

import math a=0 b=1     def f(x):         return math.sqrt(x)-math.cos(x) while b-a>0.0001:         c=(a+b)/2     if f(a)*f(c)>0:                 a=c else:         b=c print(c) 

  1. the else belongs while.
  2. c defined inside while
  3. it seems push c value down?

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -