Python: The code I typed isn’t doing anything

I’m trying to do the bisection method using Python and when I try to run it, nothing happens.
Here’s the code I 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)


Source: syntax

Leave a Reply