5
$\begingroup$

Report to WRI [CASE:5169570]


May be someone with better debugging skills than me in Mathematica internals could figure what causes this. This integral worked OK in V 14.0 but now in V 14.1 it gives

 SystemException[MemoryAllocationFailure]

With message in console saying

Throw::sysexc: Uncaught SystemException returned to top level. Can be caught with Catch[\[Ellipsis], _SystemException].

Clearly this is some kind of regression ( I will report to WRI). BUt may be someone here can figure what causes it or if there is something a user can do to fix it using some option setting?

Does it happen on Linux or the mac? I am using windows 10. I have 128 GB RAM. So memory should not an issue.

ClearAll["Global`*"];
integrand = (a + a*Sec[e + f*x])^m*(d*Sec[e + f*x])^(1/2);
Integrate[integrand, x]

Screen shots

enter image description here

enter image description here

To answer comment about if V 14.0 result was correct or not. I could not verify it. So it looks not correct.

(* V 14 on windows *)
ClearAll["Global`*"];
integrand = (a + a*Sec[e + f*x])^m*(d*Sec[e + f*x])^(1/2)
anti = Integrate[integrand, x];
PossibleZeroQ[RootReduce[Cancel[Together[D[anti,x]-integrand]]]]

(* False *)

Tried few other attempts, but can't verify it.

Update

I found second one

integrand = Cos[e + f*x]^5*(a + b*Sec[e + f*x]^2)^p;
Integrate[integrand, x]

(*SystemException["MemoryAllocationFailure"]*)

But thanks to suggestion below by Carl, changing "IntegrateOptions" now the internal error is gone:

enter image description here

$\endgroup$
8
  • $\begingroup$ Is the previous result correct? Personally, I'm not inclined to say running out of memory is a bug. It may be a backslide (maybe localized to a specific example). It may be the change an enhancement on a hundred other cases. I don't think I could figure that out as an end-user. It's worth reporting, sure, since it may actually be a bug for all I know. $\endgroup$
    – Michael E2
    Commented Aug 9 at 22:45
  • $\begingroup$ @MichaelE2 V 14.0 result seems not to be correct. I was not able to verify it. I will remove the bugs tag now also until verified. But for me, kernel crash is really a bug, at least from user point of view :) $\endgroup$
    – Nasser
    Commented Aug 9 at 23:04
  • 1
    $\begingroup$ The input line number reset to 1, if the kernel crashes. That's how I know. Also, since I usually set $HistoryLength = 5 when I start the kernel, I can see if $HistoryLength is 5 or infinity. That's how I tell. The reason your loop stopped is that an uncaught Throw[] returns all the way to the top level, effectively aborting the evaluation. When there's an operating system error or "exception" that Mathematica has no control over, like needing too much memory, the user can Catch a SystemException and respond as they see fit.... $\endgroup$
    – Michael E2
    Commented Aug 9 at 23:41
  • 1
    $\begingroup$ ....You might consider changing your loop to something like Catch[Integrate[ ...], _SystemException, $Failed &] or Catch[Integrate[integrand, x], _SystemException, Failure[#2, <|"value" -> #1|>] &] $\endgroup$
    – Michael E2
    Commented Aug 9 at 23:41
  • 2
    $\begingroup$ You could try increasing the time constraint, e.g. SetSystemOptions[ "IntegrateOptions" -> "IntegrateAlgebraicTimeConstraint" -> 100] $\endgroup$
    – Carl Woll
    Commented Aug 10 at 0:49

1 Answer 1

5
$\begingroup$

The execution takes exceptional long time. This is the case since vs 11 generally, if special complex functions with a tail of conditions on the domains are implied.

Instead of the earlier versions intention do deliver a formal algebraic expression in minimal time, now any internal call of a special function checks for cases of domains or known values in order to yield an exact equation.

As a poisoned gift to the unexperienced user, the new integration packages are buggy, too, stepwise repair left to complaints of users.

Version 6.0

   integrand = (a + a*Sec[e + f*x])^m*(d*Sec[e + f*x])^(1/2);
     Integrate[integrand, x]^2 // FullSimplify

$$\frac{4 d}{f^2}\ \tan ^2 \left(\frac{1}{2} (e+f x)\right) \left(1-\tan ^2\left(\frac{1}{2} (e+f x)\right)\right)^{2 m} (a (\sec (e+f x)+1))^{2 m} F_1\left(\frac{1}{2};m+\frac{1}{2},\frac{1}{2};\frac{3}{2};\tan ^2\left(\frac{1}{2} (e+f x)\right),-\tan ^2\left(\frac{1}{2} (e+f x)\right)\right){}^2$$

in zero sec.

We have a standard substitution case

 (t^2 -> Tan[y/2]^2,  Cos[y]->(1-t^2)/(1+t^2), 2 dt -> (1+t^2) dy} 

 integrand = (a + a*Sec[e + f*x])^m  (d*Sec[e + f*x])^(1/2) dx

 Assuming[m \[Element] PositiveIntegers && 0 < t < 1, 
  FullSimplify[
        (integrand //. 
           {e + f x -> y,  dx -> dy/f, 
              Sec[y] -> (1 + t^2)/(1 - t^2), 
               dy -> (2 dt)/(1 + t^2)})^2]]

$$-\frac{d 4^{m+1} \left(\frac{a}{t^2-1}\right)^{2 m}}{f^2 \left(t^4-1\right)} \ \text{dt}^2$$

Rearranging and concentrating to the integral

  \[Integral]1  /( Sqrt[1 + t^2] (1 - t^2)^(m + 1/2)) \[DifferentialD]t //
   FullSimplify

$$t \ F_1\left(\frac{1}{2};m+\frac{1}{2},\frac{1}{2};\frac{3}{2};t^2,-t^2\right) /. \{t \to \tan\left(\frac{1}{2}(e + f*x)\right\}$$

Caveat: I didn't check anything.

$\endgroup$
1
  • $\begingroup$ Nice tip! Here's one in return: Integrate[integrand, x, GenerateConditions -> False] cuts out the extra checking. This first time I tried it, it returned with an answer in a second or two. But when I tried again after restarting the kernel, I got the memory allocation failure. Oh well, I thought you gave me a solution. $\endgroup$
    – Michael E2
    Commented Aug 10 at 12:00

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.