8
$\begingroup$

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)

$\endgroup$
  • $\begingroup$ This is what I get when I run your code. It doesn't seem to be different. $\endgroup$ – march Sep 29 '17 at 17:26
  • $\begingroup$ @march strange, I just created a new kernel and ran my code there, still the same result. Which Mathematica version do you have? I just added my version to the original post. $\endgroup$ – Stan Sep 29 '17 at 17:39
  • $\begingroup$ V10.0.1, Mac OSX. $\endgroup$ – march Sep 29 '17 at 17:41
  • 1
    $\begingroup$ By the way, I've removed the bugs tag for now. As mentioned in the bugs 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$ – march Sep 29 '17 at 17:42
  • $\begingroup$ @march With V11.2 on Windows 10 (64bit), I do not reproduce your result. The issue, as I see it, is that ser1 and ser2 are to different orders. If I change the definition of ser1 so that the resulting series is the same order as that in ser2, I obtain the same result. So, I do not think this is a bug. $\endgroup$ – bbgodfrey Sep 29 '17 at 18:01
10
$\begingroup$

I think the behavior described is a bug, and I think it is related to the new enhanced support of Assumptions in Limit. In M11.1 we have:

Series[1 + (1 + Sqrt[1/(1-x)]) Sqrt[1/(1-x)] , {x, 1, 3}] //TeXForm

$-\frac{1}{x-1}+\frac{i}{\sqrt{x-1}}+1+O\left((x-1)^{7/2}\right)$

Note how the terms are powers of $x-1$. If we tell M11.1 that $x<1$, we get:

Series[1 + (1 + Sqrt[1/(1-x)])  Sqrt[1/(1-x)], {x, 1, 3}, Assumptions->x<1] //TeXForm

$-\frac{1}{x-1}+\frac{i}{\sqrt{x-1}}+1+O\left((x-1)^{7/2}\right)$

which is the same as before, even though we might wish to have a power series in $1-x$. Now, in M11.2, we have:

Series[1 + (1 + Sqrt[1/(1-x)]) Sqrt[1/(1-x)], {x, 1, 3}, Assumptions->x>1] //TeXForm

$-\frac{1}{x-1}+\frac{i}{\sqrt{x-1}}+1+O\left((x-1)^{7/2}\right)$

Series[1 + (1 + Sqrt[1/(1-x)]) Sqrt[1/(1-x)], {x, 1, 3}, Assumptions->x<1] //TeXForm

$\left(\frac{1}{\sqrt{1-x}}+\frac{1}{1-x}+1\right)+O\left((x-1)^4\right)$

Notice that the Assumptions -> x>1 version returns what M11.1 did, while the Assumptions -> x<1 version has the issues described in the OP. In particular, we see that Series is trying to create a power series in $1-x$ (note the Sqrt[1-x] and 1/(1-x) terms), but the overall SeriesData object is a power series in $x-1$, and so problems arise.

Until these issues are worked out, it might make sense to use Assumptions->x>1 in your code.

$\endgroup$
  • 3
    $\begingroup$ The use of fractional powers in 1-x is actually a bug fix (many bug fixes, really). Some of the details, such as integer powers of 1-x appearing in the SeriesData object coefficients, do appear to be amiss. (Maybe you knew this, but I would guess some readers did not.) $\endgroup$ – Daniel Lichtblau Oct 1 '17 at 15:37
  • $\begingroup$ @DanielLichtblau When all is said and done, do you judge the behavior here to be a bug? If so, do you or CarlWolf wish to report it, or shall I? Thanks, $\endgroup$ – bbgodfrey Oct 7 '17 at 0:46
  • $\begingroup$ (1) @bgodfrey I added the "bugs" tag, so yes, I regard appearance of such integer powers in the coefficients as a bug. I reported it. Should be fixed for the next release. $\endgroup$ – Daniel Lichtblau Oct 7 '17 at 15:06
  • 1
    $\begingroup$ (2) As best I am aware, @CarlWoll is not actually a wolf. But I should mention I've never seen him during a full moon. $\endgroup$ – Daniel Lichtblau Oct 7 '17 at 15:08
7
$\begingroup$

This seemingly simple problem indeed produces unexpected results:

ser1 = Series[test // Factor, {x, 1, -1}]
(* -(1/(x - 1)) + SeriesData[x, 1, {}, -1, 0, 1] *)
ser2 = Series[test, {x, 1, -1}]
(* SeriesData[x, 1, {1 + ((1 - x)^(-1))^Rational[1, 2] + (1 - x)^(-1)}, 0, 2, 1] *)

Note that ser1 is a series of order -1, as requested, whereas ser2 is a series of order +1. Compare

ser3 = Series[test // Factor, {x, 1, 1}] 
(* SeriesData[x, 1, {-1, 1 + ((1 - x)^(-1))^Rational[1, 2]}, -1, 2, 1] *)

which is mathematically the same as ser2, although its Mathematica internal representation is different. So one question is, why does Mathematica return series of different orders for ostensibly the same problem.

It also is worth noting that

ser2 - ser1
(* 1/(x - 1) + SeriesData[x, 1, {}, -1, 0, 1] *)

because Mathematica discards higher order terms, until both expressions are of the same order, as it should. It may be helpful to see the expressions as they actually appear on the screen:

enter image description here

Addendum:

Both the original question and the recent addition to it involve series expansions about a branch point, which invites problems. In fact, there is no well defined series about a branch point, unless additional conditions are imposed. On the other hand, adding an extra condition in the form of Assumptions -> x <= 1 to the original problem yields the same result as before.

Now, explicitly consider the new addition to the question:

test = 1/(1 - x) + 1/Sqrt[1 - x] (1/Sqrt[1 - x] + 1) + 1; 
ser1 = Series[test // Factor, {x, 1, -1}]
(* SeriesData[x, 1, {-2 - (1 - x)^Rational[1, 2]}, -1, 0, 1] *)
ser2 = Series[test, {x, 1, -1}]
(* -(1/(x - 1)) + SeriesData[x, 1, {}, -1, 0, 1] *)

Again, for clarity this is how this material appears on the screen.

enter image description here

The two results ostensibly are to the same order and, hence, can be compared directly. ser2 is incorrect. Also, Assumptions -> x <= 1 does not help. This appears to be a bug.

Progress Report: Version 11.3 produces the same results as in the addendum

$\endgroup$
  • $\begingroup$ Thanks for your reply. By the way, I just updated my original question with an additional example, in which the consequences are more subtle, but also harder to detect in a real-life setting. $\endgroup$ – Stan Sep 29 '17 at 19:09
  • 5
    $\begingroup$ That (1 - x)^(-1) inside the coefficient list for ser2 looks suspect. Will investigate (next week). $\endgroup$ – Daniel Lichtblau Sep 29 '17 at 20:22
  • 2
    $\begingroup$ @DanielLichtblau Please do. This looks like a bug to me, new to Version 11. However, I shall hold off adding a bug header until you have a chance to weigh in. Thanks. $\endgroup$ – bbgodfrey Sep 29 '17 at 20:44
  • $\begingroup$ @DanielLichtblau The problem persists with Version 11.3. $\endgroup$ – bbgodfrey Apr 15 '18 at 3:51
  • 1
    $\begingroup$ I think the issue remaining in 11.3 is the same as noted here and also here. All three behave better in the current devel code and, barring trouble appearing in testing (which has not happened as yet) the fixes will appear in the next release. $\endgroup$ – Daniel Lichtblau Apr 16 '18 at 14:52

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.