7
$\begingroup$

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:

bad output

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

good result

Documentation regarding QPochhammer can be found here.

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

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – march Mar 6 '17 at 18:31
5
$\begingroup$

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 /: 
 System`Private`InternalSeries[
   HoldPattern[QPochhammer][System`SeriesDump`w_, 
    System`SeriesDump`q_, 
    System`SeriesDump`k_Integer?Positive], {System`SeriesDump`z_, 
    System`SeriesDump`p_, System`SeriesDump`n_Integer}] /; 
 Internal`DependsOnQ[System`SeriesDump`w, System`SeriesDump`z] && ! 
    Internal`DependsOnQ[{System`SeriesDump`q, System`SeriesDump`p}, 
    System`SeriesDump`z] =.

Then add the definition from earlier versions,

QPochhammer /: 
 System`Private`InternalSeries[
   HoldPattern[QPochhammer][System`SeriesDump`w_, 
    System`SeriesDump`q_, 
    System`SeriesDump`k_Integer?Positive], {System`SeriesDump`z_, 
    System`SeriesDump`p_, System`SeriesDump`n_Integer}] /; 
  Internal`DependsOnQ[System`SeriesDump`w, System`SeriesDump`z] := 
 Module[{System`SeriesDump`lim, System`SeriesDump`ord, 
   System`SeriesDump`qq, System`SeriesDump`ww}, 
  System`SeriesDump`lim = 
   System`SeriesDump`getExpansionPoint[System`SeriesDump`w, 
    System`SeriesDump`z, 
    System`SeriesDump`p]; (System`SeriesDump`ord = 
     Min[System`SeriesDump`k, 
      System`SeriesDump`AdjustExpansionOrder[System`SeriesDump`w, 
       System`SeriesDump`lim, System`SeriesDump`z, 
       System`SeriesDump`p, System`SeriesDump`n]]; 
    System`SeriesDump`ww = 
     System`Private`InternalSeries[
      System`SeriesDump`w, {System`SeriesDump`z, System`SeriesDump`p, 
       System`SeriesDump`n}]; 
    System`SeriesDump`qq = 
     System`Private`InternalSeries[
      System`SeriesDump`q, {System`SeriesDump`z, System`SeriesDump`p, 
       System`SeriesDump`n}]; 
    1 + Plus @@ 
      Table[(-System`SeriesDump`ww)^
        System`SeriesDump`m System`SeriesDump`qq^
        Binomial[System`SeriesDump`m, 2] QBinomial[
         System`SeriesDump`k, System`SeriesDump`m, 
         System`SeriesDump`qq], {System`SeriesDump`m, 
        System`SeriesDump`ord}]) /; System`SeriesDump`lim === 0];

Protect[QPochhammer];

Now we get the desired behavior,

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

Desired result

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.

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

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
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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