I am trying to fully expand the following $$\sum_{n=0}^{\infty} \frac{q^{\frac{n(n+1)}{2}}}{(q;q)_n}$$ Which when expressed in Mathematic is: q^(n*(n + 1)/2)/QPochhammer[q, q, n]

I would like to be able to fully expand this series into individual powers of q. This should be a power series, with integer coefficients for each power. How can I get the fully expanded power series? Ultimately, I would like to obtain a list of all the coefficients. Your help will go along way.


  • $\begingroup$ Which when expressed in Mathematic is: q^{n*(n + 1)/2}/QPochhammer[q, q, n] No it is not. You are using curly brackets which are for lists and things, not subexpressions. The correct way is q^(n(n+1)/2)/QPochhammer[q, q, n] $\endgroup$
    – flinty
    Oct 8, 2020 at 17:47
  • $\begingroup$ Ah, you are right. But this does not solve my problem. Can you help me? $\endgroup$
    – Broudy
    Oct 8, 2020 at 17:51
  • $\begingroup$ You say you want all of the coefficients. I don't know if that is possible. If you want all of the coefficients up to say q^55, that is easy. $\endgroup$
    – Carl Woll
    Oct 8, 2020 at 18:08
  • $\begingroup$ @Carl Woll Yes, this would be sufficient $\endgroup$
    – Broudy
    Oct 8, 2020 at 18:43

2 Answers 2


There seems to be a weakness in series expansions of QPochhammer in Mathematica:

Series[QPochhammer[q, q, 2], {q, 0, 1}] //TeXForm

$1+q \left(\text{QPochhammer}^{(0,1,0)}(0,0,2)+\text{QPochhammer}^{(1,0,0)}(0,0,2)\right)+O \left(q^2\right)$

You can fix this by using FunctionExpand (essentially Vaclav Kotesovec's comment to Bill Watt's answer):

Series[FunctionExpand @ QPochhammer[q, q, 2], {q, 0, 1}] //TeXForm


So, the following should produce your desired result:

ser[k_] := With[{m = Ceiling[1/2 (-1+Sqrt[1+8 k])]},
        Sum[q^(n (n+1)/2) / FunctionExpand @ QPochhammer[q, q, n], {n, 0, m}],
        {q, 0, k}


ser[20] //TeXForm

$1+q+q^2+2 q^3+2 q^4+3 q^5+4 q^6+5 q^7+6 q^8+8 q^9+10 q^{10}+12 q^{11}+15 q^{12}+18 q^{13}+22 q^{14}+27 q^{15}+32 q^{16}+38 q^{17}+46 q^{18}+54 q^{19}+64 q^{20}+O\left(q^{21}\right)$

  • $\begingroup$ thank you so much! $\endgroup$
    – Broudy
    Oct 8, 2020 at 19:40

I'm not sure how you get all the terms, but if you want to look at a finite number you can do something like this:

First get a series in q from

fn = q^(1/2 n (n + 1))/QPochhammer[q, q, n]

Series[fn, {q, 0, 100}] // Normal

Then apply the first few n

Plus @@ (Table[%, {n, 0, 100}] // Expand)

That should give you several coefficients to play with. If you want more, you can make the Series and Table longer if you have the computing power.

  • $\begingroup$ When I implement this, I don't get the coefficients. What might I be doing wrong? $\endgroup$
    – Broudy
    Oct 8, 2020 at 18:51
  • $\begingroup$ Use n = 10; Series[Sum[q^(k*(k+1)/2)/Product[(1 - q^j), {j, 1, k}], {k, 0, n}], {q, 0, n}] $\endgroup$ Oct 8, 2020 at 18:58
  • $\begingroup$ This is also sequence A000009 in the OEIS. $\endgroup$ Oct 8, 2020 at 19:01
  • $\begingroup$ You should get a series in powers of $q$. What are you getting instead? $\endgroup$
    – Bill Watts
    Oct 8, 2020 at 19:38
  • $\begingroup$ In general should I use the product command, as opposed to QPochhammer? $\endgroup$
    – Broudy
    Oct 8, 2020 at 19:44

Your Answer

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

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