# Strategy tips for time consuming FullSimplify, crashing FullSimplify, and strange behavior of TimeConstraint

I am trying to simplify a complicated integration result containing both error functions and MeijerG - I give the full expression below. A simple FullSimplify[expression,{x>0,y>0,z>0}] would run for about one day and then simply crash the kernel without returning any result. I have been trying to play around with the TimeConstraint parameter. I started multiple runs at the same time, with TimeConstraint->{10000n,10000n} for n=1,5,9.

Weirdly, the one for n=9 which should have run the longest already finished after just a few minutes without significant simplification and the warning message (note the negative sign!)

"FullSimplify::time: Time spent on a transformation exceeded -2.95596 10^12 seconds, and the transformation was aborted. Increasing the value of TimeConstraint option may improve the result of simplification."

The one for n=1 crashed after a few minutes without result. The one for n=5 is still running.

Any guesses what causes this erratic behavior? What is the best way to use TimeConstraint (specifically, what is the best ration between the local and total time parameter)?

And what is the best strategy to find out if a result like this can be further simplified? I did a regular Simplify first, of course. I guess I could split the expression into separate terms, but my suspicion is that some of them only yield a simpler expression when taken together with the other terms.

Would be happy for any ideas.

Here is the function (where I know that x, y, z are positive reals):

((x*Erf[2*x*z - y*z]*((2*Pi*(x - y)*(E^(2*x^2)*(-1 + Sqrt[2*Pi]*x)*(3*x - y)
+ Pi*x*(1 - 6*x^2 + 2*x*y)*Erfi[Sqrt[2]*x]
+ x*(-1 + 6*x^2 - 2*x*y)*ExpIntegralEi[2*x^2]))/E^(2*x^2)
- MeijerG[{{0, 1/2}, {}}, {{1/2, 1, 1}, {}}, 2*x^2]
+ 2*((x - y)^2*MeijerG[{{0, 1/2, 1}, {}}, {{1/2, 1}, {}}, -(1/(Sqrt[2]*x)), 1/2]
+ x*(-2*(x - y)*MeijerG[{{1/2, 1, 1}, {}}, {{1, 3/2}, {}}, -(1/(Sqrt[2]*x)), 1/2]
+ x*MeijerG[{{1, 1, 3/2}, {}}, {{3/2, 2}, {}}, -(1/(Sqrt[2]*x)), 1/2]))))/E^(2*(x - y)^2)
- (x*Erf[(2*x + y)*z]*((2*Pi*(x + y)*(E^(2*x^2)*(-1 + Sqrt[2*Pi]*x)*(3*x + y)
+ Pi*x*(1 - 6*x^2 - 2*x*y)*Erfi[Sqrt[2]*x]
+ x*(-1 + 6*x^2 + 2*x*y)*ExpIntegralEi[2*x^2]))/E^(2*x^2)
- MeijerG[{{0, 1/2}, {}}, {{1/2, 1, 1}, {}}, 2*x^2]
+ 2*((x + y)^2*MeijerG[{{0, 1/2, 1}, {}}, {{1/2, 1}, {}}, -(1/(Sqrt[2]*x)), 1/2]
+ x*(-2*(x + y)*MeijerG[{{1/2, 1, 1}, {}}, {{1, 3/2}, {}}, -(1/(Sqrt[2]*x)), 1/2]
+ x*MeijerG[{{1, 1, 3/2}, {}}, {{3/2, 2}, {}}, -(1/(Sqrt[2]*x)), 1/2]))))/E^(2*(x + y)^2))/(2*Pi*x^2)
• Side point: Crashing is not acceptable behavior for any software, definitely not a Wolfram Language "feature" people should be able to help you with here. If you are experiencing a reproducible crash, that should be reported to Wolfram Support. People here may help to report if the crash is reproduced in different systems though. Commented Sep 8, 2021 at 8:50
• Thank you rhermans for the suggestion, I will consider that. In the meantime, it turns out that I have a bigger problem with Mathematica than I thought. The above result of Integrate[] seems to make no sense, so I need to go back through my entire calculation before trying to simplify further. I am, however, still thankful for tips regarding general strategy for FullSimplify, especially with special functions like Erf, MeijerG, ... Commented Sep 8, 2021 at 12:12
• I suggest you edit your question and make it simpler and focused to the point where you need help. Emphasize the question if possible for easier reading. Commented Sep 8, 2021 at 12:15
• Crashing is the normal behaviour for Mathematica 13 /Windows 10 if memory use grows beyond limits. Check your events. For me, illegal read attempt caused by Mathematica kernel. Rare occurence after RAM extension to max. Mathematica.exe, Version: 13.3.1994.37172, Time 0x647b6fae Modul: Mathematica.exe, Version: 13.3.1994.37172, time stamp: 0x647b6fae Exceptioncode: 0xc0000005 Commented May 24 at 7:36
• I never run any command in MA for more than 5 mins. Only with one exception, when many simple calculations in a loop. If you do not get a quick answer, try to approach problem in a different way. How knowing a simpler form will help you with next steps? Commented Jun 23 at 9:39

Reduce combinatorial explosion of transformations to check

Simplify[Simplify[expr, TimeConstraint -> 0.1]]
FullSimplify[FullSimplify[expr, TimeConstraint -> 0.1]]
FullSimplify[Simplify[expr]]
etc.

In cases where the inner simplification makes many simple simplifications, the gain in speed seems remarkable.

That is not the case here.

Specific issues

One is that FunctionExpand[] on the Meijer $$G$$ expressions take 15-25+ sec. Further the ones that result in transformations are not simpler, and FullSimplify[] would reject them. The way FullSimplify[] works on subexpressions means that such transformations might be tried more than once.

I think I had something else to say, but the browser ate my answer. In any case, I think the given expression is nearly as simple as possible.

Oh, yes, I remember!

Save 5 leaves:

LeafCount[expr // Simplify]
LeafCount[Assuming[{x > 0, y > 0, z > 0},
MeijerGReduce[expr, x] // Activate // Simplify
]]
(*
480
475
*)

Here expr is the OP's example expression.

Break up your expression. Its a product. Apply List and get the last element. Its a Plus, apply a List to it,

The best I get is by an extraction of the innermost expression

q = MeijerGReduce[pl = p[[-1, -1]], x]