16
$\begingroup$

Bug introduced in 14.3 or earlier and persisting through 14.3.0 or later

Consider the simple example

$Version

Series[\[Chi],{\[Chi],0,0}]

Before version 14.3, the result is enter image description here

But in version 14.3, the result is enter image description here which is annoying since in most cases I'd like to drop the subleading terms by the specification of expansion order.

Is this a bug due to change of internal codes, or designed behavior? I see there is no documentation on the change of this behavior.

$\endgroup$
3
  • $\begingroup$ Looks like a bug to me. $\endgroup$ Commented Aug 15, 2025 at 20:49
  • 1
    $\begingroup$ fyi, this was also mentioned before few days ago in chat. chat.stackexchange.com/transcript/message/68120805#68120805 $\endgroup$ Commented Aug 15, 2025 at 21:17
  • 10
    $\begingroup$ This was an intentional regression to address a more serious bug that it caused, wherein the following had become unreasonably slow.Series[t^34/(2 (4*Pi^2 + (-1 + t)^2)^13*(4*Pi^3 + 9*Pi*(-1 + t)^2)^4), {t, Infinity, 1}] // AbsoluteTiming // InputForm If I figure out a way to refix the 0-order series without reintroducing a massive slowdown I'll do so. In any case the excess term issue is an open bug report, so it won't fall off the radar. $\endgroup$ Commented Aug 15, 2025 at 22:32

2 Answers 2

8
$\begingroup$

This problem was mentioned elsewhere, before 14.3 was available to me, and I've forgotten where. But this was a workaround I suggested:

Series[\[Chi], {\[Chi], 0, 0}] + O[\[Chi]]^1
(*  O[\[Chi]]^1  *)

Or equivalently:

Series[\[Chi], {\[Chi], 0, 0}] + SeriesData[\[Chi], 0, {}, 1, 1, 1]
(*  O[\[Chi]]^1  *)

Here's a couple more ideas for workarounds, based on the same idea above:

Override Series[]

Series[] is rather complicated with many cases. The following works on power/Laurent series and could be a good solution for old code until a WRI can fix the issue. It will have the default V14.3 behavior on expansions about essential singularities.

Unprotect@Series;
$fakeTheOldSeriesOrder = False;
Series[f_, {v_, c_, n_}, opts___?OptionQ] /; 
   TrueQ[$fakeTheOldSeriesOrder] :=
  Block[{$fakeTheOldSeriesOrder = False},
   With[{res = Series[f, {v, c, 0}, opts]},
    If[Head@res === SeriesData && res[[3]] =!= {} && res[[5]] > n + 1,
     res + SeriesData[v, c, {}, res[[4]], Max[res[[4]], n+1], 1],
     res
     ]
    ]];
Protect@Series;

$fakeTheOldSeriesOrder = True;
Series[x, {x, 0, 0}]
Series[x^10, {x, 0, 0}]
Series[Exp[x]/x^5, {x, 0, -9}]
(*
O[x]^1
O[x]^10
1/O[x]^5
*)

Block[{$fakeTheOldSeriesOrder = False},
 Series[x, {x, 0, 0}]]
$fakeTheOldSeriesOrder = False;
Series[x^10, {x, 0, 0}]
Series[Exp[x]/x^5, {x, 0, -9}]
(*
x+O[x]^2
x^10+O[x]^11
1/x^5+1/O[x]^4
*)

This will unset the override:

Unprotect@Series;
Series[f_, {v_, c_, n_}, opts___?OptionQ] /; 
   TrueQ[$fakeTheOldSeriesOrder] =.;
Protect@Series;

Series truncation utility

truncateSeries // ClearAll;
truncateSeries[sd_SeriesData, n_] := 
  sd + SeriesData[sd[[1]], sd[[2]], {}, n + 1, n + 1, 1];

$fakeTheOldSeriesOrder (* check setting *)
Series[x, {x, 0, 0}]
truncateSeries[%, 0]
(*
False
x+O[x]^2
O[x]^1
*)

Efficiency

Truncating a series (that is, truncating SeriesData[]) in the way above is a very fast operation. The overhead is very small compared to the original generation of the series.

$\endgroup$
4
  • 2
    $\begingroup$ It was mentioned in chat. $\endgroup$ Commented Aug 16, 2025 at 12:19
  • $\begingroup$ @Domen Thanks again. I just noticed Nasser mentioned it under the OP. D'oh. $\endgroup$ Commented Aug 16, 2025 at 13:30
  • $\begingroup$ Thx! This is an interesting workaround. Since I use my customized version of series, I can simply add the bigO somewhere to fix. $\endgroup$ Commented Aug 16, 2025 at 15:41
  • 1
    $\begingroup$ @Lacia You're welcome. I added a couple of ideas of how to implement the workaround in existing code. $\endgroup$ Commented Aug 16, 2025 at 15:49
6
$\begingroup$

If we want to be consistent in treating coefficients of series then it is a bug. Also it must have affected/broke many codes that used this feature.

There is no reason why the first non-zero coefficient should be treated differently then the rest.

In old version - if we go backwards in the column output we see that at each step there is one coefficient less until we have zero coefficients.

But in version 14.3 the last (in reverse sense) coefficient is never removed.

Version 13.0.1

Coefficients one-by one:

Table[SeriesCoefficient[1/Log[x + 1]^4, {x, 0, k}], {k, -7, 2}]

{0, 0, 0, 1, 2, 7/6, 1/6, -(1/720), 0, 1/3024}

Series for different n:

Table[Series[1/Log[x + 1]^4, {x, 0, n}], {n, -7, 2}] // Column

enter image description here

Version 14.3.0 (on cloud)

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.