40
$\begingroup$

Bug introduced in 11.3 and fixed in 12.0.0


Reported to Wolfram: [CASE:4032137]

These integrals evaluate in version 11.2 on windows but when I tried them under version 11.3 they returned unevaluated.,

What to do to make them evaluate under 11.3?

Integrate[Log[x^2 + Sqrt[1 - x^2]],x]
Integrate[(1 + x^2)/((1 - x^2)*Sqrt[1 + x^2 + x^4]),x]
Integrate[Sqrt[1 + p*x^2 + x^4]/(1 - x^4),x]
Integrate[Sqrt[d + e*x^2]/(x^2*(a + b*x^2 + c*x^4)),x]
Integrate[(x^2*(d + e*x^2)^(3/2))/(a + b*x^2 + c*x^4),x]
Integrate[x^4/((d + e*x^2)^(3/2)*(a + b*x^2 + c*x^4)),x]
Integrate[1/((d + e*x)^2*Sqrt[a + b*x^2 + c*x^4]),x]
Integrate[Sqrt[a + b*Sec[c + d*x]]/Sqrt[Cos[c + d*x]],x]
Integrate[(a + b*Sec[c + d*x])^(3/2)/Sqrt[Cos[c + d*x]],x]
Integrate[(a + b*Sec[c + d*x])^(5/2)/Sqrt[Cos[c + d*x]],x]
Integrate[1/(Cos[c + d*x]^(5/2)*Sqrt[a + b*Sec[c + d*x]]),x]
Integrate[(c + d*Sec[e + f*x])^(3/2)/Sqrt[a + b*Sec[e + f*x]],x]
Integrate[(Sec[e + f*x]*Sqrt[a + b*Sec[e + f*x]])/Sqrt[c + d*Sec[e + f*x]],x]
Integrate[Cos[c + d*x]^(3/2)*(a + b*Sec[c + d*x])^(3/2)*(A + B*Sec[c + d*x]),x]
Integrate[Cos[c + d*x]^(3/2)*(a + b*Sec[c + d*x])^(5/2)*(A + B*Sec[c + d*x]),x]
Integrate[((a + b*Sec[c + d*x])^(5/2)*(A + B*Sec[c + d*x]))/Cos[c + d*x]^(3/2),x]
Integrate[(A + B*Sec[c + d*x])/(Cos[c + d*x]^(5/2)*Sqrt[a + b*Sec[c + d*x]]),x]
Integrate[(A + B*Sec[c + d*x])/(Cos[c + d*x]^(5/2)*(a + b*Sec[c + d*x])^(5/2)),x]
Integrate[(A + B*Sec[c + d*x])/(Cos[c + d*x]^(7/2)*(a + b*Sec[c + d*x])^(5/2)),x]
Integrate[(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2)/(Sqrt[Cos[c + d*x]]*Sqrt[a + b*Sec[c + d*x]]),x]
Integrate[(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2)/(Cos[c + d*x]^(3/2)*Sqrt[a + b*Sec[c + d*x]]),x]
Integrate[(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2)/(Cos[c + d*x]^(3/2)*(a + b*Sec[c + d*x])^(5/2)),x]
Integrate[(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2)/(Cos[c + d*x]^(5/2)*(a + b*Sec[c + d*x])^(5/2)),x]
$\endgroup$
4
  • 8
    $\begingroup$ Is this intnded as a bug report? If so, it should go to [email protected] (if it has not been sent there already)? As a question for MSE it falls into the "requires advice from Wolfram support" category. $\endgroup$ Mar 18, 2018 at 14:07
  • 11
    $\begingroup$ @Nasser I am very much grateful to you for your experimental observation on this significant regression in Integrate in 11.3. Some people may dislike to see here "bug reports". However, there is no other place to see what has been broken in a new release. Personally for me it is very important to decide which version/release to use in my work when I need Integrate and which one to use for NSolve and which one to use for Det or Plot, etc. It is not a joke, unfortunately, that any of these functions can be broken in any given release. $\endgroup$
    – innaiz
    Mar 19, 2018 at 13:20
  • 2
    $\begingroup$ Community seems to be split as to what to do with this topic; the conversation has been moved to chat. I left two comments to indicate what this discussion is about. Here is also a link to relevant part from the main chat channel $\endgroup$
    – Kuba
    Mar 19, 2018 at 20:11
  • 1
    $\begingroup$ So untill it is settled I removed bugs as we can all agree it is not so obvious given the number of examples. $\endgroup$
    – Kuba
    Mar 20, 2018 at 6:35

4 Answers 4

14
$\begingroup$

I haven't check these integrals myself, but we did fix some bugs related to branch cuts where indeed incorrect answers were produced. My guess is that some of these indeed had subtle issues, and others were probably collateral damage where potentially problematic branch cut issues were avoided.

