# Trouble evaluating an expression [closed]

I am currently trying to numerically evaluate an expression which is the following. The expression IntD0 is being plotted, but the next line is not. I thought it might be because of zeros in IntD0 but even after removing them it shows an empty plot. I am not sure why this is happening.

The expression formally is the following : \begin{aligned} &D_0 = \int_{-\left({w}+{T}\right)}^{\left({w}+{T}\right)}d{\epsilon}\frac{1}{\pi{w}}\left[1-\frac{{\epsilon}^2}{{w}^2}\right]\frac{\exp{\left(\frac{{\epsilon}-{\mu}}{{T}}\right)}}{\left(\exp{\left(\frac{{\epsilon}-{\mu}}{{T}}\right)}+1\right)^2}\frac{1}{T} \\ &E = \sqrt{\lambda - \frac{1}{D_{0}}}, \end{aligned} where $$\lambda$$, $$w$$, $$T$$, $$\mu$$ are parameters, and I am plotting $$E$$ as a function of $$T$$.

g[\[Epsilon]_, w_] := 1/(\[Pi]  w) (1 - (\[Epsilon])^2/w^2)
f1[\[Epsilon]_, \[Mu]_,
T_] :=  E^((\[Epsilon] - \[Mu])/T)/((1 + E^((\[Epsilon] - \[Mu])/
T))^2 T)

(* Integrate*)
IntD0[(w_)?NumericQ, (\[Mu]_)?NumericQ,  (T_)?NumericQ] :=
NIntegrate[
g[\[Epsilon], w] f1[\[Epsilon], \[Mu], T], {\[Epsilon], -w - T,
w + T}, MaxRecursion -> 100, AccuracyGoal -> Infinity,
Manipulate[
ListLinePlot[Table[{b, IntD0[t, e, b]}, {b, 0.001, 1, 0.05}]], {e, 0,
1}, {t, 0.001, 1}]

Manipulate[
ListLinePlot[
Table[{b, Sqrt[c - (1/IntD0[t, e, b]) ]}, {b, 0.1, 1}]], {e, 0.5, 1}, {t, 0.5, 1},{c, 0.5, 1}] (* empty plot*)


Edit: I had made an error in not specifying the increments for b. (thanks to @MarcoB for this)

• What's the definition of the function g that appears in your NIntegrate? Commented Jul 12, 2022 at 7:07
• There is also a mismatch between your Mathematica code (1+E^((\[Epsilon]-\[Mu])/T))^2 and the denominator in the TeX-formula for $D_0$, the square is not in the same place. Commented Jul 12, 2022 at 7:13
• Indeed sorry for the mistake. @MarcoB sorry I forgot to add that Commented Jul 12, 2022 at 8:10
• Table[{b, Sqrt[c - (1/IntD0[t, e, b]) ]}, {b, 0.1, 1}]] Evaluates to a {{0.1, 0. + 3.01091 I}}, A single point to plot, but a complex and ListLinePlotexpects real numbers, not complex. Commented Jul 12, 2022 at 8:43
• the single point is strange and perhaps the problem. I did realize that I need to take the real part. Thanks for pointing that out. Commented Jul 12, 2022 at 13:01

I understand that integrating such complex expressions causes certain difficulties. However, I tried to solve the problem in a direct way.

We take the formula for integration by parts:

u = (1 - \[Epsilon]^2/\[Omega]^2 );

v = Exp[(\[Epsilon] - \[Mu])/T ]/(Exp[(\[Epsilon] - \[Mu])/T ]^2 + 1 );

du = D[u, \[Epsilon]];

dv = D[v, \[Epsilon]];


We calculate the integral and obtain a relatively compact form:

integralbyparts = -(1/(Pi \[Omega] )) 1/
T  (ReplaceAll[u, \[Epsilon] -> \[Omega] + T] ReplaceAll[
v, \[Epsilon] -> \[Omega] + T] -
ReplaceAll[u, \[Epsilon] -> -(\[Omega] + T)] ReplaceAll[
v, \[Epsilon] -> -(\[Omega] + T)] -
Integrate[du v, {\[Epsilon], -(\[Omega] + T), \[Omega] + T}]) //
Simplify


!!!IMPORTANT!!! Then we take the formula $$E=\sqrt{\lambda-\frac{1}{D_0}}=\sqrt{\lambda-\frac{1}{integral by parts}}$$ and substitute the integral by parts instead of $$D_0$$ by simply copying the result !

e[\[Lambda]_, \[Mu]_, T_, \[Omega]_] :=
Sqrt[\[Lambda] -
1/(1/(\[Pi] \[Omega]^3) (-((
E^((T + \[Mu] + \[Omega])/T) (T + 2 \[Omega]))/(
1 + E^((2 (T + \[Mu] + \[Omega]))/T))) + (
E^((T + \[Mu] + \[Omega])/T) (T + 2 \[Omega]))/(
E^((2 \[Mu])/T) + E^(2 + (2 \[Omega])/T)) -
2 (T + \[Omega]) (ArcCot[E^((T + \[Mu] + \[Omega])/T)] +
ArcTan[E^((T - \[Mu] + \[Omega])/T)]) +
I T (PolyLog[2, -I E^((T - \[Mu] + \[Omega])/T)] -
PolyLog[2, I E^((T - \[Mu] + \[Omega])/T)] -
PolyLog[2, -I E^(-((T + \[Mu] + \[Omega])/T))] +
PolyLog[2, I E^(-((T + \[Mu] + \[Omega])/T))])))]


Then we build a graph and play with the parameters:

Manipulate[
Plot[e[\[Lambda], \[Mu], T, \[Omega]], {T, 0.1, 5},
PlotRange -> Full, AxesLabel -> Automatic], {\[Lambda], 1,
5}, {\[Omega], 0.1, 1}, {\[Mu], 1, 3}]


It would be nice if you could indicate the ranges of these parameters and their physical meaning. Because for some values, the function is not computable and I had to select these values manually.

• Thanks for the answer, very nice approach. Unfortunately at this point this problem is still in its infancy and I am not too sure myself about the ranges of these parameters. However, I would be happy to add more details about the physical meanings of the parameters in edits. Commented Jul 12, 2022 at 13:02