# Problem in plotting complex valued data in Mathematica

I have a situation where a function sys yields solutions in complex values while I change its argument x from $-\pi$ to $+\pi$ as in the following:

Bands[sys[t1, t2, 3], {x, -\[Pi], \[Pi]}]


which gives me list of complex values with x as following:

{{-3.14159, -1.99705 + 0.0000290634 I}, {-3.02073, -1.99703 -
0.0000293392 I}, {-2.8897, -1.99698 -
0.0000302499 I}, {-2.76735, -1.99691 - 0.0000316411 I},...{3.14159, 1.99705
+0.0000290634 I}}


Now if I write

Re[Bands[sys[t1, t2, 3], {x, -\[Pi], \[Pi]}]]


it gives me correct list of real parts of the complex values which is:

{{-3.14159, -1.99705},{-3.02073, -1.99703},{-2.8897, -1.99698}...so on} but for imaginary parts:

Im[Bands[sys[t1, t2, 3], {x, -\[Pi], \[Pi]}]]


it gives me:

{{0,0.0000290634 I},{0,- 0.0000293392 I},{0,- 0.0000302499 I}...so on}

thus, not showing the correct values of variable x. As a result, the real values giving me correct plot but the imaginary values don't give me correct plot since the values of 'x' show all zero which is not true.

Someone (@Rom38) suggested me to use: {First@#, Im@Last@#} & /@ [Bands[...]. But in my case how do I implement it when the plot command I use to plot the imaginary part is:

PlotBands[Im[Bands[sys[t1, t2, 1.5], {x, -2 \[Pi], 2[Pi]}]], FrameLabel -> {"x", "Im(E)"}]


Any help will be much appreciated. Many thanks!

• It is clear that imaginary part of the real number is zero. Try something like {First@#,Im@Last@#}&/@Bands[....] – Rom38 Apr 16 '18 at 6:27
• Actually my problem is precisely as in this link: mathematica.stackexchange.com/questions/58549/… @ Rom38 I couldn't understand your point. Can you explain. – foi Apr 16 '18 at 6:48
• My point is following: applying the Im for both {x,y}, you will have {0,Im[y]} in case if x is already real. Mapping my pure function {First@#,Im@Last@#}& for each sublist of your list, you will apply the Im only to second element of each {x,y} pair. You should use the /@` command for this. As result, just copy-paste my code from previous comment and see the result – Rom38 Apr 16 '18 at 7:19
• @Sam don't use answers to comment. Even with low reputation you can comment under your questions. The problem seems to be that you have created two accounts, see: mathematica.stackexchange.com/help/merging-accounts to fix this. – Kuba Apr 16 '18 at 7:31