I want to write a program to find the roots of an equation of a single variable. Will the following steps be useful? Iteratively use the Newton Raphson method. At any stage during an iteration:
If we find a root, then report the result and stop. Otherwise, go to step 2.
If we find two points x1 and x2 at which the function values have opposite signs, then find a root between x1 and x2 using the bisection method. Otherwise, go to step 3.
If we find two points x1 and x2 at which the gradients are of opposite signs, then find a point between x1 and x2 at which the gradient is zero. Suppose this point is x3. If f(x3) is of opposite sign compared to f(x1) and f(x2), then there is one root between x1 and x3 and another root between x2 and x3. We find both using the bisection method. If the three are of the same sign, then we report that the root was not found and stop. Otherwise, go to step 4.
If the gradient becomes constant, this means we have found an asymptote. Report that we could not find a root and stop.
In all other cases, continue with the iteration.
Will this be useful? Or, will it find some wrong root in some cases? Any suggestions for improvements? Thank you.