$\endgroup$
2
  • 1
    $\begingroup$ I have not had time to look carefully into these but I am pretty sure this is a correct assessment. There may be a few examples that fall outside this analysis. $\endgroup$ Mar 20, 2018 at 18:59
  • $\begingroup$ I don't have access to 11.2. Which of these give different outputs in 12.0? The outputs of the first and second ones, at least (based on the posts by gwr and Michael E2), appear to be unchanged. $\endgroup$
    – theorist
    Apr 25, 2019 at 2:02
25
$\begingroup$

Using Rubi in Mathematica 11.3.0

While the issue clearly is to be resolved eventually by WRI, a solution to the problem of obtaining symbolic solutions to indefinite integrals may be to use Rubi which is short for Rule-based Mathematics - Symbolic Integration Rules by Albert D. Rich. It is written in the Wolfram Language and can be easily used via a Notebook in 11.3.0.

After downloading the zip-file and extracting it into a directory of choice, there is a notebook called Rubi4.14.nb. Setting the parameter $LoadShowSteps = False; in the notebook to supress showing intermediate steps (for now), we can do:

Int[ Log[x^2 + Sqrt[1 - x^2]], x ]

-2 x-ArcSin[x]-Sqrt[1/10 (1+Sqrt[5])] ArcTan[Sqrt[2/(1+Sqrt[5])] x]+2 Sqrt[1/5 (2+Sqrt[5])] ArcTan[Sqrt[2/(1+Sqrt[5])] x]-Sqrt[1/10 (1+Sqrt[5])] ArcTan[(Sqrt[1/2 (1+Sqrt[5])] x)/Sqrt[1-x^2]]+2 Sqrt[1/5 (2+Sqrt[5])] ArcTan[(Sqrt[1/2 (1+Sqrt[5])] x)/Sqrt[1-x^2]]+2 Sqrt[1/5 (-2+Sqrt[5])] ArcTanh[Sqrt[2/(-1+Sqrt[5])] x]+Sqrt[1/10 (-1+Sqrt[5])] ArcTanh[Sqrt[2/(-1+Sqrt[5])] x]-2 Sqrt[1/5 (-2+Sqrt[5])] ArcTanh[(Sqrt[1/2 (-1+Sqrt[5])] x)/Sqrt[1-x^2]]-Sqrt[1/10 (-1+Sqrt[5])] ArcTanh[(Sqrt[1/2 (-1+Sqrt[5])] x)/Sqrt[1-x^2]]+x Log[x^2+Sqrt[1-x^2]]

In the same vein one can tackle the other integrals: Using the Rubi-notebook and its Int command each of Nasser's integrals can be integrated in Mathematica 11.3.0.

Optimal Antiderivatives?

Rather interesting is the comparison of results for the antiderivatives obtained using Mathematica 11.2.0 and Mathematica 11.3.0 using Rubi.

$Version
Integrate[(1 + x^2)/((1 - x^2)*Sqrt[1 + x^2 + x^4]), x] // FullSimplify // TraditionalForm

11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)

Integrate#2_V_11.2.0

$Version
Int[(1 + x^2)/((1 - x^2)*Sqrt[1 + x^2 + x^4]), x] // TraditionalForm

11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)

integrate2_V11.3.0rubi

The third integral will be an even more striking comparison: The output given by Mathematica 11.2.0 is rather too large to print (FullSimplify will take "forever") while the result obtained using Rubi fits neatly into a single line (appearing almost immediately):

11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)

Int#3_V_11.3.0_rubi

So let's wait for the Mathematicians about the validity of the results. But if the results obtained fast and neat using Rubi's rules of integration are valid, then we may see some truth in this classical verdict:

"Only the best is good enough." - Voltaire

References

$\endgroup$
6
  • 5
    $\begingroup$ To whom it may concern: There is a whole battery of test-integrations right there on the Rubi-website in Mathematica-Syntax published for at least a couple of years now. Why not use that on a regular basis for unit-testing and system-improvement? The performance of Rubi does look impressive in comparison. $\endgroup$
    – gwr
    Mar 19, 2018 at 19:17
  • $\begingroup$ Voltaire of course meant quite the opposite, so nil satis nisi optimum would be a more honest quote, albeit I do not know the source. But then again, Voltaire’s quote most often now is seen as a call for perfection in these competitive times. So there you are: panta rhei :) $\endgroup$
    – gwr
    Mar 20, 2018 at 7:06
  • 2
    $\begingroup$ Unfortunately, Rubi is not an universal tool, too. From my practice I have two complicated integrals which can be computed with Mathematica but cannot be computed using Rubi. The first integral can be computed with M versions 5, 8, 10 but not with M version 7 and not with Rubi. The second integral can be computed with M version 7 (only 32 bit, not 64 bit, fantastic) but not with M 5, 6, 8, 10 and not with Rubi. Concerning these 23 integrals of Nasser, I have checked that M version 8 (no M 11 at hand) computes correctly the integrals nimber 8--11 and 14--19 and returns other unevaluated. $\endgroup$
    – innaiz
    Mar 23, 2018 at 7:42
  • 1
    $\begingroup$ @innaiz But having a choice and more options then still is a good thing and better than looking at an unevaluated expression? $\endgroup$
    – gwr
    Mar 23, 2018 at 9:09
  • $\begingroup$ @innaiz can you please share that integral which can be solved only with version 7? $\endgroup$
    – Anixx
    Dec 25, 2019 at 20:42
