Find root of a function with sin/cos in a given interval

Solution 1:

If you are able to bracket the solution, I suggest you use subroutine RTSAFE from Numerical Recipes (this is the $C$ version) (look at page $366$). Quoting the book

"The hybrid algorithm takes a bisection step whenever Newton-Raphson would take the solution out of bounds, or whenever Newton-Raphson is not reducing the size of the brackets rapidly enough".

Looking at your plots, in order to bracket the solution, what I should to is to find the maximum value of the function (solving $f'(x)=0$ - hoping that there is only one root in the interval). So, the largest root is between this point and the right bound.

If it is possible, I would enjoy playing with your function.