Inconsistency of the results of the infinite sum in SymPy and WolframAlpha

21 views
Skip to first unread message

Paul Royik

unread,
Sep 10, 2025, 7:19:54 AM (6 days ago) Sep 10
to sympy
sum of binomial(-2/5, n), n=1..infinity

SymPy says that the answer is 2^(-2/5)-1.
WolframAlpha says that the series is divergent.

What answer is correct?

Oscar Benjamin

unread,
Sep 10, 2025, 7:48:04 AM (6 days ago) Sep 10
to sy...@googlegroups.com
I don't think wolframalpha says it is divergent:

https://www.wolframalpha.com/input?i=sum%28binomial%28-2%2F5%2C+n%29%2C+%28n%2C+1%2C+inf%29%29

It does not compute the sum in closed form but gives a formula for the
partial sums as

2^(-2/5)-1 + f(k)

where f(k) is something that goes to zero for large k.

SymPy gives the same partial sum formula in terms of 2F1 (hyper)
although it looks a little different with gamma functions:

In [29]: print(summation(binomial(S(-2)/5, n), (n, 1, k)))
(5/2 - 5*2**(3/5)/4)*gamma(3/5)/gamma(-2/5) - gamma(3/5)*hyper((1, k +
7/5), (k + 2,), -1)/(gamma(-k - 2/5)*gamma(k + 2))

I think SymPy and WolframAlpha are in agreement but just WA does not
compute a closed form for this particular sum whereas SymPy does get
the closed form but SymPy does not simplify the gamma functions as
nicely as WA does.

I think simplify here could be improved:

In [33]: e = summation(binomial(S(-2)/5, n), (n, 1, oo))

In [34]: print(e)
(5/2 - 5*2**(3/5)/4)*gamma(3/5)/gamma(-2/5)

In [35]: e.evalf()
Out[35]: -0.242141716744801

In [36]: 2**(-2/5)-1
Out[36]: -0.242141716744801

In [37]: print(simplify(e))
5*(2 - 2**(3/5))*gamma(3/5)/(4*gamma(-2/5))

Maybe gammasimp could handle this better somehow.

--
Oscar
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sympy/16f407ca-97a8-4565-ace5-1157c2702722n%40googlegroups.com.

Paul Royik

unread,
Sep 10, 2025, 7:50:40 AM (6 days ago) Sep 10
to sympy
If you replace -2/5 with -0.4, WolframAlpha says that the series diverges: https://www.wolframalpha.com/input?i=sum%28binomial%28-0.4%2C+n%29%2C+%28n%2C+1%2C+inf%29%29

Oscar Benjamin

unread,
Sep 10, 2025, 8:02:59 AM (6 days ago) Sep 10
to sy...@googlegroups.com
I think WolframAlpha is wrong when it says that it diverges. My guess
is that since you use a float it uses a heuristic numeric check for
convergence and since this converges slowly the heuristic check looks
like it does not converge. You can see mpmath struggles with it as
well:

In [1]: f = binomial(-S(2)/5, 1 + k) * hyper([1, 7/5 + k], [2 + k], -1)

In [2]: f.evalf(subs={k:1e10})
...
File <string>:38, in hypsum_2_1_RZ_Z_R(coeffs, z, prec, wp, epsshift,
magnitude_check, **kwargs)

NoConvergence: Hypergeometric series converges too slowly. Try
increasing maxterms.
> To view this discussion visit https://groups.google.com/d/msgid/sympy/b73c1f9f-774f-451f-9574-b0db731cae7dn%40googlegroups.com.

Paul Royik

unread,
Sep 10, 2025, 8:06:08 AM (6 days ago) Sep 10
to sympy
I see.

Thank you very much for the response!

Reply all
Reply to author
Forward
0 new messages