# Why NSolve does not work?

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?

• Because NSolve give a numerical solution. If you specify the values of a and b it works. Commented Oct 10, 2016 at 23:46
• 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. Commented Oct 10, 2016 at 23:49
• That's a transcendental equation which I don't think has an analytic solution (except for some very special values of a and b). Commented Oct 10, 2016 at 23:50

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]


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