Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
$n (-1)^n$ is real only for integer $n$ and complex for everything else. Plot[] skips complex values, so... –  J. M. 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. 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

3 Answers 3

up vote 10 down vote accepted

Take what you need:

  {Re, Im, Arg, Abs}[n (-1)^n] // Through,
  {n, 1, 10},
  Evaluated -> True

enter image description here

share|improve this answer
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

Come on, pick one, sweetheart!

share|improve this answer
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. 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. 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]]
share|improve this answer
OP did say that he has used DiscretePlot[]. –  J. M. Apr 17 '13 at 3:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.