# How to plot a function $\psi(r,\theta,\phi=0)$ in polar coordinates?

I have a function $\psi(r,\theta,\phi=\phi_0)$ with $\phi_0\in \Re$, $r\in[0,R]$ with $R\in \Re$, and $\theta \in [0,\pi]$ (spherical polar coordinates) and I want to plot it in Mathematica. I guess the proper way to do that is in polar coordinates, but how do I do that?

The function is:

$$\psi(r,\theta,\phi=0)=r^2e^{-r}\cos \theta$$

• Have you tried searching the docs? Lookup PolarPlot... – rm -rf Oct 25 '13 at 15:40
• How about ParametricPlot3D[{r Cos[θ], r Sin[θ], r^2 Exp[-r] Cos[θ]}, {r,0,4}, {θ,0,π}]. – Chip Hurst Oct 25 '13 at 16:29
• @rm-rf Yeah, but PolarPlot needs $r$ as function of $\theta$. – Ana S. H. Oct 25 '13 at 16:38
• What coordinate is supposed to represent $\psi$? – Michael E2 Oct 25 '13 at 19:46
• @MichaelE2 Actually $\psi$ is a wave function for the Hydrogen Atom. – Ana S. H. Oct 27 '13 at 3:21

## 2 Answers

First find the condition for $\phi=0$ in cartesian coordinates.

Last@CoordinateTransform["Cartesian" -> "Spherical", {x, y, z}];
Solve[% == 0, y]


{{y -> 0}}

Convert the expression to cartesian coordinates, apply the condition, and plot.

TransformedField["Spherical" -> "Cartesian",
r^2 Exp[-r] Cos[θ], {r, θ, ϕ} -> {x, y, z}] /. %;

Plot3D[%, {x, -5, 5}, {z, -5, 5}, AxesLabel -> {x, z, ψ}] Hope this is what you were looking for.

• First you set y -> 0, which I agree with. But I do have a criticism/question: Next in Plot3D you plot the transformed expression (let expr = %) as if it were the graph of y == expr. Why y == expr if y is 0? – Michael E2 Oct 26 '13 at 1:06
• Michael E2, Hopefully this fig en.wikipedia.org/wiki/File:3D_Spherical.svg will clear things. $\phi==0$ corresponds to $y==0$. $expr$ is a function of $x$ and $z$, and its values are plotted along the $y$ axis. – Suba Thomas Oct 27 '13 at 0:12
• I know all that. That means the $y$ on the $y$ axis is not the same $y$ that is zero when $\phi=0$. That's confusing to me. I think $\psi$ ought to be treated as an intensity (as in DensityPlot) or as you have done (but not labeled $y$). – Michael E2 Oct 27 '13 at 0:26
• I think you are taking issue with just the label? My thought flow is that there is one $y$ axis, the abscissae lie on $y==0$ and the ordinate can take values along the $y$ axis; and I also labeled it $y$. Now, I have changed it to $\psi$. – Suba Thomas Oct 27 '13 at 0:56
• Yes, I had read it that the $y$'s were the same. With relabeling the confusion disappears. I don't think the OP's question is sufficiently clear yet, but this is a reasonable interpretation. +1. – Michael E2 Oct 27 '13 at 1:09

You could visualize with ColorFunction, e.g.:

f[x_, y_, z_] := Exp[-{x, y, z}.{x, y, z}] {x, y, z}.{x, y, z} z
min = NMinimize[f[x, 0, z], {x, z}][];
max = NMaximize[f[x, 0, z], {x, z}][];
cf = Function[{x, y, z},
ColorData["Rainbow"][Rescale[f[x, 0, z], {min, max}]]];
Legended[ParametricPlot3D[{r Sin[t], 0, r Cos[t]}, {r, 0, 5}, {t, 0,
2 Pi}, ColorFunction -> cf, ColorFunctionScaling -> False,
Mesh -> False, PlotPoints -> 50],
BarLegend[{"Rainbow", {min, max}}]] 