Solving trigonometric equations numerically



Dan Soendergaard a ?crit :
> Hi again,
>
> It appears that Maxima is unable to solve equations of the form,
>
> 2 * sin(x) = 0.8, where x belongs to [0; 2*pi].
>
> I entered this:
>
> find_root(2*sin(x)=0.8, x, 0, 2*%pi);
>
> and Maxima returned this:
>
> function has same sign at endpoints
> [f(0.0)=-0.8,f(6.283185307179586)=-0.8]
>  -- an error.  To debug this try debugmode(true);
>
> Is there a way to solve this kind of equation?
>   

There is no way to find all solutions of a numerical equation in 
general, even in a given interval.

However in many cases some techniques are available. For example, when a 
continous function takes values of opposite signs at two points, then a 
zero of this function will certainly be found (with a given precision) 
by dichotomy starting from these points. This is what find_root does. 
But you need to give the two points.

One solution two solve your equation is :

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

> By the way, I have found very few difficulties using Maxima for my
> school work. It's really a great piece of software :)
>
>