Hi Varun.
There are several problems (besides the confusion between "Bisection" and
"bisection").
1) As you know, in Python blocks are delimited by indentation. So it
should be
sage: *def* *bisection*(f, a, b, errorBound):
: xm = (a+b)/*2*
: *while* f(x) != *0* and (b-a) >= er
You need to change some indentations.
def Bisection(f, a, b, errorBound): xm = (a+b)/2
while( f(x)!=0 and (b-a) >= errorBound):
if(f(a)*f(xm)<0):
b = xm
else:
a = xm
xm = (a+b)/2
return xm.n()
def f(x):
return x^3-9*x+1
Bisection(f,2
def Bisection(f, a, b, errorBound):
xm = (a+b)/2
while( f(x)!=0 and (b-a) >= errorBound):
if(f(a)*f(xm)<0):
b = xm
else:
a = xm
xm = (a+b)/2
return xm
def f(x):
return x^3-9*x+1
bisection(f,2,3,0.001)
print("ro