6

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!

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
GambitSquared
  • 2,311
  • 15
  • 23

5 Answers5

16

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}}

ciao
  • 25,774
  • 2
  • 58
  • 139
4
FindRoot[x Sin[x] == -Cos[x], {x, 2}] 

gives

(* {x -> 2.79839}  *)
thils
  • 3,228
  • 2
  • 18
  • 35
4

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]}]

enter image description here

2

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

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

If you want more answers:

FindInstance[-x Sin[x] == Cos[x], x, 3] // N
bill s
  • 68,936
  • 4
  • 101
  • 191
1

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:

N[cotSol[Range[10], -1], 20]
   {2.7983860457838871367, 6.1212504668980683013, 9.3178664617910653790,
    12.486454395223781428, 15.644128370333027630, 18.796404366210157169,
    21.945612879981044573, 25.092910412112097360, 28.238936575260272929}

The negative roots are of course just the negations of the positive roots in this case.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574