# Ex 4.3 Dichotomy function

var('a','b','N') (a, b, N) def Dichotomy(a,b,N): if f(a)*f(b) >= 0: print "Don't bother me or my wrath shall fall upon you" lb = a ub= b for i in range(1, N): mp = (lb+ub)/2 if f(mp) == 0: lb = mp up = mp if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))): lp = mp else: up = mp return [lb,ub,ub-lb]

Dichotomy(1,2,10) Don't bother me or my wrath shall fall upon you

Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in File "", line 11, in Dichotomy TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression'

# Ex 4.3 Dichotomy function

var('a','b','N') 'var('a','b','N') (a, b, N) def Dichotomy(a,b,N): if f(a)*f(b) >= 0: print "Don't bother me or my wrath shall fall upon you" lb = a ub= b for i in range(1, N): mp = (lb+ub)/2 if f(mp) == 0: lb = mp up = mp if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))): lp = mp else: up = mp return [lb,ub,ub-lb]

Dichotomy(1,2,10) Don't bother me or my wrath shall fall upon youyou'

Error 'Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in File "", line 11, in Dichotomy TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression''sage.symbolic.expression.Expression''

# Ex 4.3 Dichotomy function

'var('a','b','N') var('a','b','N') (a, b, N) def Dichotomy(a,b,N): if f(a)*f(b) >= 0: print "Don't bother me or my wrath shall fall upon you" lb = a ub= b for i in range(1, N): mp = (lb+ub)/2 if f(mp) == 0: lb = mp up = mp if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))): lp = mp else: up = mp return [lb,ub,ub-lb]

Dichotomy(1,2,10) Don't bother me or my wrath shall fall upon you'you

'Error Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in File "", line 11, in Dichotomy TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression'''sage.symbolic.expression.Expression'

# Ex 4.3 Dichotomy function

var('a','b','N') var('a','b','N') (a, b, N) def Dichotomy(a,b,N): if f(a)*f(b) >= 0: print "Don't bother me or my wrath shall fall upon you" lb = a ub= b for i in range(1, N): mp = (lb+ub)/2 if f(mp) == 0: lb = mp up = mp if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))): lp = mp else: up = mp return [lb,ub,ub-lb]

Dichotomy(1,2,10) Don't bother me or my wrath shall fall upon you

Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in File "", line 11, in Dichotomy TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression'

# Ex 4.3 Dichotomy function

var('a','b','N')
var('a','b','N')
(a, b, N)
def Dichotomy(a,b,N):
if f(a)*f(b) >= 0:
print "Don't bother me or my wrath shall fall upon you"
lb = a
ub= b
for i in range(1, N):
mp = (lb+ub)/2
if f(mp) == 0:
lb = mp
up = mp
if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))):
lp = mp
else: up = mp
return [lb,ub,ub-lb] [lb,ub,ub-lb]

Dichotomy(1,2,10)
Don't bother me or my wrath shall fall upon you Error you

Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in
File "", line 11, in Dichotomy
TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression''sage.symbolic.expression.Expression'


# Ex 4.3 Dichotomy function

var('a','b','N')
var('a','b','N')
(a, b, N)
def Dichotomy(a,b,N):
if f(a)*f(b) >= 0:
print "Don't bother me or my wrath shall fall upon you"
lb = a
ub= b
for i in range(1, N):
mp = (lb+ub)/2
if f(mp) == 0:
lb = mp
up = mp
if(((f(mp)<0) & (f(lb)<0)) | ((f(mp)>0) & (f(lb)>0))):
lp = mp
else: up = mp
return [lb,ub,ub-lb]
[lb,ub,ub-lb]

Dichotomy(1,2,10)
Don't bother me or my wrath shall fall upon you

Error you

Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in
File "", line 11, in Dichotomy
TypeError: unsupported operand type(s) for &: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression'

'sage.symbolic.expression.Expression'
`