CoCalc Public FilesBisection method.ipynbOpen with one click!
Views : 36
Compute Environment: Ubuntu 20.04 (Default)

In this activity we have a given function f(x) = ln(x)-sin(x) in the interval (2,4). We need to use the bisection method to find the root of the function.

In [1]:
def bisection(a,b,f,err): c=(a+b)/2 while c-a> err: if f(c)==0: return n elif f(c)*f(a)>0: a=c else: b=c c=(a+b)/2 return c
In [3]:
def f(x): return log(x)- sin(x)
In [ ]:

I do not know what to do exactly I tried to figure out the root using the code I can not find but I would guess that the root is 2.0454546 from what I see on my graphing calculator when I graph the function.

In [ ]:
In [ ]: