I had to work with some series expansions lately, and at some point I realised that something was becoming inconsistent at some point. It seems that applying Factor
broke my series expansions. Here's a minimal example extracted from my computations.
Consider the following expression
test = Sqrt[1/(1 - x)] (Sqrt[1/(1 - x)] + 1) + 1;
Now look at those series expansions of test
around x=1
:
ser1 = Series[test // Factor, {x, 1, -1}]
ser2 = Series[test, {x, 1, -1}]
Not only are ser1
and ser2
different, but what's worse is that
ser2 - ser1
gives 1/(x-1) + O(x-1)^0
. At this point I would have expected O(x-1)^0
, how come Factor
can break a series expansion so much? Is this sort of behaviour a feature or a bug?
The problem seems to be in ser2
, if one looks at List@@ser2
one realises that ser2
is saved as a0+O(x-1)^2
with a0
containing x
, this seems to be the root of all evil.
Interestingly, if one alters test
to
test = 1/Sqrt[(1 - x)] (1/Sqrt[(1 - x)] + 1) + 1;
which is really not much of a change, one obtains a different result. Given this instability, I don't know how I should trust the series expansions at all.
Here's a similar, but more subtle computation, which leads to two different results. Let's add 1/(1-x)
to test
test = 1/(1 - x) + 1/Sqrt[1 - x] (1/Sqrt[1 - x] + 1) + 1;
ser1 = Series[test // Factor, {x, 1, -1}];
ser2 = Series[test, {x, 1, -1}];
and compute
Limit[(1 - x) ser1, x -> 1] (* = 2 *)
Limit[(1 - x) ser2, x -> 1] (* = 1 *)
In a realistic scenario test
would be much more complicated, and I wouldn't compute both ser1
and ser2
and then compare, but just one of them. So there's a 50/50 chance that I'd obtain a wrong result without being aware of it.
Mathematica Version : 11.1 .0 .0
Platform : Mac OS X x86 (32-bit, 64-bit kernel)
bugs
tag for now. As mentioned in thebugs
tag statement, it is only used when the bug is validated by the community here. It seems like a bug, but let's let the expert community decide. $\endgroup$ser1
andser2
are to different orders. If I change the definition ofser1
so that the resulting series is the same order as that inser2
, I obtain the same result. So, I do not think this is a bug. $\endgroup$