# Help summing an infinite series

I have been trying to evaluate the following series using SageMath.

 sum((x^x)/(factorial(x)*exp(x)) - 1/sqrt(2*pi*x), x, 1, +oo).n()


The answer should be -0.084069508727655... (-2/3 - zeta(1/2)/sqrt(Pi)), but I get the following error when the upper limit is above 96:

RuntimeError: maximum recursion depth exceeded while calling a Python object


Is there any way SageMath could give me even the first few digits of the infinite sum? This sum seems to evaluate just fine in Maple and Mathematica, but not in any open source program I have tried, including Axiom, Maxima, PARI, and SymPy.

Any help would be greatly appreciated.

edit retag close merge delete

Sort by » oldest newest most voted

In sage i tried to work in the following numerical field R:

R = RealField(200)
R(pi)

N = 10000
S1 = sum( [ R( (n/exp(1))^n / factorial(n) ) for n in [1..N] ] )
S2 = 1/sqrt(2*R(pi)) * sum( [ R( 1/sqrt(n) ) for n in [1..N] ] )
S1 - S2


After a while:

3.1415926535897932384626433832795028841971693993751058209749
-0.083404622472617419033475969548978763069063830480341659271178


Two decimals only, this is because we have a slow convergence.

In pari/gp:

? \p 200
realprecision = 211 significant digits (200 digits displayed)
?
? N = 20000
%1 = 20000
? S1 = sum( n=1, N, (n/exp(1))^n / n! )
%2 = 112.17313066274937979489499417935379308757523535794874273299297201896403797332045063551083264178584322111389066602610107202478259077132712353378611733460800239174023186964221827251175464458573129824452
? S2 = 1/sqrt(2*Pi) * sum( n=1, N, 1./sqrt(n) )
%3 = 112.25673001969414128242389934033133492400419727408188161493507054932051390461929936662048861000846610281386339772874414970984758369589845752424666439767258043083118243285029238837805841560457193884550
? S1 - S2
%4 = -0.083599356944761487528905160977541836428961916133138881942098530356475931298848731109655968222622881699972731702643077685064992924571333990460547063064578039090950563208074115866303771018840640600982726
?

more