16
$\begingroup$

Too long for a comment: It seems that V11.2 was slightly wrong about the first integral. I think an antiderivative ought to be differentiable, hence continuous, at least over the connected components of the domain of a continuous function. It seems the real part of the integral is a correct real integral, but strictly speaking Re[ad] is not differentiable. Better branch checking might make the V11.2 answer be rejected in V11.3, but that's just a guess.

Plot[Log[x^2 + Sqrt[1 - x^2]], {x, 0, 1}, PlotLabel -> Row[{"Version ", $Version}]]

Mathematica graphics

ad = Integrate[Log[x^2 + Sqrt[1 - x^2]], x];
Plot[Evaluate@ReIm@ad, {x, 0, 1}, PlotLabel -> Row[{"Version ", $Version}]]

Mathematica graphics

The discontinuity is at x == Sqrt[1/GoldenRatio]

ad /. x -> (Sqrt[1/GoldenRatio] - $MachineEpsilon)
ad /. x -> (Sqrt[1/GoldenRatio] + 0.)
ad /. x -> (Sqrt[1/GoldenRatio] + $MachineEpsilon)
ad /. x -> (Sqrt[1/GoldenRatio]) // FullSimplify
(*
  -1.99674 + 1.23488 I
  Indeterminate
  -1.83736 - 1.23488 I
  Indeterminate
*)

There is a branch cut on the real axis for x > 1, but I do not see how this justifies the discontinuity in the integral far away from x == 1 ("far away" = separated by open disks):

