- find_root(f, a, b, xtol=9.9999999999999998e-13, rtol=4.5000000000000002e-16, maxiter=100, full_output=False)
- Numerically find a root of ``f`` on the closed interval `[a,b]`
(or `[b,a]`) if possible, where ``f`` is a function in the one variable.
INPUT:
- ``f`` -- a function of one variable or symbolic equality
- ``a``, ``b`` -- endpoints of the interval
- ``xtol``, ``rtol`` -- the routine converges when a root is known
to lie within ``xtol`` of the value return. Should be `\geq 0`.
The routine modifies this to take into account the relative precision
of doubles.
- ``maxiter`` -- integer; if convergence is not achieved in
``maxiter`` iterations, an error is raised. Must be `\geq 0`.
- ``full_output`` -- bool (default: ``False``), if ``True``, also return
object that contains information about convergence.
EXAMPLES:
An example involving an algebraic polynomial function::
sage: R.<x> = QQ[]
sage: f = (x+17)*(x-3)*(x-1/8)^3
sage: find_root(f, 0,4)
2.9999999999999951
sage: find_root(f, 0,1) # note -- precision of answer isn't very good on some machines.
0.124999...
sage: find_root(f, -20,-10)
-17.0
In Pomerance book on primes he asserts that the famous Riemann
Hypothesis is equivalent to the statement that the function `f(x)`
defined below is positive for all `x \geq 2.01`::
sage: def f(x):
... return sqrt(x) * log(x) - abs(Li(x) - prime_pi(x))
We find where `f` equals, i.e., what value that is slightly smaller
than `2.01` that could have been used in the formulation of the Riemann
Hypothesis::
sage: find_root(f, 2, 4, rtol=0.0001)
2.0082590205656166
This agrees with the plot::
sage: plot(f,2,2.01)