# Taylor expansion of a function containing QPochhammer[q, q, n]

I want to get the following series expansion:

Series[QPochhammer[q, q, 3], {q, 0,4}]


but in Mathematica 11.0, I obtain the following gibberish:

There weren't any problems of this kind in Mathematica 8.0.

The following example with the infinite product

Series[QPochhammer[q, q], {q, 0, 4}]


works perfectly fine, producing the series

Documentation regarding QPochhammer can be found here.

Q: What causes this problem with finite products and how to avoid it?

• Series[QPochhammer[q, q, 3], {q, 0, 4}] yields SeriesData[q, 0, {1, -1, -1, 0, 1}, 0, 5, 1] in V10.0.1. That gibberish, of course, is Mathematica evaluating the formal power series of that function assuming that it doesn't know anything about the symbol QPochhammer. But clearly it does (since it knew it before), so this strikes me as likely a bug introduced somewhere between 10.0.1 and 11.0. – march Mar 6 '17 at 18:31

The reason it doesn't work is because somewhere between v10.0 and v10.3, the seventh definition of QPochhammer was modified to check that the second argument does not depend on the expansion parameter.

To restore previous behavior, clear the seventh definition,

(*Triggers loading of definitions*)
Series[QPochhammer[0, x, 3], {x, 0, 1}];

(*Unprotect*)
Unprotect[QPochhammer];

QPochhammer /:
SystemPrivateInternalSeries[
HoldPattern[QPochhammer][SystemSeriesDumpw_,
SystemSeriesDumpq_,
SystemSeriesDumpk_Integer?Positive], {SystemSeriesDumpz_,
SystemSeriesDumpp_, SystemSeriesDumpn_Integer}] /;
InternalDependsOnQ[SystemSeriesDumpw, SystemSeriesDumpz] && !
InternalDependsOnQ[{SystemSeriesDumpq, SystemSeriesDumpp},
SystemSeriesDumpz] =.


Then add the definition from earlier versions,

QPochhammer /:
SystemPrivateInternalSeries[
HoldPattern[QPochhammer][SystemSeriesDumpw_,
SystemSeriesDumpq_,
SystemSeriesDumpk_Integer?Positive], {SystemSeriesDumpz_,
SystemSeriesDumpp_, SystemSeriesDumpn_Integer}] /;
InternalDependsOnQ[SystemSeriesDumpw, SystemSeriesDumpz] :=
Module[{SystemSeriesDumplim, SystemSeriesDumpord,
SystemSeriesDumpqq, SystemSeriesDumpww},
SystemSeriesDumplim =
SystemSeriesDumpgetExpansionPoint[SystemSeriesDumpw,
SystemSeriesDumpz,
SystemSeriesDumpp]; (SystemSeriesDumpord =
Min[SystemSeriesDumpk,
SystemSeriesDumpAdjustExpansionOrder[SystemSeriesDumpw,
SystemSeriesDumplim, SystemSeriesDumpz,
SystemSeriesDumpp, SystemSeriesDumpn]];
SystemSeriesDumpww =
SystemPrivateInternalSeries[
SystemSeriesDumpw, {SystemSeriesDumpz, SystemSeriesDumpp,
SystemSeriesDumpn}];
SystemSeriesDumpqq =
SystemPrivateInternalSeries[
SystemSeriesDumpq, {SystemSeriesDumpz, SystemSeriesDumpp,
SystemSeriesDumpn}];
1 + Plus @@
Table[(-SystemSeriesDumpww)^
SystemSeriesDumpm SystemSeriesDumpqq^
Binomial[SystemSeriesDumpm, 2] QBinomial[
SystemSeriesDumpk, SystemSeriesDumpm,
SystemSeriesDumpqq], {SystemSeriesDumpm,
SystemSeriesDumpord}]) /; SystemSeriesDumplim === 0];

Protect[QPochhammer];


Now we get the desired behavior,

Series[QPochhammer[q, q, 3], {q, 0, 4}]


Warning The seventh definition was modified in later releases probably because someone discovered that it leads to incorrect results in some cases. Proceed with caution.

• An alternative is to use QPochhammer[q + O[q]^5, q, 3] – Carl Woll Mar 6 '17 at 19:15

An easier method is to perform a preliminary application of FunctionExpand[]:

Series[QPochhammer[q, q, 3] // FunctionExpand, {q, 0, 4}]
1 - q - q^2 + q^4 + O[q]^5
`