0
$\begingroup$

This question already has an answer here:

I want to have a 3D plot for the following function: (1.6 - 0.005 I) E^(-0.5 p^2 + ( 2. I) p q + (6.5 - 11 q) q) p and q from -10 to 10

Is there any way?

$\endgroup$

marked as duplicate by Artes, Jens, b.gates.you.know.what, RunnyKine, Karsten 7. Oct 11 '14 at 23:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Hi, welcome to Mathematica.SE, please consider taking the tour so you learn the basic rules of the site. Here its considered helpful to share your code attempts, hopefully is a well formatted way. Do you want to plot only of the real part? Please explain further what do you expect as an output. $\endgroup$ – rhermans Oct 11 '14 at 19:57
3
$\begingroup$

Here's an interesting way to do it using complex phase-amplitude plots:

hue = Compile[{{z, _Complex}}, {(1.0 Arg[-z] + \[Pi])/(2 \[Pi]), 
    Exp[1 - Max[Abs[z], 1]], Min[Abs[z], 1]}, 
   CompilationTarget -> "C", RuntimeAttributes -> {Listable}];
ComplexPlot[f_, {x0_, x1_, \[Delta]x_}, {y0_, y1_, \[Delta]y_}] := 
  Image[hue[
     f[#[[All, All, 1]], #[[All, All, 2]]] &@
      Outer[List, Range[x0, x1, \[Delta]x], 
       Range[y0, y1, \[Delta]y]]]\[Transpose], ColorSpace -> Hue, 
   Magnification -> 1];
ComplexPlot[f_, {x0_, x1_, \[Delta]x_}, {y0_, y1_, \[Delta]y_}, 
   mag_] := 
  Image[hue[
     mag f[#[[All, All, 1]], #[[All, All, 2]]] &@
      Outer[List, Range[x0, x1, \[Delta]x], 
       Range[y1, y0, -\[Delta]y]]]\[Transpose], ColorSpace -> Hue, 
   Magnification -> 1];
CCompile[expr_] := 
  Compile[{{x, _Real}, {y, _Real}}, Evaluate[expr], 
   CompilationTarget -> "C", RuntimeAttributes -> {Listable}];

Then execute the following:

f = (1.6 - 
      0.005 I) E^(-0.5 p^2 + (2. I) p q + (6.5 - 11 q) q) /. {p -> x, 
    q -> y};
ComplexPlot[CCompile[f], {-2, 2, 0.005}, {-0.8, 1.2, 0.005}, 0.3]

which produces the following plot:

enter image description here

$\endgroup$
2
$\begingroup$

Since the function is complex valued, you have to find its real and imaginary and plot these. This type of question has been asked before many times, so I am sure this is duplicate.

Clear[p, q]
f = (1.6 - 0.005 I) E^(-0.5 p^2 + (2. I) p q + (6.5 - 11 q) q)
p1 = Plot3D[Re@f, {p, -2, 2}, {q, -2, 2}, PlotRange -> All]
p2 = Plot3D[Im@f, {p, -2, 2}, {q, -2, 2}, PlotRange -> All]

Mathematica graphics

$\endgroup$
2
$\begingroup$

Expanding on @Nasser's answer

f = (1.6 - 0.005 I) E^(-0.5 p^2 + (2. I) p q + (6.5 - 11 q) q);

Partition[
  Plot3D[#[f],
     {p, -2, 2}, {q, -2, 2},
     PlotRange -> All,
     PlotPoints -> 51,
     AxesLabel -> (Style[#, 14, Bold] & /@
        {p, 
         q, #["f"]})] & /@
   {Re, Im, Abs, Arg}, 2] // Grid

enter image description here

$\endgroup$

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