# Why does this lead to zero when integrating a non-negative function?

When I try to integrate this $$\int_0^{1} \frac{\log ^2(x+1) \log ^2(1-x)}{x} \, dx$$, it leads to 0.

And when I use NIntegrate, it turns into a positive number, which seems to be right.

The codes are shown below.

Clear["Global`*"];
Plot[Log[1 + x]^2 Log[1 - x]^2/x, {x, 0, 1}]
Integrate[Log[1 + x]^2 Log[1 - x]^2/x, {x, 0, 1}]
NIntegrate[Log[1 + x]^2 Log[1 - x]^2/x, {x, 0, 1}]
• Setting $x=0$ and $x=1$ gives Indeterminate and Infinity. In v12.3.1 it doesn't return zero - it can't work out the integral. Sep 14, 2021 at 12:18
• Rubi and Maple 2021 fail with it, returning the input. Sep 14, 2021 at 13:24
• @flinty - with v12.3.1 on my Mac I get zero for Integrate (after a long wait). Sep 14, 2021 at 13:40
• Confirm it in 12.3.1 on Windows 10 Pro. Sep 14, 2021 at 13:43
• One can obtain an analytical expression for this integral thrugh Integrate[Log[1 + x]^2 *x^k/x, {x, 0, 1}, Assumptions -> k \[Element] PositiveIntegers] which results in (1/(6 k))(-1)^-k (6 EulerGamma^2 + \[Pi]^2 - 24 k HypergeometricPFQ[{1, 1, 1, 1 - k}, {2, 2, 2}, 2] - 6 Log[2]^2 + 6 (-1)^k Log[2]^2 + 6 k HypergeometricPFQ[{1, 1, 1 - k}, {2, 2}, 2] Log[16] + 12 EulerGamma PolyGamma[0, 1 + k] + 6 PolyGamma[0, 1 + k]^2 - 6 PolyGamma[1, 1 + k]). Sep 14, 2021 at 13:45

I cannot answer why, but I can provide an analytical solution with MA. We have

$$\int_0^1 \frac{\log ^2(1-x) \log ^2(x+1)}{x} \, dx= \frac{1}{12} \int_0^1 \frac{\log ^4\left(1-x^2\right)}{x} \, dx +\frac{1}{12} \int_0^1 \frac{\log ^4\left(\frac{1-x}{x+1}\right)}{x} \, dx -\frac{1}{6} \int_0^1 \frac{\log ^4(1-x)}{x} \, dx -\frac{1}{6} \int_0^1 \frac{\log ^4(x+1)}{x} \, dx.$$

Each of them can be correctly computed with MA

i1 = 1/12 Integrate[Log[1 - x^2]^4/x, {x, 0, 1}]
(*Zeta[5]*)
i2 = 1/12 Integrate[Log[(1 - x)/(1 + x)]^4/x, {x, 0, 1}]
(*(31 Zeta[5])/8*)
i3 = -1/6 Integrate[Log[1 - x]^4/x, {x, 0, 1}]
(*-4 Zeta[5]*)
i4 = -1/6 Integrate[Log[1 + x]^4/x, {x, 0, 1}]
(*1/6 (-(2/3) \[Pi]^2 Log[2]^3 + (4 Log[2]^5)/5 + 21/2 Log[2]^2 Zeta[3] +
24 (Log[2] PolyLog[4, 1/2] + PolyLog[5, 1/2] - Zeta[5]))*)

Combining together we obtain

i = i1 + i2 + i3 + i4

$$4 \text{Li}_5\left(\frac{1}{2}\right)+\text{Li}_4\left(\frac{1}{2}\right) \log (16)-\frac{25 \zeta (5)}{8}+\frac{7}{4} \zeta (3) \log ^2(2)+\frac{2 \log ^5(2)}{15}-\frac{1}{9} \pi ^2 \log ^3(2).$$

• Could you ground that the integral under consideration equals i1+i2+i3+i4 in order to complete your answer? TIA. Sep 14, 2021 at 21:38
• @user64494 Does FullSimplify[Log[1 - x^2]^4/(12 x) + Log[(1 - x)/(x + 1)]^4/(12 x) - Log[1 - x]^4/(6 x) - Log[1 + x]^4/(6 x), Assumptions -> 0 < x < 1] which results in (Log[1 - x]^2 Log[1 + x]^2)/x provide the desired justification?
– JimB
Sep 14, 2021 at 21:53
• @JimB: Yes. Thank you. Sep 14, 2021 at 22:00
• BTW, now Integrate[Log[1 + x]^2 Log[1 - x]^2/x, {x, 0, 1}] returns the input. Sep 14, 2021 at 22:03
• @SHBookP You would do such a separation when solving the integral manually. The four integrals are easier to compute. It seems to be easier to MA as well. Concerning your second question, how they can be actually computed. These are popular integral types often discussed in math.stackexchange.com. Have a look at the solutions of simpler integral math.stackexchange.com/q/795867/435814 . If you ar interested in the manual solution, post your question there, you'll get the answer quick. For MA--post another question here. Sep 23, 2021 at 5:48