# Why doesn't Mathematica plot $n(-1)^n$ with Plot?

I was in doubt if this question should be asked in Mathematics.SE or Mathematica.SE, but I've decided this site would be more appropriate, because I think those who read my question here will know about both mathematics and Mathematica.

I tried to plot $n(-1)^n$ with Plot, but it showed nothing. When I tried to plot it with DiscretePlot, it worked. Why did that happen?

• $n (-1)^n$ is real only for integer $n$ and complex for everything else. Plot[] skips complex values, so... – J. M.'s ennui Apr 17 '13 at 0:41
• Use this instead Plot[Re[x Exp[i x \[Pi] ]], {x, -1, 1}] – Spawn1701D Apr 17 '13 at 0:42
• ...or Plot[n (-1)^Floor[n], {n, -5, 5}]. – J. M.'s ennui Apr 17 '13 at 0:45
• Actually $(-1)^n$ becomes a multivariable function. It may take a real value apart from when $n$ is integer (but of course not when $n$ is irrational). – Spawn1701D Apr 17 '13 at 0:49

Take what you need:

Plot[
{Re, Im, Arg, Abs}[n (-1)^n] // Through,
{n, 1, 10},
Evaluated -> True
] • I can't help but to read Mr. Wizards posts in Professor Hubert J. Farnsworth's voice. – jmlopez Apr 17 '13 at 3:01

See the mage of Araby
Get your functions, old and new
With a two-year guarantee
And a choice of colors, too

Map[Function[f, Plot[n (-1)^f[n], {n, -10, 10}, PlotLabel -> (n (-1)^f[n])]],
{{Floor, Ceiling}, {Round, IntegerPart}}, {2}] // GraphicsGrid • And what about the point $\frac{2}{3}$ for example? It is a real function there and to many other like this points. – Spawn1701D Apr 17 '13 at 9:31
• @Spawn, Ah, for that you don't want the principal value of Power[]. I understand that Mathematica these days has the Surd[] function; that would be useful in the situation you think of. – J. M.'s ennui Apr 17 '13 at 9:32
• Actually 1 is the principal value for the odd roots the rest are complex of course. – Spawn1701D Apr 17 '13 at 9:36
• @Spawn, I don't quite think so. To take $(-1)^{2/3}$ as an example, the real value is not the principal value, at least if we want our power function to have a branch cut that agrees with our branch cut choice for the logarithm. – J. M.'s ennui Apr 17 '13 at 9:45
• Just run it on wolfram alpha it will show you that 1 is the principal value. I suppose is a different definition for different purposes. – Spawn1701D Apr 17 '13 at 9:53

Perhaps @Gustavo Bandeira intended just discrete values of n. Then:

ListPlot[Table[n (-1)^n, {n, 1, 20}], PlotStyle -> PointSize[Large]]

• OP did say that he has used DiscretePlot[]. – J. M.'s ennui Apr 17 '13 at 3:31