3
$\begingroup$

I am trying to solve the following equation, but it does not work. I am very new to Mathematica so I am probably missing something very simple:

NSolve[(-a*x+x^2-b+b*x*Coth[x])*(-1+x^2*Csch[x]^2)==0, x, Reals]

This returns "NSolve: This system cannot be solved with the methods available to NSolve". Why?

$\endgroup$
  • 2
    $\begingroup$ Because NSolve give a numerical solution. If you specify the values of a and b it works. $\endgroup$ – corey979 Oct 10 '16 at 23:46
  • $\begingroup$ Thanks, that makes sense. I think I needed to use Solve, then, as I need a functional solution. However, this gives the same error message. $\endgroup$ – user43693 Oct 10 '16 at 23:49
  • 1
    $\begingroup$ That's a transcendental equation which I don't think has an analytic solution (except for some very special values of a and b). $\endgroup$ – corey979 Oct 10 '16 at 23:50
9
$\begingroup$

NSolve gives a numerical solution, so a and b need to be specified; then it works.

You can get an insight into how does the solution depend on the parameters a and b like this:

f[a_, b_] := 
 x /. NSolve[(-a*x + x^2 - b + b*x*Coth[x])*(-1 + x^2*Csch[x]^2) == 0,
     x, Reals][[1]]

to produce a table

tab = Flatten[#, 1]& @
    Table[{a, b, f[a, b]}, {a, 0.1, 3, 0.1}, {b, 0, 3, 
      0.1}]; // AbsoluteTiming

{42.2379, Null}

and plot the results

plot1 = ListDensityPlot[tab, PlotLegends -> Automatic]
   (* or *)
plot2 = ListContourPlot[tab, PlotLegends -> Automatic]

enter image description here enter image description here

Finally, you can also interpolate the results:

inter = Interpolation @ tab

inter[0.12, 2.37]

0.067048

which for this well-behaving equation works very well:

f[0.12, 2.37]

0.067048

Plot3D[inter[x, y], {x, 0.1, 3}, {y, 0, 3}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.