Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 199
Image: ubuntu2004
Kernel: Python 3 (system-wide)

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.

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
def f(x): return log(x)- sin(x)
bisection(2,4,f,0.01)

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.