Bug introduced in 11.1 or earlier and fixed in 11.2

I have updated to Mathematica 11.1 and I am shocked to see that the Series function now works differently:

If I enter

Series[x^2+x^3, {x,0,0}]

it will return


which is just weird. In the old versions, it would correctly return


I get that it now tries to return the leading non-trivial term, but this "feature" breaks a number of functions that I have written over the last years and use in my daily work. Does anybody know if there is a quick way to make Series work as it used to in older versions? Did anybody actually see this in any changelog? Because I for sure haven't...

Cheers, Matthias

  • 2
    $\begingroup$ Looks like a bug. $\endgroup$ Apr 12 '17 at 10:48
  • 1
    $\begingroup$ You should report this to Wolfram and let us know what they said. $\endgroup$
    – Szabolcs
    Apr 12 '17 at 11:45
  • 4
    $\begingroup$ btw: Mathematica hasn't released a comprehensive "changelog" since the last 10 years. $\endgroup$
    – QuantumDot
    Apr 12 '17 at 13:43
  • 1
    $\begingroup$ @jjc385 Most probably SeriesData[x, 0, List[], 2, 2, 1] $\endgroup$
    – QuantumDot
    Apr 12 '17 at 18:23
  • 2
    $\begingroup$ The only reply I got was "I'll forward this to the devs". Nothing since then. The update that was rolled out shortly after also didn't fix it. Right now I'm using QuantumDot's reply. I suggest everyone affected submits a bug report to keep up the pressure on that matter. $\endgroup$ Jul 3 '17 at 6:31

There is an undocumented function System`SeriesDump`truncateSeries that you can use to facilitate the truncation of your series.

System`SeriesDump`truncateSeries[Series[x^2 + x^3, {x, 0, 0}], {x, 0, 0}]
(* O[x]^2 *)

Modify the Series function so that it calls System`SeriesDump`truncateSeries after it is applied:

ClearAttributes[Series, Protected];
Series[expr_, {var_, x0_, nf_}] := 
  Block[{$inSeries = True, result},
    result = System`SeriesDump`truncateSeries[
      Series[expr, {var, x0, nf}], {var, x0, nf}];
    result] /; ! TrueQ[$inSeries];
SetAttributes[Series, Protected];


Series[x^2 + x^3, {x, 0, 0}]
(* O[x]^2 *)

All disclaimers associated with using undocumented functionality and modifying built-in functions apply.

  • $\begingroup$ It's a good workaround, undocumented notwithstanding. $\endgroup$ Apr 15 '17 at 20:39
  • 1
    $\begingroup$ Unprotect[]/Protect[] is the traditional way to remove and restore the Protected[] attribute, but this apparently works, too. $\endgroup$ Apr 16 '17 at 0:25
  • $\begingroup$ Incredible, thanks a lot. $\endgroup$ Apr 18 '17 at 12:58
  • $\begingroup$ I just wanted to add that Series in 11.0.0 does not consistently return the leading order term. Mathematica 10.0.0 evaluates Series[(-(h^3*t1^3)/864 + (ht1)^(3/2) - (h^4*t1^3*t2) 373248 + (h*(ht1)^(3/2)*t2)/864 + (h^2*(h*t1)^(3/2)*t2^2) 746496)^(1/6), {h, 0, 2}] to $$ \sqrt[4]{h} \sqrt[6]{\text{t1}^{3/2}}+\frac{h^{5/4}\sqrt[6]{\text{t1}^{3/2}} \text{t2}}{5184}-\frac{h^{7/4}\left(\text{t1}^{3/2}\right)^{7/6}}{5184}+O\left(h^{9/4}\right) $$ while 11.0.0 returns $$ \sqrt[6]{h^{3/2} \text{t1}^{3/2}}+\frac{h \text{t2} \sqrt[6]{h^{3/2} \text{t1}^{3/2}}}{5184}-\frac{h^{3/2} \left(\text{t1}^{3/2} $\endgroup$
    – Cobi
    Jun 21 '17 at 13:37
  • 1
    $\begingroup$ @vsht It's fixed for the next release. $\endgroup$ Jul 5 '17 at 17:52

The following works for expansions in one variable only. It would need to be extended for multiple variables.

If you're looking for a quick and dirty fix, you might replace every instance of Series in your code with series :

series[f_, {x_, x0_, nMaxSpec_}, args___] := (
  Series[f, {x, x0, nMaxSpec}, args]
   // Replace[ 
    HoldPattern@SeriesData[x, x0, coeffs_, n0Min_, n0Max_, denom_] :>
     With[{nMin = n0Min/denom, nMax = n0Max/denom},
      SeriesData[x, x0, {}, n0Min, n0Min, denom]
       /; ! n0Min === n0Max && n0Min > nMaxSpec

As mentioned above, this works for expansions in one variable only. It would need to be extended for multiple variables.

It would probably be ideal to modify the behavior of Series itself rather than have to replace it with a different function. I attempted to do such a thing, but I was unsuccessful. Perhaps someone more clever will figure out something better.


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.