Comment #6 on issue 3544 by asmeu...@gmail.com: binomial should not get expanded except when expand(func=True) is called on it
http://code.google.com/p/sympy/issues/detail?id=3544

The point of the issue is that the *default* should be to not evaluate. In generally, it may be possible to make something that usually evaluates not evaluate or visa-versa, but the default should aim for what will be most desirable. I can give several arguments why binomial(n, 5) should not auto-expand (by default):

- As described in the OP, it makes dealing with things like that summation.

- The size of the expression grows linearly with the value of the second argument. That means that binomial(n, 10) might be manacle, but binomial(n, 100) is quite large, and binomial(n, 1000) is huge. (By the way, if we document this, we should recommend expand_func, not expand(func=True), as the latter will also expand the polynomial in n itself)

So basically, it violates rules, 2, 3, and 4 from https://github.com/sympy/sympy/wiki/Automatic-Simplification. n*(n - 4)*(n - 3)*(n - 2)*(n - 1)/120 is definitely not simpler than binomial(n, 5). The size issue means that it will not be cheap even for relatively small arguments to binomial. And the OP clearly gives a case where this would not want to be done.

And going back to what I said in the first paragraph of this comment, if there's ever ambiguity between whether something should evaluate to something else automatically or not, I would say, when in doubt, don't evaluate. Not evaluating is much easier to deal with than evaluating. To evaluate later, one just has to call the relevant function (in this case, expand_func). These functions generally work recursively, so one can even call it on a larger expression containing the object and it will still be evaluated. To not evaluate, on the other hand, one usually has to resort to hacks like evaluate=False, and even if they are implemented in a way that isn't hacky, it isn't easy to "unevaluate" something later on, especially if it's part of a larger expression.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to