Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Find out if there is a zero on an interval...and then use that knowledge

So, I'm using find_root to figure out if there is a zero on a particular interval for a function. But this is part of a larger program and I want to be able to do something different if there is a root versus if there isn't. The idea is that this has to automate for all manner of functions!

For instance: f = sin(x) if find_root(sin(x),1,2) not in RR: print(no root) else: print(root)

Now, of course, this doesn't work because find_root just kicks out an error when there isn't a root. Any ideas what I can do instead?

Find out if there is a zero on an interval...and then use that knowledge

So, I'm using find_root to figure out if there is a zero on a particular interval for a function. But this is part of a larger program and I want to be able to do something different if there is a root versus if there isn't. The idea is that this has to automate for all manner of functions!

For instance: instance:

f = sin(x)
if find_root(sin(x),1,2) not in RR:
   print(no root)
else:
   print(root)

print(root)

Now, of course, this doesn't work because find_root just kicks out an error when there isn't a root. Any ideas what I can do instead?