1 | initial version |
When there is no root in the given interval, the function find_root()
does not return anything but raises a RuntimeError
exception:
sage: f(x) = 2 ; f
x |--> 2
sage: find_root(f,-10,10)
...
RuntimeError: f appears to have no zero on the interval
If you want to deal with that, you have to catch the error (otherwise your program will stop here):
try:
root = find_root(f,-10,10)
root_exist = True
except RuntimeError:
root_exist = False
You can read more here.