Brent's method to find the root of a function.