2
$\begingroup$

I have a 2 variable function named 'wig', and I have to take double integral of its absolute value with respect to the variables p and q. Then subtract 1 from the final answer and 3D plot it with q and p. In short, I have to compute $(\int\int dq dp |(wig)|) - 1$ and then plot it. By using the following code, my integrals do not compute. Please tell me what is wrong with my code and how to correct it.

wig = (2*(7 - 20*I*Sqrt[2]*p - 24*p^2 - 20*Sqrt[2]*q + 48*I*p*q + 24*q^2 + 8*(-3 + 8*p^2 + 8*I*p*(Sqrt[2] - 2*q) + 8*Sqrt[2]*q - 8*q^2)*Conjugate[p]^2 + 4*(-5*Sqrt[2] + 16*Sqrt[2]*p^2 + 28*q - 16*Sqrt[2]*q^2 - 4*I*p*(-7 + 8*Sqrt[2]*q))*Conjugate[q] + 8*(3 - 8*p^2 - 8*I*p*(Sqrt[2] - 2*q) - 8*Sqrt[2]*q + 8*q^2)*Conjugate[q]^2 + 4*Conjugate[p]*(-16*I*Sqrt[2]*p^2 - 4*p*(-7 + 8*Sqrt[2]*q) + I*(5*Sqrt[2] - 28*q + 16*Sqrt[2]*q^2) - 4*(-8*I*p^2 + 8*p*(Sqrt[2] - 2*q) + I*(3 - 8*Sqrt[2]*q + 8*q^2))*Conjugate[q])))/ (E^(2*Abs[-(1/Sqrt[2]) + I*p + q]^2)*(3*Pi*(Sqrt[2] - 4*I*p - 4*q)* (Sqrt[2] + 4*I*Conjugate[p] - 4*Conjugate[q])))

intofwig = Integrate[Abs[wig], q]

doubint = Integrate[intofwig, p]

delta = Solve[doubint - 1]

Plot3D[delta, {q, - 10 , 5}, {p, -10, 5}, PlotRange -> All]

$\endgroup$
5
  • $\begingroup$ Your code has syntax errors. Also, I see no wig defined anywhere. It looks like you copied half the cell or something. Try again. $\endgroup$
    – Nasser
    Aug 16, 2023 at 10:22
  • $\begingroup$ Oops let me fix that $\endgroup$
    – Anaya
    Aug 16, 2023 at 10:48
  • $\begingroup$ I have tried to fix it. If I put it in a code block, 'wig' does not appear I don't know why. $\endgroup$
    – Anaya
    Aug 16, 2023 at 10:56
  • $\begingroup$ No. You still have syntax errors. Ipq should be I*pq and ISqrt[2] should be I*Sqrt[2] and Ip should be I*p and IConjugate[p] should be I*Conjugate[p] and so on. Simply convert the code to input form and copy/paste that. All your I are for some reason stuck to the letters next to them. $\endgroup$
    – Nasser
    Aug 16, 2023 at 10:58
  • $\begingroup$ `Thanks. I copied the input form. Hope it's fine now $\endgroup$
    – Anaya
    Aug 16, 2023 at 11:02

1 Answer 1

3
$\begingroup$
wig = (2*(7 - 20*I*Sqrt[2]*p - 24*p^2 - 20*Sqrt[2]*q + 48*I*p*q + 
      24*q^2 + 
      8*(-3 + 8*p^2 + 8*I*p*(Sqrt[2] - 2*q) + 8*Sqrt[2]*q - 8*q^2)*
       Conjugate[p]^2 + 
      4*(-5*Sqrt[2] + 16*Sqrt[2]*p^2 + 28*q - 16*Sqrt[2]*q^2 - 
         4*I*p*(-7 + 8*Sqrt[2]*q))*Conjugate[q] + 
      8*(3 - 8*p^2 - 8*I*p*(Sqrt[2] - 2*q) - 8*Sqrt[2]*q + 8*q^2)*
       Conjugate[q]^2 + 
      4*Conjugate[
        p]*(-16*I*Sqrt[2]*p^2 - 4*p*(-7 + 8*Sqrt[2]*q) + 
         I*(5*Sqrt[2] - 28*q + 16*Sqrt[2]*q^2) - 
         4*(-8*I*p^2 + 8*p*(Sqrt[2] - 2*q) + 
            I*(3 - 8*Sqrt[2]*q + 8*q^2))*Conjugate[q])))/(E^(2*
       Abs[-(1/Sqrt[2]) + I*p + q]^2)*(3*
      Pi*(Sqrt[2] - 4*I*p - 4*q)*(Sqrt[2] + 4*I*Conjugate[p] - 
        4*Conjugate[q])));

 abs = Simplify@ComplexExpand@Abs[wig];
 intofwig = Integrate[abs, q]

Mathematica graphics

 doubint = Integrate[intofwig, p]

Mathematica graphics

The above gets you the integral. I do not know what you are solving for what you type

delta = Solve[doubint - 1]

But I think you can take it from here since now the integrals evaluate.

May be you meant this?

delta=doubint-1
Plot3D[delta,{p,-1,1},{q,-1,1},AxesLabel->{"p","q"},
     PlotLabel->"my nice plot in 3D",BaseStyle->14]

Mathematica graphics

V 13.3 on windows.

$\endgroup$
4
  • $\begingroup$ Thanks a lot! It works. $\endgroup$
    – Anaya
    Aug 16, 2023 at 11:13
  • $\begingroup$ Yeah I am getting a bit different plot. Perhaps the reason is I am using the PlotRange-> All command. I am actually computing the negative region in the wigner function $\endgroup$
    – Anaya
    Aug 16, 2023 at 11:21
  • $\begingroup$ @Anaya Adding PlotRange->All does not change the plot for me. Screen shot !Mathematica graphics I am using V 13.3 May be you can post screen shot of the what you did showing the plot, starting from clean kernel. $\endgroup$
    – Nasser
    Aug 16, 2023 at 11:23
  • $\begingroup$ My bad! I was actually using different values for 'q' and 'p'. Using your values, I got the same plot. $\endgroup$
    – Anaya
    Aug 16, 2023 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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