I want to expand the following type of $q$-series
$$ \begin{align} &\mathrm{ELi}_{n_1,...,n_l;m_1,...,m_l;2o_1,...,2o_{l-1}}\left(x_1,...,x_l;y_1,...,y_l;q\right) \\ &= \sum\limits_{j_1=1}^\infty ... \sum\limits_{j_l=1}^\infty \sum\limits_{k_1=1}^\infty ... \sum\limits_{k_l=1}^\infty \;\; \frac{x_1^{j_1}}{j_1^{n_1}} ... \frac{x_l^{j_l}}{j_l^{n_l}} \;\; \frac{y_1^{k_1}}{k_1^{m_1}} ... \frac{y_l^{k_l}}{k_l^{m_l}} \;\; \frac{q^{j_1 k_1 + ... + j_l k_l}}{\prod\limits_{i=1}^{l-1} \left(j_i k_i + ... + j_l k_l \right)^{o_i}} \end{align} $$ to arbitrary but fixed orders in $q$. Whereby the variables $x_i,y_i \in \mathbb{C}$ are fixed numerical values, the variables $n_i,m_i,o_i\in \mathbb{Z}$ are fixed numbers and $q$ remains a symbol.
The function I have written so far is:

(* 2.1 General properties *)  
ELiQ[a_] := MatchQ[a, ELi[__]] (* Test if function is ELi-Function *)  
ELi2qSeries[z_, upper_] := Map[ELi2qSeries[#, upper] &, z, {2}] /; MatrixQ[z] (* Apply on Matrices *)  
ELi2qSeries[a_*b_, upper_] := a ELi2qSeries[b, upper] /;ELiQ[a] == False (* factor out non ELi(B)'s *)  
ELi2qSeries[a_ + b_, upper_] := ELi2qSeries[a, upper] + ELi2qSeries[b, upper]; (* Linearity *)  
ELi2qSeries[a_, upper_] := a /; ELiQ[a] == False (*ELi2qSeries applied on non-ELi's *)  
(* 2.2 actual series-Expansion with upper denoting the order of the expansion *)
ELi2qSeries[ELi[nlist_, mlist_, xlist_, ylist_, var_, olist_], upper_] := Module[{j, k, term, newterm},  
(* term <- definition of eli-Function *)
term = Product[
 xlist[[i]]^j[i]/j[i]^nlist[[i]] ylist[[i]]^k[i]/
   k[i]^mlist[[i]], {i, Length[nlist]}]*(var)^
 Sum[j[h]*k[h], {h, Length[nlist]}]*1/
 Product[(Sum[j[i] k[i], {i, h, Length[nlist]}])^(olist[[h]]/
     2), {h, 1, Length[olist]}];  
(* expand by summation over all j[i],k[i] *)
Do[newterm = Sum[Sum[term, {j[l], 1, upper+1-Length[nlist]}], {k[l], 1, upper+1-Lengt[nlist]}];  
term = newterm, {l, 1, Length[nlist]}];  
(* omit incorrect higher order terms *)
Series[newterm, {var, 0, upper}]]

My main problem is, that the above defined expansion works incredible slow for a sufficiently high chosen order of expansion (upper>20) by a typical length of nlist~3. Since I have to apply it several times during my calculations, it's an major issue.
Therefore any suggestions on how to speed up the whole expansion procedure are much appreciated!
Thanks, Armin

Remark: Code-Example

(* Example: Our calculations yield expressions like: *)
r6=Exp[2 Pi I/6];

(* for numerical evaluations around small q, I need an expansion, wich is currently done by: *)
(* Output:  (-3-3 E^((I \[Pi])/3)) q+(-(3/2)-3/2 (2 (-1)^(1/3)+(-1)^(2/3))) q^2+(-4-3 (-(1/3)+E^((I \[Pi])/3))) q^3+(-(3/4)-3/4 (3 (-1)^(1/3)+2 (-1)^(2/3))) q^4+O[q]^5 *)

This expansion (in much higher order) is suitable for numeric evaluation and for comparison with related Taylor series. The interest for these kind of functions is due to this paper.

  • $\begingroup$ Can you give some examples of how your code is used? $\endgroup$
    – QuantumDot
    Commented Aug 26, 2016 at 13:28
  • $\begingroup$ @QuantumDot I edited the original post and included an minimal example. Is there anything else I can do to clarify things? $\endgroup$
    – Armin
    Commented Aug 26, 2016 at 14:31

1 Answer 1


Some elaborate trickery can be done to implement your multiple sum:

ELi[n_?VectorQ, m_?VectorQ, o_?VectorQ, x_?VectorQ, y_?VectorQ, q_,
    r : (_Integer?Positive | Infinity) : Infinity] /; 
Length[n] == Length[m] == Length[o] + 1 == Length[x] == Length[y] :=
    Block[{l = Length[n], i, j, k}, 
          Inactive[Sum][Apply[Times, x^Array[j, l]/Array[j, l]^n]
                        Apply[Times, y^Array[k, l]/Array[k, l]^m]
                        q^(Array[j, l].Array[k, l])/
                        Apply[Times, Table[Array[j, l - i + 1, i].Array[k, l - i + 1, i],
                                           {i, l - 1}]^(o/2)],
                        Evaluate[Sequence @@ Join[Table[{j[i], 1, r}, {i, l}],
                                                  Table[{k[i], 1, r}, {i, l}]]]]]

(I used Inactive[] so that the sum can be quickly displayed and checked for correctness; for actual computation, replace Inactive[Sum] with Sum.)

An optional parameter r can be specified so that you can either see the actual infinite sum or just a partial sum.

An example:

ELi[{1, 3, 5}, {2, 4, 6}, {14, 16}, Array[x, 3], Array[y, 3], q]

the multiple sum

  • $\begingroup$ Thanks a lot. I learned some useful things by understanding your code! $\endgroup$
    – Armin
    Commented Oct 4, 2016 at 19:48

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.