Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
refine the code
Source Link
AsukaMinato
  • 10.6k
  • 1
  • 20
  • 48

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:

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

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:

\[CapitalDelta]max=5; \[ScriptCapitalL]0s2 = 1/((s - \[CapitalDelta]) (1 + s + \[CapitalDelta])) 16 x^(2 + \[CapitalDelta]) (1 + s - \[CapitalDelta]) (s + \[CapitalDelta]) Hypergeometric2F1[1/2, -s, 1/2 - s, 1] Hypergeometric2F1[1/2, 2 + \[CapitalDelta], 5/2 + \[CapitalDelta], x^2] Sum[Series[(f[\[CapitalDelta], s] Series[\[ScriptCapitalL]0s2 /. {\[CapitalDelta] -> \ \[CapitalDelta] + g^2 \[CapitalDelta]2[\[CapitalDelta], s] + g^4 \[CapitalDelta]4[\[CapitalDelta], s]}, {g, 0, 4}] /. {Log[x] -> 0} // Normal) /. {\[CapitalDelta] -> \[CapitalDelta]\[CapitalDelta], s -> ss}, {x, 0, \[CapitalDelta]max}] /. _?(N[#] == 0 &) :> 0 // Normal, {\[CapitalDelta]\[CapitalDelta], 2, \[CapitalDelta]max}, {ss, 0, \[CapitalDelta]\[CapitalDelta] - 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?

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:

Δmax=5; ℒ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?

Source Link
Pxx
  • 711
  • 3
  • 12

Optimizing a series expansion for high order in $x$

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:

\[CapitalDelta]max=5; \[ScriptCapitalL]0s2 = 1/((s - \[CapitalDelta]) (1 + s + \[CapitalDelta])) 16 x^(2 + \[CapitalDelta]) (1 + s - \[CapitalDelta]) (s + \[CapitalDelta]) Hypergeometric2F1[1/2, -s, 1/2 - s, 1] Hypergeometric2F1[1/2, 2 + \[CapitalDelta], 5/2 + \[CapitalDelta], x^2] Sum[Series[(f[\[CapitalDelta], s] Series[\[ScriptCapitalL]0s2 /. {\[CapitalDelta] -> \ \[CapitalDelta] + g^2 \[CapitalDelta]2[\[CapitalDelta], s] + g^4 \[CapitalDelta]4[\[CapitalDelta], s]}, {g, 0, 4}] /. {Log[x] -> 0} // Normal) /. {\[CapitalDelta] -> \[CapitalDelta]\[CapitalDelta], s -> ss}, {x, 0, \[CapitalDelta]max}] /. _?(N[#] == 0 &) :> 0 // Normal, {\[CapitalDelta]\[CapitalDelta], 2, \[CapitalDelta]max}, {ss, 0, \[CapitalDelta]\[CapitalDelta] - 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?