# Plotting a function $\psi(\rho,\theta,\phi)$ in spherical coordinates

If I want to plot the function

$$\qquad \psi(\rho,\theta,\phi)=\frac{1}{8}\left(\frac{1}{\pi}\right)^{1/2}\rho e^{-\rho/2}sin(\theta)e^{-i\phi}$$,

for which I wrote the code

ψ[ρ_, θ_, ϕ_] := (E^(-(ρ/2) - i ϕ)  ρ Sin[θ])/(8 Sqrt[π])


How would I go about making a plot? I'm thinking that I could convert these spherical coordinates to cartesian coordinates using a built-in function, but I haven't been able to get that to work.

• Try SphericalPlot3D – J42161217 Oct 15 '18 at 21:56
• I only get graphic results using SphericalPlot3D only if I remove "i" (which by the way is "I" in Mathematica) ρ = 1; SphericalPlot3D[(E^(-(ρ/2) - [Phi]) ρ Sin[θ])/(8 Sqrt[Pi]), {θ, 0, 2 Pi}, {[Phi], 0, 2 Pi}] – J42161217 Oct 15 '18 at 22:17
• (1) The function is a scalar field and SphericalPlot3D won't plot a field. (2) It's a complex field, and only real fields can be plotted, so you have to choose Re, Im, Abs, and/or Arg. (3) ContourPlot3D is one way to plot scalar fields. See also TransformedField for converting from spherical to cartesian for ContourPlot3D. – Michael E2 Oct 16 '18 at 2:12
• i in your function definition should be I. – m_goldberg Oct 16 '18 at 5:12

You likely need to take the modulus-squared of the wave function first:

ψ[ρ_, θ_, ϕ_] := (E^(-(ρ/2) - I ϕ) ρ Sin[θ])/(8 Sqrt[π]);
Abs[ψ[ρ, θ, ϕ]]^2 // ComplexExpand
(* (E^-ρ ρ^2 Sin[θ]^2)/(64 π) *)


Then plot a slice of the function radially:

Plot[Abs[ψ[ρ, π/2, 0]]^2 // ComplexExpand, {ρ, 0, 10}] Then plot the angular part at fixed radius (which is typically done for hydrogen-like wave functions like this):

SphericalPlot3D[Abs[ψ[1, θ, ϕ]]^2 // ComplexExpand, {θ, 0, π}, {ϕ, 0, 2 π}] As you have it right now, the function itself cannot be plotted for a variable radius. That being said, you can just specify it. Also, the expression is complex, and thus will not output anything when plotted. So we can take the real and imaginary parts, and plot those.

SphericalPlot3D[
{Re, Im}[
ComplexExpand[
(Exp[-(\[Rho]/2) - I \[Phi]] \[Rho] Sin[\[Theta]])/(8 Sqrt[\[Pi]]) /. \[Rho] -> 1,
TargetFunctions -> {Re, Im}
]
] // Through // Simplify[#, {\[Theta], \[Phi]} \[Element] Reals] & // Evaluate,
\[Theta], \[Phi],
PlotStyle -> {{Opacity[.4], Red (*Real*)}, {Opacity[.4], Blue (*Imaginary*)}},
PlotPoints -> 100
] We can make the surfaces a little translucent and see that the real and imaginary parts overlap a little bit near the origin.