Hydrogen Atom Probability Density

To use this Mathematica notebook you have to execute the commands in the cell below. The cell is defined by the closest square bracket on the right. Click anywhere in the cell and then hit the Enter key (NOT the Return key). If you don’t see an Enter key on your keyboard (laptops often leave this out), then try shift-Return. Once you have done that you can change the values used to calculate the probability density by clicking on the buttons on the interface. It may take a few seconds to update the display so be patient.

(* Define the pieces of the hydrogen wave functions. *)
Rnl[n_,l_,r_]:=(r^l)*Exp[-r/2]*LaguerreL[n-l-1,2*l+1,r];Ylm[l_,m_,theta_,phi_]:=SphericalHarmonicY[l,m,theta,phi];
(* Now do the interface with the actual calculation. *)
Manipulate[If[l≥n,l=n-1];
If[m>l,m=l];
DensityPlot[Module[{r=Norm[{x,0,z}]},
(* factor 0f 4((πr)^2) in included to make scaling the plots easier. *)4 π r^2 (Rnl[n,l,r])^2 Re[Ylm[l,m,ArcCos[z/r],ArcTan[x,0]]*Conjugate[Ylm[l,m,ArcCos[z/r],ArcTan[x,0]]]]
 ](* end of Module *),
{x,-side,side},{z,-side,side},Mesh->False,Frame->False,PlotPoints->Round[resolution],ColorFunctionScaling->True,ColorFunction->"SunsetColors",PlotRange->{0,10^scale}],{{n,8,"principal quantum number"},1,8,1,ControlType->Setter},{{l,3,"angular momentum"},Range[0,n-1],ControlType->SetterBar},{{m,1,"magnetic quantum number"},Range[0,l],ControlType->SetterBar},{{side,40,"Length of a side"},1,200,ControlType->Slider[Dynamic[side]]},{{scale,16,"Vertical Scale"},1,30,ControlType->Slider[Dynamic[scale]]},
{{resolution,40,"Resolution"},30,100,ControlType->Slider[Dynamic[scale]]}
]