Sometimes FullSimplify takes a really long time and it is not really clear if it makes sense to wait another half an hour in hopes for it to finish, or if it will actually take three years in which case cancelling it and improving the approach would be the way to go. Having a progress bar in place, which shows the percent of calculation per unit of time (and maybe even a time prediction until finish) would be highly useful to make such decisions. I looked online and found a few links talking about progress bars. However, these realizations rely on an explicit iterator to keep track of. My interest is solely in monitoring the FullSimplify function and I do not know of any iterator to access there. So basically, I guess my question is:

Is there any way to predict how much time FullSimplify will need to finish in each case?

  • 1
    $\begingroup$ Use the TimeConstraint option $\endgroup$
    – Bob Hanlon
    Commented Oct 9, 2015 at 16:54
  • 3
    $\begingroup$ Not sure if I'm confusing something, but I guess if the simplification knew how long it will take to finish it would also know the most simplified result, hence not needing any more simplification. To me, the only option is using the TimeConstraint as suggested by @BobHanlon $\endgroup$
    – Lukas
    Commented Oct 9, 2015 at 17:27
  • $\begingroup$ @Lukas I am pretty sure FullSimplify iterates through a finite set of substitution rules. Given a starting size of an input it might be able to produce a worst case scenario estimate of required iterations and then update it while the expression is being simplified. $\endgroup$
    – Kagaratsch
    Commented Oct 9, 2015 at 17:51
  • $\begingroup$ One could also simply just take the inverse of the leaf count and consider an unattainable upper bound like 1 and measure how close the inverse of the leaf count is to 1 $\endgroup$ Commented Dec 26, 2022 at 6:23

1 Answer 1


I don't think it is possible for FullSimplify to assess how far it is from a meaningful reduction of complexity. At every stage parts of the expression may after some transformation cancel (or not).

Sometimes complexity has to be increased before it can be lowered (as I showed in this answer). Simplification is the process of minimizing complexity, where the complexity function has numerous local minimums. This is basically a very difficult and unpredictable problem.

To have some kind of progress indication you could provide FullSimplify with a ComplexityFunction of your own, one which stores the complexity of the expressions fed through it:

lc = {}; (* List to store intermediate complicity values *)
myLeafCount[expr_] := Module[{c}, AppendTo[lc, c = LeafCount[expr]]; c]

The Automatic method is slightly more complicated than LeafCount (you can find it at the bottom of the ComplexityFunction page), but for a demonstration this suffices.

First, lets pick a function to simplify. This question has a nice, complex one:

expr = x[t] /. 
   DSolve[{z'[t] == d (x[t] + u) - k (z[t] + s), 
     y'[t] == -R*x[t] v - R y[t] u - R u v + k (1 - c (x[t] + u) - (y[t] + v)), 
     x'[t] == R x[t] v + R y[t] u + R u v - x[t] - u}, 
     {y[t], z[t], x[t]}, t];

It has a huge LeafCount:

(* 34464 *)

Then we generate a dynamic plot of the intermediate results


and we start the simplification:

FullSimplify[expr, ComplexityFunction -> myLeafCount]

We get a refresh of the plot for every call to myLeafCount.

After 20 steps:

Mathematica graphics

100 steps:

Mathematica graphics

1,000 steps (note Mathematica rescales the plot to show the parts it thinks are most interesting):

Mathematica graphics

10,000 steps:

Mathematica graphics

100,000 steps:

Mathematica graphics

200,000 steps:

Mathematica graphics

and after a few hours it ends at 312,893 steps:

Mathematica graphics

with a result that has a LeafCount of 727.

As you can see there are quite a few very similar patterns in it. My guess it is trying various permutations of sub-expressions recursively.

Although this is a poor substitute for a progress bar (especially given that it is still difficult to see when it will finish), it will give you some indication of what's going on and whether the simplification process got stuck somewhere.

I guess this all should also suffice to show why it would be very difficult to make a real progress bar.

  • 4
    $\begingroup$ Enjoyed reading it..+1 $\endgroup$ Commented Oct 11, 2015 at 3:20
  • $\begingroup$ I think Windows 95 taught us that progress bars, even for simple things like copying or downloading files, can be quite deceptive! Fascinating answer. $\endgroup$ Commented Jun 19, 2017 at 4:37
  • $\begingroup$ After so many years I keep using this trick, so beautiful! +1 $\endgroup$
    – Massimo
    Commented Feb 4, 2021 at 11:56
  • 1
    $\begingroup$ The repetitive patterns in these graphs make me suspicious that FullSimplify does not re-use any intermediate results, and often repeats simplifications of the same sub-expression. If that's true, it seems like an extremely effective optimization has not been implemented. Of course, there are always trade-offs of memory vs time, but caching at least some intermediate results seems very obviously worth it. $\endgroup$ Commented May 25, 2023 at 23:58

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.