"ma...@mendelu.cz" <ma...@mendelu.cz> writes: >> >> sage: def theta(dz): >> ... angle=0; >> ... if 0<=dz<2*r*cot(gangle) : angle= 2*arcsin(dz*tan(gangle)/2/r); >> ... if 2*r*cot(gangle)<= dz < 2*2*r*cot(gangle) : angle= >> 2*arcsin((dz-2*r*cot(gangle))/(cot(gangle)*2*r)) - pi; >> ... if 2*2*r*cot(gangle)<= dz < 4*2*r*cot(gangle) : angle= >> 2*arcsin((dz-2*2*r*cot(gangle))/(cot(gangle)*2*r)) - 2*pi; >> ... if 0>=dz>-2*r*cot(gangle) : angle= 2*arcsin(dz*tan(gangle)/2/r); >> ... if 2*r*cot(gangle)>= dz > -2*2*r*cot(gangle) : angle= >> 2*arcsin((dz+2*r*cot(gangle))/(cot(gangle)*2*r)) - pi; >> ... if 2*2*r*cot(gangle)>= dz > -4*2*r*cot(gangle) : angle= >> 2*arcsin((dz+2*2*r*cot(gangle))/(cot(gangle)*2*r)) - 2*pi; >> ... return angle; >> ... >> >> then executing >> >> sage: find_root(erseno(x)==0,2,10,xtol=0.01) > > Try to print erseno(x) > it seems that your equation becomes 0.609368485026990==0
It probably does because I put angle=0 at the beginning of theta(dz). If I take it away I get (if calling erseno(x)) ->Traceback (most recent call last): -> File "<stdin>", line 1, in <module> -> File "_sage_input_16.py", line 4, in <module> -> open("___code___.py","w").write("# -*- coding: utf-8 -*-\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZmluZF9yb290KGVyc2Vubyh4KSwyLDEwLHh0b2w9MC4wMSk="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) -> File "", line 1, in <module> -> -> File "/private/var/folders/bc/bcpFbanYErusTUkLXieJfE+++TI/-Tmp-/tmpy0Ob9z/___code___.py", line 3, in <module> -> find_root(erseno(x),_sage_const_2 ,_sage_const_10 ,xtol=_sage_const_0p01 ) -> File "", line 1, in <module> -> -> File "/private/var/folders/bc/bcpFbanYErusTUkLXieJfE+++TI/-Tmp-/tmp87jRdJ/___code___.py", line 4, in erseno -> return _sage_const_2 *arcsin(b*sin(gangle)/_sage_const_2 /r)-(Nrib-_sage_const_1 )*theta(dz2(x))/_sage_const_2 -(Nrib+_sage_const_1 )*theta(x)/_sage_const_2 ; -> File "/private/var/folders/bc/bcpFbanYErusTUkLXieJfE+++TI/-Tmp-/tmps88obK/___code___.py", line 11, in theta -> return angle; ->UnboundLocalError: local variable 'angle' referenced before assignment Thanks again for your time, Giovanni -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org