I would like to expand the following function at $x \sim 0$ up to some high $x_\text{max} = \Delta_\text{max}$:

$$16 \sum_{\Delta=1}^{\Delta_\text{max}} \sum_{s=0}^{\Delta-2} f_{\Delta,s} \frac{(s+\Delta)(1+s-\Delta)}{(s-\Delta)(1+s+\Delta)}\ _2F_1 \left(\frac{1}{2},-s,\frac{1}{2}-s,1\right)\ _2F_1 \left(\frac{1}{2},2+\Delta,\frac{5}{2}+\Delta,x^2 \right) x^{2+\Delta}, \tag{1}$$

where $f_{\Delta,s}$ are numerical coefficients. The series expansion should be performed after doing the following replacement (everywhere except in the subscript of $f_{\Delta,s}$ and in the summation limits):

$$\Delta \to \Delta + g^2 \Delta^{(2)}_{\Delta,s} + g^4 \Delta^{(4)}_{\Delta,s}, \tag{2}$$

and expanding in $g$. Again the $\Delta^{(k)}$ are numbers, which depend on $\Delta$ and $s$. I am not interested in $\log$ terms, which can be discarded by setting the rule $\log x \to 0$.

So far I wrote the following simple code:

ℒ0s2 = 1/((s - Δ) (1 + s + Δ)) 16 x^(2 + Δ) (1 + s - Δ) (s + Δ) Hypergeometric2F1[1/2, -s, 1/2 - s, 1] Hypergeometric2F1[1/2, 2 + Δ, 5/2 + Δ, x^2]
Sum[Series[(f[Δ, s] Series[ℒ0s2 /. {Δ -> \
Δ + g^2 Δ2[Δ, s] + g^4 Δ4[Δ, s]}, {g, 0, 4}] /. {Log[x] -> 0} // Normal) /. {Δ -> ΔΔ, s -> ss}, {x, 0, Δmax}] /. _?(N[#] == 0 &) :> 0 // Normal, {ΔΔ, 2, Δmax}, {ss, 0, ΔΔ - 2}]

Unfortunately this is insanely inefficient for high $\Delta_\text{max}$. For $\Delta_\text{max}=5$ the computation takes less than a second, for $\Delta_\text{max}=10$ about $20$ seconds, for $\Delta_\text{max}=15$ it took $3$ minutes,... I let it run the whole night yesterday to reach my goal, which is at least $\Delta_\text{max}=60$, and it was still running this morning!

Any suggestion how this expansion could be done (much) faster?

  • $\begingroup$ It looks like it helps if I do the expansion resulting from $(2)$ "manually". I'll report on that soon if it indeed reduces the computation time significantly. $\endgroup$
    – Pxx
    Sep 22, 2020 at 7:57

1 Answer 1


I found a workaround. As indicated in the comment, the idea is to expand the series in $g$ manually by doing the derivatives and then expand each sum individually.

The concatenation of Series seems to be the reason why the code was so slow. The computation now only takes a few minutes.

  • 1
    $\begingroup$ Please post executable MMA code. $\endgroup$ Sep 22, 2020 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.