Lecture 21.  Print out some spherical harmonic functions and their integrals, to look at the conditions for  ∫ cos(θ) (Subscript[Y, lm])(θ, ϕ) dΩ = 0.  Also evaluate the <100|z|210> and <100|z^2|100> brakets.

$Assumptions = l ∈ Integers && m ∈Integers  && a0 > 0;
Row[{Integrate[ Cos[t]Sin[t] SphericalHarmonicY[#1,#2,t,p], {t, 0, Pi}, {p, 0, 2 Pi}] // HoldForm // TraditionalForm,
" = ",
Integrate[ Cos[t]Sin[t] SphericalHarmonicY[#1,#2,t,p], {t, 0, Pi}, {p, 0, 2 Pi}]
}] & @@@ {{0,0},{1,0}, {1,1}, {1,-1}, {2,0}, {2,1}, {2,2}, {2,-1}, {2,-2}}

Row[{ 
SphericalHarmonicY[#1,#2,θ, ϕ] // HoldForm // TraditionalForm,
" = ",
SphericalHarmonicY[#1,#2,θ,ϕ]
}] & @@@ {{1,0}, {2,0}, {3,0},{1,1}, {2,1}, {2,2}, {3,1}, {3,2}, {3,3}} // TraditionalForm

Row[{ SphericalHarmonicY[#,0,θ, ϕ] // HoldForm // TraditionalForm,
" = ",
SphericalHarmonicY[#,0,θ, ϕ] // TraditionalForm
}] & /@(Range[8] -1)

(*Integrate[ Exp[ I phi ], {phi, 0, 2 Pi}]*)

Row[{HoldForm[Integrate[ Sin[t] Cos[t] Cos[t]^#, {t, 0, Pi}]] // TraditionalForm, 
" = ",
Integrate[ Sin[t] Cos[t] Cos[t]^#,{t, 0, Pi}]}] & /@ Range[10]

Row[{HoldForm[Integrate[ Sin[θ] Cos[θ] SphericalHarmonicY[#,0,θ,ϕ], {θ, 0, Pi}, {ϕ, 0, 2 Pi}]] // TraditionalForm, 
" = ",
Integrate[ Sin[t] Cos[t] SphericalHarmonicY[#,0,t, p],{t, 0, Pi}, {p, 0, 2 Pi}] 
}] & /@ (Range[10]-1)

ClearAll[braOpKet, unit]
(* wave function definition from: 
http://mathematica.stackexchange.com/a/88150/10
*)
ψ[{n_,l_,m_},{r_,θ_,ϕ_}]:=With[{ρ=2 r/(n a0)},Sqrt[(2/(n a0))^3 (n-l-1)!/(2 n (n+l)!)] Exp[-ρ/2] ρ^l LaguerreL[n-l-1,2 l+1,ρ] SphericalHarmonicY[l,m,θ,ϕ]]


braOpKet[f_, A_, g_] := Integrate[ Conjugate[f[r, theta, phi]] A[r, theta, phi] g[r, theta, phi] r^2 Sin[theta], {r,0, Infinity}, {theta, 0, Pi}, {phi, 0, 2 Pi}]

(*(ψ[{1,0,0},{#1, #2, #3} ]&)[r, theta, phi]*)
unit = 1 &;
braOpKet[ ψ[{1,0,0},{#1, #2, #3} ]&, unit, ψ[{1,0,0},{#1, #2, #3}] &] 
braOpKet[ ψ[{2,1,0},{#1, #2, #3} ]&, unit, ψ[{2,1,0},{#1, #2, #3}] &]
braOpKet[ ψ[{1,0,0},{#1, #2, #3} ]&, #1 Cos[#2] &, ψ[{2,1,0},{#1, #2, #3}] &] /. a0 -> 1 // N
braOpKet[ ψ[{1,0,0},{#1, #2, #3} ]&, (#1 Cos[#2])^2 &, ψ[{1,0,0},{#1, #2, #3}] &] 
(*unit[r,theta, phi]*)

((128 (Sqrt[2]) )/243)// N