I am new to Mathematica. I am struggling but I can't code properly. Please help me plot the Wigner function between x and p. In the following equation $n$ is the number of iterations, and $b=5$, $k=2$, and $\alpha=2\pi/3$:


Here is code which I use to plot it:

  Animate[ListPlot[x = Table[0, {i, 1, m}];
  p = Table[0, {i, 1, m}];
  \[Alpha] = 2 \[Pi]/q;
  q = 3;
  k = 2;
  b = 5;
  x[[1]] = 1.9;
  p[[1]] = 2;
   W[x[[n + 1]], p[[n + 1]]] = 
    2*Exp[4 \[Pi]^2*(Cos[\[Alpha]]*(p[[n]] + k*Sin[x[[n]]]) - 
          x[[n]]* Sin[\[Alpha]])^2 - ( 
        x[[n]]*Cos[\[Alpha]] + 
         Sin[\[Alpha]]*(p[[n]] + k * Sin[x[[n]]]))^2 - b], {n, 1, 
    Length[x] - 1}];

  Transpose[{x, p}], Joined -> True, AspectRatio -> 1], {m, 1, 1000, 
  1}, AnimationRate -> 100, AnimationRunning -> False]
  • $\begingroup$ Please post your equation as Mathematica code, (and indent with four spaces) rather than LaTeX. It makes it much easier for people to copy and paste, and also helps to identify any mistakes in your coding. $\endgroup$ – aardvark2012 Nov 16 '17 at 6:59
  • $\begingroup$ I do not see any equation here, but an expression. Further, explain please more clearly, what do you want to do with it? May be a simple example is available to let us understand your question? $\endgroup$ – Alexei Boulbitch Nov 16 '17 at 8:35
  • $\begingroup$ – Alexei Boulbitch ....Sir this is basicaly evolution of wigner function which evolves after every kick $\endgroup$ – Ali Nov 16 '17 at 9:11
  • $\begingroup$ The reason you see no plot is that you never set values for x or p anywhere (except for the initial x[[1]] and p[[1]]). I would first define W as a function and then iterate using NestList or Table. $\endgroup$ – bill s Nov 16 '17 at 13:43

Your functional form does not evaluate, but here is a simple example of how to define and iterate a function. Change the "5" to the desired number of iterations,the function to your desired form, and replace {1,1} with your initial conditions:

w[{x_, p_}] := {x Cos[p], p Exp[x]};
NestList[w, {1., 1.}, 5]

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.