# Solve simple trig equation

I would like to solve this equation:

$$-x\sin(x)=\cos(x)$$

But Solve in Mathematica doesn't work:

This system cannot be solved with the methods available to Solve

Being a beginner, I don't know any other ways to solve this equation. Any suggestions?

Thanks!

• Have a look at NSolve, which solves an equation numerically. Sep 3, 2015 at 7:53

Restrict the domain:

Solve[-x Sin[x]==Cos[x]&&-30<=x<=30,x,Reals]//N

{{x->-28.2389},{x->-25.0929},{x->-21.9456},{x->-18.7964},{x->-15.6441},{x->-12.4865},{x->-9.31787},{x->-6.12125},{x->-2.79839},{x->2.79839},{x->6.12125},{x->9.31787},{x->12.4865},{x->15.6441},{x->18.7964},{x->21.9456},{x->25.0929},{x->28.2389}}

• As long as you're adding the constraint -30<=x<=30, the 3rd argument Reals is superfluous. Sep 3, 2015 at 14:59
• For me, restricting to the Reals is more useful than constraining the domain. Jun 20, 2020 at 23:40
FindRoot[x Sin[x] == -Cos[x], {x, 2}]

gives

(* {x -> 2.79839}  *)

In which domain do you want to solve your problem? Make a plot and restrict your domain (example here [-2 Pi,2 Pi]).

sol = x /. NSolve[-x Sin[x] == Cos[x] && -2 \[Pi] < x < 2 \[Pi], x]
{-6.12125, -2.79839, 2.79839, 6.12125}

Plot[{-x Sin[x], Cos[x]}, {x, -2 \[Pi], 2 \[Pi]},
Epilog -> {Red, PointSize -> Medium, Point[{#, Cos[#]} & /@ sol]}]

Another function worth trying in cases like this may be FindInstance:

FindInstance[-x Sin[x] == Cos[x], x] // N
{{x -> 2.79839}}

The function cotSol[k, λ] for generating the $k$-th positive root of $\lambda x=\cot x$, which I wrote for this answer, can be used to directly generate the required solutions: