10
$\begingroup$

Bug introduced in version 12.0.0, and persisting through 13.2.0 on Windows. Doesn't reproduce on ARM Mac versions 13.0.0 and above.


Calculating the integral $$\int\limits_0^1 \frac{x^2\log(1-x^4)} {1+x^4}\,dx$$ symbolically

Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}]

-4 + 2 Catalan - 1/4 \[Pi] (-2 + Log[8]) + Log[8]

N[%]

-0.151021

and numerically

NIntegrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}]

-0.162858

, I obtain different numbers and the difference is too much for round-off errors. How to preclude the end of math?

$\endgroup$
8
  • $\begingroup$ This is a bug worth reporting to Support. In 11.3, Integrate[] returns the (complicated but) correct answer, so something happened in between that version and 12.2. (Someone else who can check 12 and 12.1 should add the requisite bug header to this question.) $\endgroup$ Commented Feb 26, 2021 at 8:29
  • $\begingroup$ Work correctly in MA 11.1.1 with the integration result $\frac{1}{144} \left(8 \left(6 \text{Hypergeometric2F1}^{(0,0,1,0)}\left(\frac{3}{4},1,\frac{7}{4},-1\right)+\sqrt{2} \log (8)-6 \sqrt{2} \log \left(2-\sqrt{2}\right)\right)+3 \sqrt{2} \left(-3 \pi ^2-8 \pi -2 \log ^2(8)+7 \pi \log (8)-6 (\pi -2 \log (8)) \log \left(2-\sqrt{2}\right)\right)\right)$ $\endgroup$
    – yarchik
    Commented Feb 26, 2021 at 8:41
  • $\begingroup$ Maple 2020.2 int gives the same result the the numerical one. This looks like bug in integrate. screen shot !Mathematica graphics -0.1628582917 + 0.*I $\endgroup$
    – Nasser
    Commented Feb 26, 2021 at 8:47
  • $\begingroup$ @Nasser: In fact, Maple reduces the integral under consideration to the sum of other integrals. $\endgroup$
    – user64494
    Commented Feb 26, 2021 at 8:50
  • $\begingroup$ Version 12.1 gives also: -0.162858 $\endgroup$ Commented Feb 26, 2021 at 9:13

5 Answers 5

8
$\begingroup$

This bug was introduced in version 12.0. Please submit bug report to [email protected] or https://www.wolfram.com/support/contact/

enter image description here

enter image description here

$\endgroup$
2
  • $\begingroup$ Submitted. No response. $\endgroup$
    – user64494
    Commented Feb 26, 2021 at 9:26
  • 1
    $\begingroup$ @user64494. General, you have to wait a few days. $\endgroup$ Commented Feb 26, 2021 at 15:22
4
$\begingroup$

One way:

Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, I, 1}]

N@%

(*  -0.162858 - 4.44089*10^-16 I  *)

Another way:

Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1/2, 1}]

N[%]

(*  -0.162858 - 2.28333*10^-16 I  *)
$\endgroup$
8
  • $\begingroup$ Thank you. It's interesting. The question arises: why Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, I, 1}]==Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0,1}]? The imaginary unit is a singularity (a branch point) of the integrand so the application of the Cauchy's theorem is not clear to me. Also we deal with improper integrals. The command Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, I, 1}] returns the input on my comp in several minutes. As far as I understand it, you simply do NIntegrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, I, 1}]. $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 6:13
  • $\begingroup$ The same issue with Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1/2, 1}]. Corollary: this is not it. $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 6:53
  • $\begingroup$ -1. I repeat again: you calculate its numerical value in a weird way only. The symbolic result is not obtained. $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 10:07
  • 1
    $\begingroup$ @user64494 You made a mistake. $\endgroup$
    – Michael E2
    Commented Feb 27, 2021 at 15:12
  • $\begingroup$ @user64494 your downvoting is unjustified and unfair. If you omit the evaluation with N[], the Integrate[] does return a (complicated!) symbolic result, which Michael has mercifully omitted. $\endgroup$ Commented Feb 27, 2021 at 17:06
4
$\begingroup$

The integration with help of Rubi gives after inserting the limits:

(1/(4*Sqrt[2]))*(Pi*Log[2] - Log[(Sqrt[2] + 1)^2]*Log[2] + 
PolyLog[2, -(Sqrt[2] + 1)^2] - PolyLog[2, (Sqrt[2] - 1)^4]/2 + 
Re[4*PolyLog[2, I*(Sqrt[2] - 1)] - 4*PolyLog[2, I*(Sqrt[2] + 1)] + 
PolyLog[2, (Sqrt[2] + 1)^2 + I/1000000000000]] + 
Im[-8*(PolyLog[2, I*(Sqrt[2] - 1)] + PolyLog[2, I*(Sqrt[2] + 1)]) + 
2*PolyLog[2, (Sqrt[2] + 1)^2 + I/1000000000000]]/2)

which I don't know how to further simplify. The small imaginary offset in the argument of the PolyLog 'pushes' the sign of its imaginary part to the positive side. Otherwise the numeric result would be wrong.

Addendum: the imaginary part of the mentioned PolyLog is

2*Pi*Log[Sqrt[2] + 1]

so the result can be written

(1/(4*Sqrt[2]))*( Pi^2/3 + Pi*(2*Log[Sqrt[2] + 1] + Log[2]) - 
2*Log[Sqrt[2] + 1]*(Log[Sqrt[2] + 1] + Log[2])-PolyLog[2, (Sqrt[2] - 1)^2] + 
PolyLog[2, -(Sqrt[2] + 1)^2] - (1/2)*PolyLog[2, (Sqrt[2] - 1)^4] + 
Re[4*PolyLog[2, I*(Sqrt[2] - 1)] - 4*PolyLog[2, I*(Sqrt[2] + 1)]]
-4*Im[PolyLog[2, I*(Sqrt[2] - 1)] + PolyLog[2, I*(Sqrt[2] + 1)]])

2.Addendum: The last may be further simplified to

(1/(4*Sqrt[2]))*(Pi^2/3 + Pi*Log[2]+2*Pi*Log[Sqrt[2]+1] - 
2*Log[1+Sqrt[2]]*Log[2*(1+Sqrt[2])]-2*PolyLog[2,(Sqrt[2]-1)^2] - (Sqrt[2]+1)*
LerchPhi[-(Sqrt[2]+1)^2,2,1/2]-(Sqrt[2]-1)*LerchPhi[-(Sqrt[2]-1)^2,2, 1/2])
$\endgroup$
1
  • $\begingroup$ Thank you. In fact, Rubi reduces the improper integral under consideration to other integrals through PolyLog. $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 6:05
3
$\begingroup$

Strangely, it works when done correctly via limit:

f[a_] = Assuming[0 < a < 1,
                 Integrate[(x^2 Log[1 - x^4])/(1 + x^4), {x, 0, a}]];
A = Limit[f[a], a -> 1, Direction -> "FromBelow"];
N[A]
(*    -0.162858 - 5.88785*10^-17 I    *)

$Version
(*    "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)"    *)

The Limit command throws a Limit::ztest warning though, which may indicate some trouble.

$\endgroup$
4
  • $\begingroup$ Roman(@ does not work.):+1. Thank you. f[a_] returns a big expression with many PolyLogs. I think Rubi finds that integral in such a way. Also that works with 0<a<=1 too, but Mathematica has problems with its evaluating for a->1: it returns (0.08838834764831844055010555+0.08838834764831844055010555 I) ((-0.9908537560314543211012304-0.1349401132293848328673948 I) \[Infinity]+(0.1349401132293848328673948+0.9908537560314543211012304 I) \[Infinity]+(0.5388161543132108251339676-0.8424233804038929803675840 I) \[Infinity]+... $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 13:24
  • $\begingroup$ @user64494 To quote the commenting instructions: "Note that the author of the post will always be notified of any new comment. You may still use it for clarity, if needed; however, if there are no comments, or only you or the author have commented on the post so far, the @name will be automatically removed from the beginning of the comment, as it adds no value. (To avoid breaking sentences, mentions not at the beginning will not be removed.)" $\endgroup$
    – Roman
    Commented Feb 27, 2021 at 14:40
  • $\begingroup$ @user64494 Concerning evaluation at $a=1$: yes, that's precisely why I used a Limit instead of simply asking for f[1]. Keep in mind that Mathematica returns general results that may be inapplicable on some special points, like $a=1$ in this case even if you specify the assumption $0<a\le1$. $\endgroup$
    – Roman
    Commented Feb 27, 2021 at 14:52
  • $\begingroup$ As I understand it, f[a_] produces a very long expression with many compound functions. Its evaluation exeeds some internal Mathematica limitations (something like $MaxIterations=100) and this causes problems. Maybe, it is possible to increase these limitations. $\endgroup$
    – user64494
    Commented Feb 27, 2021 at 16:16
1
$\begingroup$

From 13.2.0 we see that is takes a while

int = Integrate[
    x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}]; // AbsoluteTiming

time

and that the results agree

Chop[Chop@N[int] - NIntegrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}]]

0

I am providing the analytic result as well

int // ToRadicals // Factor

analytic

$\endgroup$
7
  • 1
    $\begingroup$ Fixed in 13.0.0, modified bug comment. $\endgroup$
    – kirma
    Commented Feb 4, 2023 at 9:43
  • $\begingroup$ Cannot reproduce it in 13.2 on Windows 10. I obtain int = Integrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}] // AbsoluteTiming results in {294.976, -4 + 2 Catalan - 1/4 \[Pi] (-2 + Log[8]) + Log[8]} and then Chop[Chop@N[int] [[2]]- NIntegrate[x^2*Log[1 - x^4]/(1 + x^4), {x, 0, 1}]] produces 0.0118378. Maybe, the result depends on a session. See dropbox.com/s/6m39559x8lia92i/… $\endgroup$
    – user64494
    Commented Feb 4, 2023 at 11:30
  • $\begingroup$ @user64494 not sure why this is happening. on my mac it worked fine as you can see. could be session-dependent as you said, but perhaps it relates to the OS(?). $\endgroup$
    – bmf
    Commented Feb 4, 2023 at 11:39
  • $\begingroup$ perhaps @kirma has access to windows to shed some light? $\endgroup$
    – bmf
    Commented Feb 4, 2023 at 11:39
  • 1
    $\begingroup$ @bmf No, I don't have access to Windows, sadly. It worked fine for me on all versions starting from 13.0 on Mac though... Could be that this is more convoluted than I first thought, but it worked fine on fresh kernels on my system. My Mac is ARM-based, by the way, and I think 13.0 was the first version with native support for ARM on Mac. $\endgroup$
    – kirma
    Commented Feb 4, 2023 at 11:45

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.