8
$\begingroup$

This bug has been fixed in V11.2.0 or earlier. Regression in V13.0.0 or earlier.


Consider

Plot[Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}]

At least in Mma 11 it gives the following picture:zero

Meanwhile,

Plot[Im[ComplexExpand[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)]], {x, 0, 
  1}]

gives

enter image description here

What is going on here?

$\endgroup$
13
  • $\begingroup$ My initial guess is that it's a bug, and Plot is doing some transformation that it shouldn't. $\endgroup$
    – Michael E2
    Feb 10, 2021 at 3:16
  • $\begingroup$ At the same time, e.g., Plot[Im[1/((-1)^(2/3) + x)], {x, 0, 1}] works as expected. $\endgroup$
    – Roma Lee
    Feb 10, 2021 at 3:18
  • $\begingroup$ It works with arbitrary precision: Plot[Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}, WorkingPrecision -> 10]. It works with a black-box machine-precision function: f[x_?NumericQ] := Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)]; Plot[f[x], {x, 0, 1}]. And a third way: Plot[Im[(1 + (-1.)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}] $\endgroup$
    – Michael E2
    Feb 10, 2021 at 3:24
  • $\begingroup$ @MichaelE2 Yes, the erroneous behavior is very fragile. Can it be related to (-1)^(...) representation of complex numbers? I myself make mistakes from time to time when checking for presence of complex numbers with _Complex pattern. Maybe Mma erroneously assumes the argument of Im is real as there are no Complex heads? But then why Plot[Im[1/((-1)^(2/3) + x)], {x, 0, 1}] work fine? $\endgroup$
    – Roma Lee
    Feb 10, 2021 at 3:30
  • 1
    $\begingroup$ Sorry for all the experiments. NOPE: Plot[N@Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}]. Add Evaluate, and YEP: Plot[Evaluate@N@Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}] $\endgroup$
    – Michael E2
    Feb 10, 2021 at 3:30

1 Answer 1

2
$\begingroup$

It seems that it was fixed in V11.2.0 or earlier. It was fine until V12.0.0 or later. And there's a regression in V13.0.0 or earlier.

V11.2.0

v11

V12.0.0

v12

V13.0.0

13

$\endgroup$

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.