(I did not know there is sage group at stackoverflow. I asked this before at sage support usenet, but that is very slow).
Here is the question:
Is there a way in sage to determine the size of expression as given typically by leaf count? Similar to what is documented in Mathematica leafCount[]
here
http://reference.wolfram.com/language/ref/LeafCount.html
"gives the total number of indivisible subexpressions in expr."
And also similar to Maple's
I need a way to measure the size of resulting expression from sage to compare it with Mathematica's result and Maple's as well. I currently use leafCount() for this since both Maple and Mathematica have this function.
Does sage have similar function or another way to obtain this measure?
For example, given this expression
(c + integrate(e^(2*x + sin(x)), x))*e^(-sin(x))
Then in Mathematica I would write
Clear[x, c];
expr = (c + Integrate[Exp[2*x + Sin[x]], x])*Exp[-Sin[x]];
LeafCount[expr]
19
Update: To answer the question below on how the leaves are counted. If one draws a tree expression, then it is each node in the expression tree. For the above, it is
Similarly, LeafCount[x + y]
gives 3 since