7
$\begingroup$

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 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 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 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 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 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.