2
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ It' s related to Exclusions.Try using Exclusions->None. $\endgroup$ – Carl Woll Mar 23 '17 at 17:27
  • $\begingroup$ @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? $\endgroup$ – QuantumDot Mar 23 '17 at 17:58
  • $\begingroup$ 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. $\endgroup$ – Carl Woll Mar 23 '17 at 18:55
  • $\begingroup$ @CarlWoll - Exclusions -> 1 also eliminates the warning message and strikes me as easier to understand than Exclusions -> None $\endgroup$ – Bob Hanlon Mar 23 '17 at 20:57
  • $\begingroup$ @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. $\endgroup$ – Carl Woll Mar 23 '17 at 22:14
4
$\begingroup$

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

Visualization`ExpandExclusions[Re[PolyLog[2, 1/(1 - x)]], {x}, Automatic]  (* OP *)
Visualization`ExpandExclusions[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.

$\endgroup$
  • $\begingroup$ This is very helpful and enlightening. So, would you this behaviour a bug? $\endgroup$ – QuantumDot Mar 27 '17 at 16:46
  • 2
    $\begingroup$ @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. $\endgroup$ – Michael E2 Mar 27 '17 at 18:51
  • $\begingroup$ 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. $\endgroup$ – QuantumDot Feb 14 '18 at 3:49

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.