Get the intermediate steps of FullSimplify

Here is one way to extract some intermediate results:

expr = Log[i] > (i Log[i])/n + Log[n - i] - (i Log[n - i])/n;

Select[FullSimplify[expr == #] &]@
 Reap[
   FullSimplify[expr, TransformationFunctions -> {Automatic, Sow}]
 ][[2, 1]]

(* .{
  Log[i] > (i Log[i])/n + Log[-i + n] - (i Log[-i + n])/n,
  Log[i] > (i Log[i] + (-i + n) Log[-i + n])/n, 
  n (-i + n) (Log[i] - Log[-i + n]) > 0, 
  n (-i + n) (Log[i] - Log[-i + n]) > 0
} *)

As you can see, the steps are roughly:

  • Put everything on the right side in one fraction
  • Multiply by n, move the right side to the left and group terms

How it works

The idea is to add Sow to TransformationFunctions. This allows us to take note of most of the expressions that FullSimplify generates during the simplification. We then use Select to filter out those expressions that are equivalent to the initial expression. The other terms are subexpressions, which might also be useful, depending on how much detail you want. (If you want to look at them as well, just remove the Select[...]@ part)


It is a very old and very interesting task, which as far as I know still lacks a satisfactory solution. One of most interesting attempts is given in M. Trott's celebrated "The Mathematica Guide for Symbolic", page 1036. Here I provide slightly modified version of it

id = (Log[i] > (i Log[i])/n + Log[n - i] - (i Log[n - i])/n);

csc := (count1 = 0; count2 = 0; count3 = 0;
  lf = LeafCount[id];
  (*simplify and keep track of intermediate results*)
  FullSimplify[id, ComplexityFunction -> ((count1++;
         Which[LeafCount[#] === lf, count2++, LeafCount[#] < lf, 
          lf = LeafCount[#]; count2++; count3++]; LeafCount[#]) &[
       Print[#]; #] &)])

Evaluating

csc

will print all attempts to simplify any part of the expression. Of course, most of them are useless. I don't know how to construct from them entire simplification tree. Your can print only those transformations which leads to decrease of LeafCount.