# Why does plotting a PolyLog function yield 1/0 error? (Intentional bug?)

Bug introduced in 11.0 and fixed in 11.1.1

In Mathematica 11.0, the following

Plot[Re[PolyLog[2, 1/(1 - x)]], {x, -3, 3}]


generates a Power::infy message before displaying the plot. I asked WRI about this [CASE:3810816], and the support representative told me that

The developer said the generated Power message is by design.

Since Plot[1/(1 - x), {x, -3, 3}] does not generate a similar error, I find this a little inconsistent?

Is there a rationale for intentionally introducing a bug in Plot?

• It' s related to Exclusions.Try using Exclusions->None. – Carl Woll Mar 23 '17 at 17:27
• @CarlWoll I don't understand that. Why doesn't Plot[1/(1 - x), {x, -3, 3}] or even Plot[Re[Log[1/(1 - x)]], {x, -3, 3}] generate errors? – QuantumDot Mar 23 '17 at 17:58
• I don't have any knowledge about the internals of Exclusions, but we can assume that it is looking for a singularity of the expression. The code to find this singularity must depend on the expression, and finding singularities of an arbitrary function must involve evaluating it, possibly at the point of singularity. Presumably your other examples are common enough that function evaluations are not required. – Carl Woll Mar 23 '17 at 18:55
• @CarlWoll - Exclusions -> 1 also eliminates the warning message and strikes me as easier to understand than Exclusions -> None – Bob Hanlon Mar 23 '17 at 20:57
• @BobHanlon Exclusions->2 also eliminates the warning message. Basically, Exclusions->rhs eliminates automatic exclusion detection unless rhs contains Automatic. It is the automatic exclusion detection code that is issuing messages. – Carl Woll Mar 23 '17 at 22:14

To explain the difference between the OP's and QuantumDot's comment examples, consider the V11 automatic exclusions expansions:

VisualizationExpandExclusions[Re[PolyLog[2, 1/(1 - x)]], {x}, Automatic]  (* OP *)
VisualizationExpandExclusions[Re[Log[1/(1 - x)]], {x}, Automatic]         (* comment *)
(*
{{Im[1/(1 - x)] == 0, Re[1/(1 - x)] >= 1}, {1 - x == 0, True}, {1/(1 - x) == 1, True}}
{{Im[1/(1 - x)] == 0, Re[1/(1 - x)] <= 0}, {1 - x == 0, True}, {False, True}}
*)


The first two discontinuities are the same, but the third is different. Moreover, in the OP's case, the third evaluates to 1/0 at the discontinuity x == 1. This seems to be source of the error message. This could probably be considered a bug, but if you've been around Mathematica long enough, you probably remember when Plot was always giving Pwer::infy messages.

Some tests follow below. The {False, True} in the comment version ex2 is perhaps not a valid exclusion spec, as it seems to turn off exclusions. The third set of exclusions ex3 will show that it is the interaction between the last two exclusions in the OP's PolyLog example that leads to the error.

ex1 = {{Im[1/(1 - x)] == 0, Re[1/(1 - x)] >= 1}, {1 - x == 0, True}, {1/(1-x) == 1,True}};
ex2 = {{Im[1/(1 - x)] == 0, Re[1/(1 - x)] >= 1}, {1 - x == 0, True}(*, {False, True}*)};
ex3 = {{Im[1/(1 - x)] == 0, Re[1/(1 - x)] >= 1}, {1/(1-x) == 1,True}};


Using the PolyLog exclusions generates 1/0. errors; using the Log exclusions generates no errors:

Plot[Re[Log[1/(1 - x)]], {x, -3, 3}, Exclusions -> ex1]         (* 1/0. error *)
Plot[Re[PolyLog[2, 1/(1 - x)]], {x, -3, 3}, Exclusions -> ex2]  (* no error *)
Plot[Re[PolyLog[2, 1/(1 - x)]], {x, -3, 3}, Exclusions -> ex3]  (* no error *)
Plot[1/(1 - x), {x, -3, 3}, Exclusions -> ex1]                  (* 1/0. error *)


Some functions must be white-listed:

Plot[x, {x, -3, 3}, Exclusions -> ex2]                          (* no error *)
Plot[Sin[x], {x, -3, 3}, Exclusions -> ex2]                     (* no error *)


But the discontinuity does not have to be at x == 1, for the OP's exclusions to generate a 1/0. error:

Plot[Tan[x], {x, -3, 3}, Exclusions -> ex1]                     (* 1/0. error *)


As for a rationale justifying the error message in plotting PolyLog[], I am at a loss.

• This is very helpful and enlightening. So, would you this behaviour a bug? – QuantumDot Mar 27 '17 at 16:46
• @QuantumDot As a bug, it's not an error per se (the end result is correct and apparently 1 is divided by 0), but, OTOH, it's unwanted, unhelpful, and unnecessary. If it were my software product, I would say it's a bug because it irritates the customers for no good reason. – Michael E2 Mar 27 '17 at 18:51
• Do you know if it is possible to extend the automatic Exclusions computation by informing it of all the singularities in a user-derived functions of the form f[x_?NumericQ]:=...? That would be most useful, especially in building packages for the numerical evaluation of special functions. – QuantumDot Feb 14 '18 at 3:49