1.Solve the same problem as in Exercise 7.1, using the bisection method, but let the initial interval be [−5, 3]. Report how the interval containing the solution evolves during the iterations.
2.An attractive idea is to combine the reliability of the bisection method with the speed of Newton’s method. Such a combination is implemented by running the bisection method until we have a narrow interval, and then switch to Newton’s method for speed. Write a function that implements this idea. Start with an interval [a, b] and switch to Newton’s method when the current interval in the bisection method is a fraction s of the initial interval (i.e., when the interval has length s(b−a)). Potential divergence of Newton’s method is still an issue, so if the approximate root jumps out of the narrowed interval (where the solution is known to lie), one can switch back to the bisection method. The value of s must be given as an argument to the function, but it may have a default value of 0.1. Try the new method on tanh(x) = 0 with an initial interval [−10, 15].