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...
ne[\[Micro]_, T_] := ne[\[Micro], T] = ...
and just usene[\[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). ThenRemove["Global`*"]
and re-evaluate. You'll still get warnings about poor convergence. $\endgroup$