Brent Root Finding Algorithm Python