1
$\begingroup$

This code creates three complex lists. The third list is the Union of the other two. There are three plots. When applying ComplexListPlot to all three lists I would expect the third plot to be the first two plots combined. But no! Why? What am I missing?

z = Table[{x, I*y}, {x, -2, 0}, {y, -2, 0}]
s = z^3
g = Union[z, s]
ComplexListPlot[#, Joined -> True, PlotRange -> Full] & @@ z
ComplexListPlot[#, Joined -> True, PlotRange -> Full] & @@ s
ComplexListPlot[#, Joined -> True, PlotRange -> Full] & @@ g

First plot

Second Plot

Third Plot

So I expected to add the first and second plot. But The second plot equals the third plot. ComplexListPlot[#, Joined -> True, PlotRange -> Full] & @@ g[[3;;4]] gives partly the right picture. Very strange! I use Mathematica 12.1.

$\endgroup$
2
  • 1
    $\begingroup$ try ComplexListPlot[z[[1]], Joined->True], ComplexListPlot[s[[1]], Joined->True] and ComplexListPlot[Join[z[[1]],s[[1]]], Joined->True] $\endgroup$ – kglr Feb 18 at 4:39
  • 1
    $\begingroup$ hint: consider z1 = {u, v, w}; s1 = {a, b, c}; g1 = Union[z1, s1]; and compare # & @@ z1 and # & @@ s1 and # & @@ g1 (versus, say #2 & @@ z1 and #2 & @@ s1 and #2 & @@ g1), Similarly, for an arbitrary function foo, inspect foo[# ]& @@ z1 and foo[# ]& @@ s1 and foo[# ]& @@ g1 . $\endgroup$ – kglr Feb 18 at 4:43
3
$\begingroup$

Look at the output from Table. E.g. z

{{{-2, -2 I}, {-2, -I}, {-2, 0}}, {{-1, -2 I}, {-1, -I}, {-1, 0}}, {{0, -2 I}, {0, -I}, {0, 0}}}

This is a list of 3 elements. Each element is a list of tuples. Each tuple contains a real and an imaginary number.

I assume that you wanted to create a list of complex numbers and to plot them. To do so, you must write:

z = Flatten[Table[{x + I*y}, {x, -2, 0}, {y, -2, 0}], 1]

Further, ComplexListPlot takes one argument and options. But when you write

ComplexListPlot[#, Joined -> True, PlotRange -> Full] & @@ z

All the elements of z are given as arguments to ``ComplexListPlot`. The first is then treated as data, the rest as options. Therefore, you should write something like:

z = Flatten[Table[{x + I*y}, {x, -2, 0}, {y, -2, 0}], 1]
s = z^3
g = Union[z, s]
ComplexListPlot[z]
ComplexListPlot[s]
ComplexListPlot[g]
$\endgroup$
2
  • $\begingroup$ Thanks! Sorry, obviously my question was ambiguous. I edited my question by adding three outputs for clarification. Any other idea? $\endgroup$ – user57467 Feb 18 at 4:30
  • $\begingroup$ With your input, I only get 2 lines per plot. Could it be a version problem? I have 12.1 $\endgroup$ – Daniel Huber Feb 18 at 13:14

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.