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: Showing the discrepancy

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:

Showing integral vanishes

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?

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

1 Answer 1


The closest version that I have to yours is


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


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

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

 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 *)


 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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.