# Integration NSolve problems

I have some problems in solving this equation numerically in Mathematica. Mathematica gives me the error message "NSolve::nsmet: This system cannot be solved with the methods available to NSolve". This is the code:

f[x_, d_] := NIntegrate[z/(Exp[z] - 1), {z, x, x Sqrt[1 + d^2]}]

NSolve[f[x, d] == e x^2 d, d]


where e and x are two parameters. Can anyone help me?

• You can't use NIntegrate when there are unknowns in the integrand or in the limits as in your case. It is a numerical integration after all. You can use Integrate. But the resulting equation can't be solved for d, too complicated. If you have some numerical values for x and e, there could be a better chance. Oct 17, 2021 at 8:46
• I simplified the code in this: f[d_] := Integrate[z/(Exp[z] - 1), {z, 1, Sqrt[1 + d^2]}] NSolve[f[r] == r, r] But give me the same error Oct 17, 2021 at 8:57

Lets solve the integral with Integrate and restrict to x>0,d>0. A plot shows at which d the one sided equation f[x, d] - e x^2 d  is zero in dependence of x (and e, later set to 3).

f[x_, d_] =
Integrate[z/(Exp[z] - 1), {z, x, x Sqrt[1 + d^2]},
Assumptions -> {x > 0, d > 0}]

(*   -(1/2) x (-2 I (-1 + Sqrt[1 + d^2]) \[Pi] + d^2 x + 2   Log[-1 + E^x] -
2 Sqrt[1 + d^2] Log[-1 + E^(Sqrt[1 + d^2] x)]) - PolyLog[2, E^x] +
PolyLog[2, E^(Sqrt[1 + d^2] x)]   *)

Manipulate[
Plot[f[x, d] - e x^2 d // Chop, {d, 0, 30},
PlotRange -> 1], {{x, .15}, 0, 1, Appearance -> "Labeled"}, {{e, 3},
0, 5, Appearance -> "Labeled"}]


In order to get the two d values where equation is zero (here called dzero1 and dzero2), regard d as a function of x, d[x], differentiate for x ( you get also d'[x]) and solve with NDSolve with two initial conditions for d (her for d[.15]) and plot result (attention: LogPlot)

dd = D[0 == f[x, d] - e x^2 d /. {e -> 3} /. d -> d[x], x] //
ExpandAll // Simplify

d01 = d /.
FindRoot[f[x, d] - e x^2 d /. {e -> 3} /. x -> .15, {d, 3}] // Chop

d02 = d /.
FindRoot[f[x, d] - e x^2 d /. {e -> 3} /. x -> .15, {d, 15}] // Chop

dzero1 = d /. First@NDSolve[{dd, d[15/100] == d01}, d, {x, 10^-6, 1}]

dzero2 = d /. First@NDSolve[{dd, d[15/100] == d02}, d, {x, 10^-6, 1}]

LogPlot[Evaluate[{dzero1[x], dzero2[x]}], {x, 10^-6, .21},
PlotRange -> 100]


With your updated/simplified problem, Reduce and Solve can do it

Clear["Global*"]
f[d_] := Integrate[z/(Exp[z] - 1), {z, 1, Sqrt[1 + d^2]}, GenerateConditions -> False];
eq = f[r] == r


Reduce[eq, r, Reals]


Verify solution

 Simplify[eq /. r -> 0]


And Solve

Solve[eq, r, Reals]


And NSolve

NSolve[eq, r, Reals]


But need to use the Reals options in all of them.

Update

Fixing only "e" and making "x" a free variable, can't be solved?

A quick experiment shows that solution is always d=0?

It could not solve it without having specific values for x and e. At least I could not find a way. Tried Solve and Reduce. May be someone else can find a better method to tackle this.

Clear["Global*"];
f = Integrate[z/(Exp[z] - 1), {z, x, x Sqrt[1 + d^2]},
GenerateConditions -> False];
Manipulate[
Module[{eq},
eq = f == e *x^2* d;
Print[eq];
eq = eq /. {x -> x0, e -> e0};
Print[eq];
Grid[{{Row[{"Equation =", eq}]}, {Row[{"solution = ",
Reduce[eq, d, Reals]}]}}]
],
{{e0, 1, "e"}, 0, 10, 1, Appearance -> "Labeled"},
{{x0, 1, "x"}, 0, 10, 1, Appearance -> "Labeled"},
TrackedSymbols :> {e0, x0},
SynchronousUpdating -> False
]

• Thanks! Fixing only "e" and making "x" a free variable, can't be solved? Oct 17, 2021 at 9:19