# $\int_0^\infty -\frac{\log(|1-x|) dx}{x(2-x)} = \frac{3 \pi^2}{8}$ but Integrate gives $\frac{\pi^2}{4}$

I'm running Mathematica 13.0 Student Edition on Windows 10.

Consider the function $$f(x) = -\frac{\log(|1-x|)}{x(2-x)}$$. The function is well-defined at $$0$$ and $$2$$ and has a weak, integrate-able logarithmic divergence at $$x=1$$. The function is also positive everywhere on the real line.

Note that the function decays sufficiently rapidly so that it can be integrated from $$0$$ to $$\infty$$ without trouble. I can show that $$\int_0^\infty -\frac{\log(|1-x|) dx}{x(2-x)} = \frac{3 \pi^2}{8}.$$

This is indeed what NIntegrate finds numerically. However, I have the following perplexing result where Integrate is off by a factor of $$2/3$$ smaller than the correct answer:

Perhaps a key to what's happening can also be seen in the integral from $$0$$ to $$1$$ - as noted above, the function $$f(x)$$ is positive on the real line, so the fact Integrate gives zero is a sign of something going awry:

Here is the key code I used above for straightforward copy-pasting:

Integrate[-1/(x (2 - x)) Log[Abs[1 - x]], {x, 0, Infinity}] and Integrate[-1/(x (2 - x)) Log[Abs[1 - x]], {x, 0, 1}]

Why is this happening? Does it happen in other versions of Mathematica?

• On Win7-x64 running v12.2.0, I see this.
– Syed
Jan 29, 2023 at 18:14
• Both v11.3 and 13.0 on Windows 10 give the correct result. Jan 29, 2023 at 18:16
• Thanks all, good to see! Jan 29, 2023 at 18:17
• v13.2.0 on MacOS 13.2 also gives the correct answer. Jan 29, 2023 at 18:21

The closest version that I have to yours is

\$Version

(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)

Clear["Global*"]

RepeatedTiming[
Integrate[-Log[Abs[1 - x]]/(x(2 - x)),
{x, 0, Infinity}]]

(* {8.69404, (3 π^2)/8} *)

RepeatedTiming[
Integrate[-Log[RealAbs[1 - x]]/(x(2 - x)),
{x, 0, Infinity}]]

(* {8.93449, (3 π^2)/8} *)


However, since

Assuming[x ∈ Reals, Abs[1 - x] == Sqrt[(1 - x)^2] // Simplify]

(* True *)


then

RepeatedTiming[
Integrate[-Log[Sqrt[(1 - x)^2]]/(x(2 - x)),
{x, 0, Infinity}]]

(* {0.851492, (3 π^2)/8} *)
`

This form is much faster which indicates that it is much easier to work with. Check whether your version/OS gives the correct result with this alternate representation.

• Great thinking! I'm getting the correct answers now. I'll have to remember this as an alternative to Abs. Jan 29, 2023 at 18:42