Hello,
I am having troubles with the evaluation of some infinite series, see code below. The values g and c are normally not hard coded and might vary (e.g g could be complex as well), however they shouldn't be huge if that is important.
import mpmath as mp
g = 4+0j
c = 11+0.25j
mp.mp.prec = 53
def F(m):
return ((1j*mp.sqrt(g))**m * mp.hyp2f1(-m, -c, -2*c, 2,
zeroprec=1000))
def N_sum(m):
return ((2**m/mp.factorial(m)) * mp.fabs(F(m))**2)
N_summed = mp.nsum(lambda m: N_sum(m), [0, mp.inf])
With the structure of this code, python returns N_summed = mpf('1.0843757481788037'), chossing in nsum instead of mp.inf a finite intervall like [0, 100], the sum evaluates to N_summed = mpf('176.89459407143693'). Since N_sum(m) > 0 for all m, the result for the intervall is obviously wrong.
I suspect that this behavior occurs for one of the following reasons:
- the structure of F(m) is such that F(m) = 0 for m odd with the given parameters.
- N_sum(m)/F(m) is such that for the given parameters the main contributions to N_summed are for m in [22, 40].
Which **kwargs or settings should be changed so that nsum provides the right results if the intervall [0, inf]?
Thank you!
P.S. I've added the values for N_sum(k) for some k below:
for k in range(60):
print(k, N_sum(k))
0 1.0
1 0.0
2 0.0725212464589235
3 0.0
4 0.00963604105198153
5 0.0
6 0.00177674049935701
7 0.0
8 0.000441720168541587
9 0.0
10 0.00015032840004724
11 0.0
12 7.27362155555033e-5
13 0.0
14 5.32013462348824e-5
15 0.0
16 6.48138228242222e-5
17 0.0
18 0.000155153881700228
19 0.0
20 0.00101982227106745
21 0.0
22 0.0498414957205326
23 0.0
24 2.44555605668747
25 0.0
26 16.269811603742
27 0.0
28 39.7655367061756
29 0.0
30 49.9525117608541
31 0.0
32 38.1176089744364
33 0.0
34 19.5280509773219
35 0.0
36 7.17919484477287
37 0.0
38 1.9861362687566
39 0.0
40 0.428469846742998
41 0.0
42 0.074101491372788
43 0.0
44 0.0105035953776932
45 0.0
46 0.0012425439891461
47 0.0
48 0.000124535929606539
49 0.0
50 1.07108584229306e-5
51 0.0
52 7.99182578407715e-7
53 0.0
54 5.22241931504883e-8
55 0.0
56 3.01369159463784e-9
57 0.0
58 1.54703782299725e-10
59 0.0