Message Boards Message Boards

0
|
1412 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Unexpected output from Integrate

Posted 9 months ago

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:

https://gyazo.com/8ebda5752271450bbcf73067974f84a8

(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

POSTED BY: Carlo Wood
4 Replies

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.

POSTED BY: Gianluca Gorni

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) *)
POSTED BY: Daniel Lichtblau
Posted 9 months ago

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.

POSTED BY: Carlo Wood

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
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract