Solving trigonometric equations numerically



On 02/04/2008, reyssat <reyssat at math.unicaen.fr> wrote:

>
>  1/ First plot your function to see where changes of sign do occur :
>  plot2d([2*sin(x),0.8],[x,0,2*%pi]);
>  the graphic shows obviously a solution between 0 and 1, another between 2
> and 3, and no other.
>
>  2/ With this information, use find_root wih appropriate starting points :
>
>  find_root(2*sin(x)=0.8, x, 0, 1);            --->     0.41151684606749
>  find_root(2*sin(x)=0.8, x, 2,3);             --->     2.730075807522305
>
>
>
>  Another possibility is to use newton, when your function is differentiable
> (which is the case here), starting from a single point. There is no
> guarantee to obtain a solution, and the one you obtain may far from the
> starting point, but it often converges to a solution. Here are the commands
> :
>
>  load (newton1);
>  newton (2*sin(x)-0.8, x, 0, 10^-10);           --->    0.41151684606749
>
>  Eric Reyssat
>

This works absolutely great. I probably should have tried to plot the
equation first and try some other boundaries before asking, must have
slipped my mind.

You've all been very helpful, thank you very much!

-- 
Sincerely,

Dan Sondergaard