Plot3D[ReIm@Log[x^2 + Sqrt[1 - x^2]] /. x -> z + I y // Evaluate,
 {z, -0.1, 1.1}, {y, -1/2, 1/2},
 PlotLabel -> Row[{"Version ", $Version}], AxesLabel -> Automatic]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ I agree this is problematic. But (forgive me if I've misunderstood you) your post gives me the impression you view this as atypical behavior. Yet I've found that MMA's integrator does this often, when it generates more complicated integrals. Further, WRI's blog on this subject would seem to indicate they don't see the discontinuity "mismatch" between the integrand and integral as problematic (please see my answer below). $\endgroup$
    – theorist
    Apr 25, 2019 at 1:49
  • $\begingroup$ @theorist I can no longer test V11.2, but "wrong" and "atypical" have quite different meanings in my mind. My point was speculative, that the error in V11.2 was detectable (e.g. Plot detects it in V11.2) and that it might have been detected by improvements in V11.3. $\endgroup$
    – Michael E2
    Apr 25, 2019 at 2:05
11
$\begingroup$

It seems your voice has been heard! All of the integrals you list are now again evaluated, in MMA 12.0.0 (for Mac). Note, however, that the new outputs may not be different from those originally generated by 11.2.0. I don't have the latter running to do a comprehensive check, but 12.0.0 does give results identical to 11.2.0 for the examples shown in the posts by gwr and Michael E2.

Here is a table comparing the respective (unsimplified) leaf counts of the integrals in Nasser's table, in MMA 12.0.0 and Rubi 4.16.0.2 (running within MMA 12.0.0), respectively.

Rubi can evaluate all of these except for integral no. 12:

Int[(c + d*Sec[e + f*x])^(3/2)/Sqrt[a + b*Sec[e + f*x]],x]

The MMA results for the remaining 22 integrals are, on average, substantially (160–fold, by leaf count) larger than those from Rubi. Evaluating all 22 integrals together in a single cell on a fresh kernel takes 19 times longer in MMA than Rubi.

enter image description here [Equipment: Mid-2014 MacBook Pro, 2.8 GHz Core i7 (4980HQ Haswell/Crystalwell), MacOS 10.13.6 (High Sierra).]

One other notable distinction between MMA and Rubi (referring to Michael E2's post) is that, when the integrand has non-integrable singularities, Rubi typically (though not always) returns antiderivatives whose discontinuities "match" (i.e., occur at the same points in the domain) those of the integrand, while MMA (especially for more complicated antiderivatives) often does not. Furthermore, I've found that, for intervals over which an integrand is real-valued, Rubi's integrals are much more likely to be real-valued than MMA's (unless the integral is relatively simple, in which case both will be real-valued). For instance, here is the integrand from Michael E2's example (integrand no. 1 from Nasser's list):

expr = Log[x^2 + Sqrt[1 - x^2]];
intRUBI = Int[expr, x];
Plot[{expr, intRUBI}, {x, -2, 2}, PlotRange -> All, PlotLegends ->    {"integrand", "Rubi integral"}]

enter image description here

Here's a related example, taken from a WRI blog, of an integrand that is continuous on the reals, but has simple poles elsewhere in the complex plane (https://blog.wolfram.com/2008/01/19/mathematica-and-the-fundamental-theorem-of-calculus/):

expr = 1/(5 + 4 Sin[x]);
intRUBI = Int[expr, x];
intMMA = Integrate[expr, x];
Plot[{expr, intRUBI, intMMA}, {x, -10, 10}, PlotRange -> All, PlotLegends -> {"integrand", "Rubi integral", "MMA integral"}]//Quiet

enter image description here

Note the blog is from 2008, and doesn't mention Rubi, which may not have yet been publicly released; it just happens that the "alternative" antiderivative to which the author compares the MMA result is the one that Rubi generates. Let's call the integrand $\mathcal{h}(z)$, and its MMA and Rubi antiderivatives $\mathcal{H}_1(z)$ and $\mathcal{H}_2(z)$, respectively.

An implicit message of the blog seems to be that $\mathcal{H}_1(z)$'s discontinuities on the reals do not make it an inferior result to $\mathcal{H}_2(z)$, since if the integrand has simple poles, discontinuities somewhere in the antiderivative are unavoidable: "Moreover, if a meromorphic integrand $\mathcal{h}(z)$ has simple poles in the complex plane, it is impossible to choose an antiderivative $\mathcal{H}(z)$ continuous along every imaginable path in the complex plane–because of branch cuts in $\mathcal{H}(z)$."

Specifically, the author explains that while $\mathcal{H}_1(z)$ may have discontinuities in the reals that aren't present in $\mathcal{H}_2(z)$, $\mathcal{H}_2(z)$ has discontinuities elsewhere in the complex plane that aren't present in $\mathcal{H}_1(z)$. For instance, he shows that $\mathcal{H}_2(z)$ has a discontinuity at $z = \frac{3}{2} + i \ln(2)$, while $\mathcal{H}_1(z)$ does not. I.e., it's a wash.

However, this notion (that $\mathcal{H}_1(z)$ and $\mathcal{H}_2(z)$ are equivalent merely because they both have discontinuities) doesn't make sense to me, since it ignores the importance of where the discontinuities occur. Here there is a choice between an antiderivative that is continous along the reals and one that is not, and I think the former is typically a more convenient choice. Yet, even when an antiderivative that is continous on the reals exists (which is generally the case if the integrand is continous on the reals*), Mathematica often instead provides one that is not.

*With the possible exceptions, as Daniel Lichblau points out, of "complex-analytic antiderivatives, or a different notion of integral e.g as might exist in the world of generalized functions".

$\endgroup$
8
  • $\begingroup$ The last paragraph, about branch cut discontinuities only existing at integrand discontinuities, is a mathematical impossibility. The cuts run between singularities. $\endgroup$ Apr 25, 2019 at 14:03
  • $\begingroup$ My understanding is that, by the Fundamental Theorem of Calculus, if an integrand is continuous on an interval, then there must exist an antiderivative also continuous on that interval. Thus if there is no integrand discontinuity on an interval, there must exist an antiderivative that has no discontinuities there as well. Hence, for instance, if the integrand is continuous on the reals, then there must exists an antiderivative continuous on the reals. $\endgroup$
    – theorist
    Apr 25, 2019 at 15:51
  • $\begingroup$ 1/x is continuous away from the origin. Nonetheless there must be a branch cut for the antiderivative. running through that region. $\endgroup$ Apr 25, 2019 at 17:14
  • $\begingroup$ Of course. But: $1/x$ is continuous away from the origin, i.e. it is continuous on the intervals $(-\infty, 0)$ and ($0,\infty)$. Thus, by FTC, there must exist antiderivatives continuous on each of those intervals. I.e., the integrand's singularity at $x=0$ doesn't necessitate a discontinuity in the antiderivatives anywhere other than at that point. $\endgroup$
    – theorist
    Apr 25, 2019 at 21:26
  • $\begingroup$ That is simply not correct. (Exercise: design a logarithm function that is continuous except at 0 and infinity.) $\endgroup$ Apr 25, 2019 at 21:32

Your Answer

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

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