carlo
(Carlo Wood)
December 4, 2023, 6:08pm
1
Hello, I am desperately trying to evaluate the following integral for several days now:
Integral[(1/(1+Exp[-x]))*Log[1/(1+Exp[-(x*w+b)])],{x,-Infinity,Infinity}]
I can’t get Mathematica to do it; so I tried - at some point - this:
Integrate[(1/(1 + Exp[-x]))*Log[1/(1 + Exp[-x])], x]
That results in a formula, but it doesn’t seem to make any sense?!
It returns:
(I can’t get Mathematica to copy anything to clipboard)
This contains Log[-Exp[x]] which can’t exist since Exp[] is always positive?!
Can someone please help,
Carlo Wood
danl
(Daniel Lichtblau)
December 4, 2023, 6:32pm
2
Use Integrate, not Integral.
In[316]:= Integrate[(1/(1 + Exp[-x]))*
Log[1/(1 + Exp[-x])], {x, -Infinity, Infinity}]
Out[316]= -(\[Pi]^2/6)
In[317]:= NIntegrate[(1/(1 + Exp[-x]))*
Log[1/(1 + Exp[-x])], {x, -Infinity, Infinity}]
Out[317]= -1.64493
carlo
(Carlo Wood)
December 4, 2023, 7:01pm
3
Sorry, I was typing that from my head - I use Integrate in the notebook example.
What can you say about the log(-exp(x)) in the answer? I knew that the integral with limits for the simpler form is -pi^2/6; I either need the definite integral with the w and b, or an explanation of the logarithm of a negative value in an answer that should be just real function.
danl
(Daniel Lichtblau)
December 4, 2023, 7:05pm
4
The imaginary parts will cancel.
ii = Integrate[(1/(1 + Exp[-x]))*Log[1/(1 + Exp[-x])], x]
(* Out[359]=Log[-E^x] Log[1/(1 + E^x)] + 1/2 Log[1/(1 + E^x)]^2 -
Log[1/(1 + E^x)] Log[E^x/(1 + E^x)] - PolyLog[2, 1 + E^x] *)
hi = Limit[ii, x -> Infinity]
lo = Limit[ii, x -> -Infinity]
(* Out[360]= -(\[Pi]^2/3)
Out[361]= -(\[Pi]^2/6) *)
hi - lo
(* Out[362]= -(\[Pi]^2/6) *)
The output contains functions with complex values, but the end result is real:
int = Integrate[(1/(1 + Exp[-x]))*Log[1/(1 + Exp[-x])], x]
int2 = FullSimplify[ComplexExpand[int], Element[x, Reals]]
FullSimplify[ComplexExpand[int] == int2, Element[x, Reals]]
Plot[int - int2, {x, -1, 1}]
Unfortunately we cannot check the derivative of int2, because int2 contains Re, which is not differentiable in the complex sense.