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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI 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?
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:
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]
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