# Invertion of an equation involving an integral

I am trying to solve the following equation numerically for $$\mu$$, but I'd like to keep $$T$$ and $$n_e$$ as parameters for easier plots. $$n_e = \frac{1}{\pi^2}\int_0^\infty dp\, p^2\frac{\sinh \left(\frac{\mu }{T}\right)}{\cosh \left(\frac{\sqrt{{m_e}^2+p^2}}{T}\right)+\cosh \left(\frac{\mu}{T}\right)}$$

I tried the following code

me = 0.51 10^-3;
Ke = 8.62 10^-14;
ne[\[Micro]_, T_] := ne[\[Micro], T] = 1/\[Pi]^2 NIntegrate[p^2*Sinh[\[Micro]/T]/(Cosh[Sqrt[me^2 + p^2]/T] + Cosh[\[Micro]/T]), {p, 0, \[Infinity]}]
FindRoot[10 == ne[\[Micro], 10^2*Ke], {\[Micro], 0.10}]


But got an error saying that the integrand has evaluated to non-numerical values for all sampling points in the region of integration...

• Get rid of this ne[\[Micro]_, T_] := ne[\[Micro], T] = ... and just use ne[\[Mu]_?NumericQ, T_?NumericQ] := and change \[Micro] to \[Mu] (this last part has no functional effect but it's bad style to use an SI prefix symbol instead of a Greek letter). Then Remove["Global*"] and re-evaluate. You'll still get warnings about poor convergence. – flinty Nov 25 '20 at 13:17
• I tried out some different integration methods but they still had warnings, and LocalAdaptive had no warnings but was incorrect. The best I could get was $\mu = 6.7$ but I have no idea if that's accurate. – flinty Nov 25 '20 at 13:37
• Thanks but it keeps telling me that it encountered a singular Jacobian, whatever value I use as starting point (Btw, ne is ~10^30 and T ~ 10^-3) – Eugene Hankerson Nov 25 '20 at 13:49

Try this:

m = 0.51 10^-3;
ParametricPlot3D[{T,
Log[Sinh[μ/T]*π^-2 NIntegrate[
p^2/(Cosh[Sqrt[m^2 + p^2]/T] + Cosh[μ/T]), {p, 0,
100}]], μ}, {T, 1, 5}, {μ, 1, 5}, PlotRange -> All,
AxesLabel -> {Style["T", Italic, 16],
Style["log(\!$$\*SubscriptBox[\(n$$, $$e$$]\))", Italic, 16],
Style["μ", Italic, 16]}, ColorFunction -> "Rainbow"]


with the following effect:

If you want to make a solution in a form of a list, replace  ParametricPlot3D by Table`.

Have fun!