I noticed that when I call
Integrate for the first time, on an integral that I know will take longer than the time limit I give it, it will abort for the first time, as expected when wrapped by
TimeConstrained. But on the third try (not the second!), it will return the antiderivative very quickly within the same time limit.
This tells me that
Integrate seems to be loading things or caching things each time it is called?
Is it possible to somehow start each call of
Integrate fresh, as the first call, but without restarting the kernel? Here is an MWE. Run the following from a fresh kernel:
res = AbsoluteTiming[ TimeConstrained[Integrate[ (Sqrt[1 - x]*x*(1 + x)^(2/3))/(-((1 - x)^(5/6)*(1 + x)^(1/3)) + (1 - x)^(2/3)*Sqrt[1 + x]), x], 500 $TimeUnit]]
Here is a screen shot
An interesting thing is that I needed 3 calls to get an answer. You might have to adjust the multiplier on
$TimeUnits on your PC. For me,
500 seems to work just right for this illustration.
Using 11.1 on Windows 7, 64 bit.
I am trying to get predictable results each time, and would like the next integral calls not to be affected by the previous integral calls made in terms of timing.