Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 3544 by samj...@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
Usually one does not require binomial() to be expanded, as expanding it
doesn't help any and will only clutter up the output. For example, see the
output of this program:
from sympy import symbols,summation,binomial,Function
i,n,j=symbols('i n j', integer=True)
t=symbols('t',real=True)
ival=Function('ival')
def Ra(i) : return
summation((-1)**(i+j)*binomial(i,j)*binomial(n,i)*ival(j),(j,0,i))
mysum=0
for i in range(6): mysum += t**i*Ra(i)
print(mysum)
[or alternatively, by replacing the last three lines by:
print(summation(t**i*Ra(i),(i,0,5)).doit()) ]
t**5*(-n*(n - 4)*(n - 3)*(n - 2)*(n - 1)*ival(0)/120 + n*(n - 4)*(n - 3)*(n
- 2)*(n - 1)*ival(1)/24 - n*(n - 4)*(n - 3)*(n - 2)*(n - 1)*ival(2)/12 +
n*(n - 4)*(n - 3)*(n - 2)*(n - 1)*ival(3)/12 - n*(n - 4)*(n - 3)*(n - 2)*(n
- 1)*ival(4)/24 + n*(n - 4)*(n - 3)*(n - 2)*(n - 1)*ival(5)/120) +
t**4*(n*(n - 3)*(n - 2)*(n - 1)*ival(0)/24 - n*(n - 3)*(n - 2)*(n -
1)*ival(1)/6 + n*(n - 3)*(n - 2)*(n - 1)*ival(2)/4 - n*(n - 3)*(n - 2)*(n -
1)*ival(3)/6 + n*(n - 3)*(n - 2)*(n - 1)*ival(4)/24) + t**3*(-n*(n - 2)*(n
- 1)*ival(0)/6 + n*(n - 2)*(n - 1)*ival(1)/2 - n*(n - 2)*(n - 1)*ival(2)/2
+ n*(n - 2)*(n - 1)*ival(3)/6) + t**2*(n*(n - 1)*ival(0)/2 - n*(n -
1)*ival(1) + n*(n - 1)*ival(2)/2) + t*(-n*ival(0) + n*ival(1)) + ival(0)
However this is quite unreadable and unhelpful to the user to under the
content of the expression. It is therefore preferable to not expand
binomial() except when expand(func=True) is called on it.
--
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.