Jason Grout <[email protected]> writes: > > > So which of your "if" conditions is true when the input is > the variable x? I think that's the problem---none of the > conditions is true, so angle is never set, so you are trying > to return an undefined variable. > > > The find_root function takes in just a function (not a > function evaluated at x), so the call should look something > like: > > find_root(erseno, xmin, xmax) > > However, it seems that there is another problem with a NaN > coming up. I just posted about this in another thread.
Sorry, my bad. The correct function theta should have been ... 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)) - 3.1415; ... 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*3.1415; ... 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)) - 3.1415; ... 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*3.1415; ... return angle; with the minus sign in the last two conditions. Putting a plus "freaks" sage out (I don't know if that is normal). Thanks, and sorry for the inconvenience. Giovanni -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
