# Some indefinite integrals evaluate in 11.2 but not in 11.3 - what can be done?

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]

• Is this intnded as a bug report? If so, it should go to support@w.c (if it has not been sent there already)? As a question for MSE it falls into the "requires advice from Wolfram support" category. – Daniel Lichtblau Mar 18 '18 at 14:07
• @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. – innaiz Mar 19 '18 at 13:20
• 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 – Kuba Mar 19 '18 at 20:11
• So untill it is settled I removed bugs as we can all agree it is not so obvious given the number of examples. – Kuba Mar 20 '18 at 6:35

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.

• 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. – Daniel Lichtblau Mar 20 '18 at 18:59
• 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. – theorist Apr 25 '19 at 2:02

# 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)] ArcTan[Sqrt[2/(1+Sqrt)] x]+2 Sqrt[1/5 (2+Sqrt)] ArcTan[Sqrt[2/(1+Sqrt)] x]-Sqrt[1/10 (1+Sqrt)] ArcTan[(Sqrt[1/2 (1+Sqrt)] x)/Sqrt[1-x^2]]+2 Sqrt[1/5 (2+Sqrt)] ArcTan[(Sqrt[1/2 (1+Sqrt)] x)/Sqrt[1-x^2]]+2 Sqrt[1/5 (-2+Sqrt)] ArcTanh[Sqrt[2/(-1+Sqrt)] x]+Sqrt[1/10 (-1+Sqrt)] ArcTanh[Sqrt[2/(-1+Sqrt)] x]-2 Sqrt[1/5 (-2+Sqrt)] ArcTanh[(Sqrt[1/2 (-1+Sqrt)] x)/Sqrt[1-x^2]]-Sqrt[1/10 (-1+Sqrt)] ArcTanh[(Sqrt[1/2 (-1+Sqrt)] 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) $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) 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) 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 • 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. – gwr Mar 19 '18 at 19:17 • 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 :) – gwr Mar 20 '18 at 7:06 • 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. – innaiz Mar 23 '18 at 7:42 • @innaiz But having a choice and more options then still is a good thing and better than looking at an unevaluated expression? – gwr Mar 23 '18 at 9:09 • @innaiz can you please share that integral which can be solved only with version 7? – Anixx Dec 25 '19 at 20:42 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}]] ad = Integrate[Log[x^2 + Sqrt[1 - x^2]], x];
Plot[Evaluate@ReIm@ad, {x, 0, 1}, PlotLabel -> Row[{"Version ", $Version}]] 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] • 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). – theorist Apr 25 '19 at 1:49
• @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. – Michael E2 Apr 25 '19 at 2:05

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. [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"}] 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 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. Instead, I think it is functionally superior to have an antiderivative whose discontinuities occur only where there are also discontinuities in the integrand. For instance, if the integrand is continuous on the reals, it is convenient to have an antiderivative that is likewise continuous along the reals, so that one does not have to do a piecewise integration there. [Note also that $$\mathcal{H}_2(z)$$'s discontinuity at $$z = \frac{3}{2} + i \ln(2)$$ matches that of $$\mathcal{h}(z)$$.]

• The last paragraph, about branch cut discontinuities only existing at integrand discontinuities, is a mathematical impossibility. The cuts run between singularities. – Daniel Lichtblau Apr 25 '19 at 14:03
• 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. – theorist Apr 25 '19 at 15:51
• 1/x is continuous away from the origin. Nonetheless there must be a branch cut for the antiderivative. running through that region. – Daniel Lichtblau Apr 25 '19 at 17:14
• 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. – theorist Apr 25 '19 at 21:26
• That is simply not correct. (Exercise: design a logarithm function that is continuous except at 0 and infinity.) – Daniel Lichtblau Apr 25 '19 at 21:32