Hi Aaron, thanks for checking. Yes you are right a definite sum over k can not return an expression with k.
That was my mistake I did not realized, that with R4 test, Wester wanted to check if Gosper algorithm for indefinite sums are supported: http://en.wikipedia.org/wiki/Gosper's_algorithm#Definite_versus_indefinite_summation SymPy does not support indefinite sums, and that particular algorithm right? This is the macsyma test: (c15) /* Check whether the full Gosper algorithm is implemented => 1/2^(n + 1) binomial(n, k - 1) */ closedform(*indefsum*(binomial(n, k)/2^n - binomial(n + 1, k)/2^(n + 1), k)); Time= 2690 msecs (- n + k - 1) binomial(n + 1, k) (d15) - -------------------------------- n 2 2 (n + 1) (c16) factcomb(makefact(%)); Time= 220 msecs n! (d16) ---------------- n 2 k! 2 (n - k)! I will change test_R4() in test_wester.py. Thanks, Pablo On Tuesday, October 15, 2013 4:11:35 AM UTC+2, Aaron Meurer wrote: > > I think your expected answer must be wrong, because it cannot contain > k, since it is the summation variable. > > I would check the various expressions (the unevaluated summation, the > result before combsimp, the result after combsimp, and the expected > result) numerically for various values of n. The results from the > unevaluated Sum should be considered to be the true values, since > those are just evaluated numerically. > > That will at least show which of Sum.doit, combsimp, and your expected > result are right and wrong. > > Aaron Meurer > > On Sat, Sep 28, 2013 at 1:29 AM, Pablo Puente > <[email protected]<javascript:>> > wrote: > > Hi, > > > > > > Wester test case R4 sum(binomial(n, k)/2^n - binomial(n + 1, k)/2^(n + > 1), > > k) should return 2**(-n-1)*binomial(n,k-1). > > > > > > Sympy is returning -2**(-n)/2 > > > > > > I am making a mistake or do we have a bug here? > > > > n,k = symbols('n,k', integer=True, positive=True) > > > > sk = binomial(n, k)/(2**n) - binomial(n + 1, k)/(2**(n + 1)) > > > > S = Sum(sk, (k,1,oo)) > > > > T = S.doit() > > > > assert T.combsimp() == 2**(-n-1)*binomial(n,k-1) # returns -2**(-n)/2 > > > > > > Thanks, > > > > Pablo Puente > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected]<javascript:>. > > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
