I'm trying to evaluate a long expression with lots of summations and n choose k's. For some reason, the following expression (which is a part of the long expression) returns NaN.
from sympy import *
w_1_2_3 = symbols('w_1_2_3')
w_1_3 = symbols('w_1_3')
w_2_3 = symbols('w_2_3')
w_1_2 = symbols('w_1_2')
exprr = 7*Sum(binomial(5, w_1_2_3)*Sum(binomial(0, -w_1_2_3 + w_1_3)*binomial(2, w_1_2_3 - w_1_3 - 2)*binomial(13, 11 - w_1_2_3), (w_1_3, w_1_2_3, 5)), (w_1_2_3, 0, 5))/868017280
exprr.doit()
-> NaN
However, if I evaluate each of the terms in the first sum separately, I get 0 for each of them (as should be):
exprr2 = binomial(5, w_1_2_3)*Sum(binomial(0, -w_1_2_3 + w_1_3)*binomial(2, w_1_2_3 - w_1_3 - 2)*binomial(13, 11 - w_1_2_3), (w_1_3, w_1_2_3, 5))
for t in range(0, 6):
res = exprr2.subs(w_1_2_3, t).doit()
print(t, res)
-> 0 0
1 0
2 0
3 0
4 0
5 0
What is going on here? Why do I get NaN for the overall term?