Re: [sage-support] Error while finding a solution of the non linear equation by bisection method using loop in SageCellServer

2022-08-28 Thread G. M.-S.
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

Re: [sage-support] Error while finding a solution of the non linear equation by bisection method using loop in SageCellServer

2022-08-28 Thread 'Colombel Bruno' via sage-support
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

[sage-support] Error while finding a solution of the non linear equation by bisection method using loop in SageCellServer

2022-08-28 Thread Varun Kumar
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