# Problems with Series and Map

Consider the two following ways to write down the same expression

ff1 = {(a - b)*Log[2 - z]*Log[z]*PolyLog[2, z/2] -
2*(a - b)*Log[z]*PolyLog[3, (2 - z)/2] + (7*(a - b)*Log[z]*Zeta[3])/4};

ff2 = {(a - b)*Log[z]*(Log[2 - z]*PolyLog[2, z/2] -
2*PolyLog[3, (2 - z)/2] + (7*Zeta[3])/4)};


Using Simplify[ff1 - ff2] we can easily check that the two expressions are identical. Now let us expand both expressions around z=0 using Series and Map

seriesFu[ex_] :=
Normal[Series[#, {z, 0, 0}, Assumptions -> {z > 0}]] & /@ ex
r1 = seriesFu /@ ff1
r2 = seriesFu /@ ff2


This yields

{-2 \[Zeta](3) (a-b) log(z)+7/4 (a \[Zeta](3) log(z)-b \[Zeta](3) log(z))+1/2 z (a log(2) log(z)-b log(2) log(z))}
{-(1/4) \[Zeta](3) (a-b) log(z)}


Surprisingly, in Mathematica 11.2 r1 and r2 are not the same, since

Simplify[r1 - r2]


returns

{1/2 z log(2) (a-b) log(z)}


Notice that if we apply Series directly, the difference vanishes, as it should.

s1 = Normal[Series[ff1, {z, 0, 0}, Assumptions -> {z > 0}]]
s2 = Normal[Series[ff2, {z, 0, 0}, Assumptions -> {z > 0}]]
Simplify[s1 - s2]


gives

{1/4 (b \[Zeta](3) log(z)-a \[Zeta](3) log(z))}

{-(1/4) \[Zeta](3) (a-b) log(z)}

{0}


Mathematica 11.1 is also affected, while Mathematica 11.0 and Mathematica 10.3 do not have this problem.

I noticed this behavior, because a calculation I did with Mathematica 11.0 gave me completely wrong results once I evaluated the same notebook with the version 11.2.

Can someone reproduce this issue? Is it a bug, or have there been some fundamental changes in the way Series works? Are there workarounds?

Edit: I'm afraid that my question was misunderstood. I'm well aware of the intricacies related to the expansion of functions around their singularities. But this is not what I'm asking. My point is that Mathematica versions before and after 11.1 give completely different result for the same piece of code and I want to understand why.

I made few more tests and it seems that the issue is related to Normal not Map. Consider the following

ff1 = (a - b)*Log[2 - z]*Log[z]*PolyLog[2, z/2] -
2*(a - b)*Log[z]*
PolyLog[3, (2 - z)/2] + (7*(a - b)*Log[z]*Zeta[3])/4;
ff2 = (a - b)*
Log[z]*(Log[2 - z]*PolyLog[2, z/2] -
2*PolyLog[3, (2 - z)/2] + (7*Zeta[3])/4);


and

(Series[#, {z, 0, 0}, Assumptions -> {z > 0}] & /@ (ff1)) // Simplify
(Series[#, {z, 0, 0}, Assumptions -> {z > 0}] & /@ (ff2)) // Simplify
Simplify[% - %%]


Even though here Series is applied to each term separately, it still produces identical results.

1/4 \[Zeta](3) (b-a) log(z)+O(z^1)

-(1/4) \[Zeta](3) (a-b) log(z)+O(z^1)

O(z^1)


However, with Normal we observe the behavior that I described earlier

(Normal[Series[#, {z, 0, 0},
Assumptions -> {z > 0}]] & /@ (ff1)) // Simplify
(Normal[Series[#, {z, 0, 0},
Assumptions -> {z > 0}]] & /@ (ff2)) // Simplify
Simplify[% - %%]


gives

1/4 (a-b) log(z) (z log(4)-\[Zeta](3))

-(1/4) \[Zeta](3) (a-b) log(z)

1/4 z log(4) (b-a) log(z)


Notice that with versions 11.0, 10.3 and 9.0 both codes give the same results. This example might be somewhat artificial, but I think that it clearly shows that something fundamental in Series/Normal was changed in version 11.1. This is what I hope to understand, to avoid such pitfalls when running same codes on different Mathematica versions.

I guess WRI would say that applying Series to each term separately is undefined behavior so that one cannot expect any consistency across different versions.

• For comparison purposes, can you investigate what happens if you use Limit[] with Direction -> -1? – J. M.'s discontentment Nov 10 '17 at 15:10
• You should isolate an example that gets rid of all the junk. There are unneeded lists and Map that only serve to confuse things. The answer by @BobHanlon appears to show the results are essentially equivalent once the confusing clutter is removed. If you want to claim otherwise then a minimal example that shows the actual discrepancy is needed. – Daniel Lichtblau Nov 11 '17 at 14:52
• Please evaluate the five last code blocks (after Edit:...) in my question on a Mathematica version 11.2 and a version earlier than 11.1 (e.g. 11.0 or 10.3). There are no lists there and you will see that the results do not agree. As I already wrote, for MMA 11.1 and 11.2 this depends on whether one uses Normal or not. Earlier versions give the same output regardless of Normal. – vsht Nov 12 '17 at 6:27

This is not a bug, but normal behavior of Series.

The first term of Series for a function f at z=0 is f[0].

Series[f[x], {x, 0, 0}] // Normal


All functions, that are not defined at 0, are given back unevaluated by Series, because it makes no sense to give back -Infinity.

ser0 = Series[Log[z] Cos[z - w], {z, 0, 0}, Assumptions -> z > 0] //
Normal

(*    Cos[w] Log[z]     *)


The ff1 and ff2 can both be splitted in 3 terms, but with different limit at z=0.

Plot[Evaluate[(List @@ ff1) /. {a -> 1, b -> 2.5}], {z, -2, 2},
PlotRange -> 8]


Plot[Evaluate[(List @@ ff2) /. {a -> 1, b -> 2.5}], {z, -2, 2},
PlotRange -> 8]


With ff1 there are two terms with Infinity-Limit at z=0 and therfore two terms are given back partly unevaluated by Series.

With ff2 there is only one term given back unevaluated and therefore you get different Series of the two functions.

ns1 = Normal[
Series[#, {z, 0, 0}, Assumptions -> {z > 0}]] & /@ (List @@ ff1)

(*     {0, -2 (a - b) Log[z] Zeta[3],
7/4 (a Log[z] Zeta[3] - b Log[z] Zeta[3])}     *)

ns2 = Normal[
Series[#, {z, 0, 0}, Assumptions -> {z > 0}]] & /@ (List @@ ff2)

(*     {a - b, Log[z], -(Zeta[3]/4)}     *)

• Good analysis, but what I wanted to point out is the difference between the results from version 11.1 and above and previous versions. When you apply List to ff1 and ff2, you are really forcing Series to look at each term separately. However, I believe that this is not how it behaves (or used to behave) in my examples. It seems to be something related to Normal not Map as I originally assumed. I edited my question accordingly. – vsht Nov 11 '17 at 6:57
• By applying Map to ff1, ff2 you too force Series to look at each term separately. – Akku14 Nov 11 '17 at 9:20
• First: By applying Map to ff1, ff2 you too force Series to look at each term separately. ff1//Lengthshows ff1 to be composed of three parts. With Mapthey are treated separately and added according to their sign at the end. Second: With Version 8.0 I also get the same results for (Normal[Series[#, {z, 0, 0}, Assumptions -> {z > 0}]] & /@ (ff1)) // Simplify (Normal[Series[#, {z, 0, 0}, Assumptions -> {z > 0}]] & /@ (ff2)) // Simplify Simplify[% - %%]. Your result with Vers. 11.2 seems to have sign-errors. Give the first and last line a (-) to get 0. – Akku14 Nov 11 '17 at 9:30
• You don't have version 11.1 or 11.2 to test yourself? – vsht Nov 11 '17 at 10:04
• Your answer actually shows that when Series is looking separately at each term of ff1 and ff2, the final results should differ. However, on older Mathematica versions this is not the case, which is why I suspect that despite Map there Series still somehow looks at the full expression. It is also not so clear to me why having or not having Normal should change the two results on 11.1 and 11.2. This is why I would not call this behavior of Series normal. At least I do not understand it. – vsht Nov 11 '17 at 10:15
ff1 = {(a - b)*Log[2 - z]*Log[z]*PolyLog[2, z/2] -
2*(a - b)*Log[z]*PolyLog[3, (2 - z)/2] + (7*(a - b)*Log[z]*Zeta[3])/4};

ff2 = {(a - b)*
Log[z]*(Log[2 - z]*PolyLog[2, z/2] -
2*PolyLog[3, (2 - z)/2] + (7*Zeta[3])/4)};

Simplify[ff1 - ff2]

(* {0} *)


Map is included in your definition of seriesFu so you do not want to Map seriesFu onto the components of ff1 and ff2, i.e., just use @

seriesFu[ex_] := Normal[Series[#, {z, 0, 0}]] & /@ ex
r1 = seriesFu@ff1 // Simplify
r2 = seriesFu@ff2

(* {1/4 (-a + b) Log[z] Zeta[3]}

{-(1/4) (a - b) Log[z] Zeta[3]} *)

Simplify[r1 - r2]

(* {0} *)


It is not clear why you are using extraneous List brackets.

• The example is admittedly somewhat artificial and possibly not well defined. First I though that it was something related to Map but it looks like the real reason is Normal. I edited my question accordingly. Actually I'm just trying to understand why different Mathematica versions give me different results. Obviously, one would normally not map a Plus to Series, but I'm curious to know what was changed under the hood of version 11.1 to produce this discrepancy. – vsht Nov 11 '17 at 7:02