I need to perform series expansion in p, q (to order order) of products/ratios of the so-called elliptic gamma functions, commonly defined by the infinite product, $$ \Gamma(z,p,q) = \prod_{m,n \ge 0} \frac{1 - z^{-1}p^{m+1}q^{n+1}}{1 - z p^m q^n} \ . $$

However, in practice I find this definition (with the dummy variables $m, n$ truncated to order) is very slow to work with.

I wonder if there are better ways to implement this function? Note that the function will be used abstractly, instead of numerically.


1 Answer 1


You can do one of the products exactly, and the other numerically, to gain a factor of >20 in speed:

(* original: double-infinite product *)
Γ1[z_?NumericQ, p_?NumericQ, q_?NumericQ] :=
  NProduct[(1 - z^-1 p^(m + 1) q^(n + 1))/(1 - z p^m q^n),
           {m, 0, ∞}, {n, 0, ∞}]

(* simpler: single-infinite product *)
Γ2[z_?NumericQ, p_?NumericQ, q_?NumericQ] :=
  NProduct[QPochhammer[(p q^(1 + n))/z, p]/QPochhammer[q^n z, p],
           {n, 0, ∞}]

(* same but symmetrized over p&q to maintain the symmetry *)
Γ3[z_?NumericQ, p_?NumericQ, q_?NumericQ] :=
  Sqrt@NProduct[(QPochhammer[p*q/z p^k, q]*QPochhammer[p*q/z q^k, p])/
                (QPochhammer[z p^k, q]*QPochhammer[z q^k, p]),
  {k, 0, ∞}]

Γ1[0.3, 0.17, 0.09] // RepeatedTiming
(*    {0.0538385, 1.47214}    *)

Γ2[0.3, 0.17, 0.09] // RepeatedTiming
(*    {0.00227641, 1.47214}    *)

Γ3[0.3, 0.17, 0.09] // RepeatedTiming
(*    {0.00333879, 1.47214}    *)

The formulas used are

Product[(1 - z^-1 p^(m + 1) q^(n + 1))/(1 - z p^m q^n), {m, 0, ∞}]
(*    QPochhammer[(p q^(1 + n))/z, p]/QPochhammer[q^n z, p]    *)

Product[(1 - z^-1 p^(m + 1) q^(n + 1))/(1 - z p^m q^n), {n, 0, ∞}]
(*    QPochhammer[(p^(1 + m) q)/z, q]/QPochhammer[p^m z, q]    *)

Of course, a QPochhammer symbol is nothing more than the infinite product given; but we can assume that the internal evaluation of QPochhammer is much more efficient than NProduct.

  • $\begingroup$ (+1) it's astonishing that QPochhammer is performing so much better than NProduct. Somehow related(?): perhaps this approach generalizes nicely for situations involving ${}_2F_1$? Namely, write them as Pochhammer symbols using the standard formuale? $\endgroup$
    – bmf
    Commented Feb 7, 2023 at 0:10
  • $\begingroup$ Thanks for the suggestion! The function will be used abstractly (z, p, q all symbols not numerics) in my project, and will be series expanded in p, q. I tested some simple expressions and expansions, and, unfortunately, your suggestion seems roughly the same as the simple product approach. It would be nice if you could also suggest on abstract use. $\endgroup$
    – Lelouch
    Commented Feb 7, 2023 at 1:20
  • $\begingroup$ (I now added emphasis on abstract use in the question) $\endgroup$
    – Lelouch
    Commented Feb 7, 2023 at 1:21
  • 2
    $\begingroup$ I'd recommend you head to the math stackexchange and ask for help with finding concise expressions for calculating these derivatives. Once you know a concise formulation, it will be easier to write fast Mathematica code for calculating them. For example, can your $\Gamma$ and its derivatives be expressed as Mellin–Barnes integrals? Or as hypergeometric functions? This would simplify and speed up and follow-up work. $\endgroup$
    – Roman
    Commented Feb 7, 2023 at 10:39

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.