Are solid spherical harmonics implemented in Mathematica?
You could also do something like the following (taking advantage of TransformedField
):
solidHarmonicS[l_?IntegerQ, m_?IntegerQ, x_, y_, z_] :=
Module[{r, θ, ϕ, xx, yy, zz},
FullSimplify@
Evaluate[
TransformedField["Spherical" -> "Cartesian",
r^l SphericalHarmonicY[l, m, θ, ϕ],
{r, θ, ϕ} -> {xx, yy, zz}]] /. {xx -> x, yy -> y, zz -> z}
]
$$\begin{array}{ccc} \frac{1}{2 \sqrt{\pi }} & 0 & 0 \\ \frac{1}{2} \sqrt{\frac{3}{\pi }} z & -\frac{1}{2} \sqrt{\frac{3}{2 \pi }} (x+i y) & 0 \\ -\frac{1}{4} \sqrt{\frac{5}{\pi }} \left(x^2+y^2-2 z^2\right) & -\frac{1}{2} \sqrt{\frac{15}{2 \pi }} z (x+i y) & \frac{1}{4} \sqrt{\frac{15}{2 \pi }} (x+i y)^2 \\ \end{array}$$
Using this formula for the spherical harmonic function, and making a few simplifications, here is a direct implementation of the solid spherical harmonic function:
dpower[x_, y_] := Piecewise[{{1, y == 0}}, x^y]
SolidHarmonicS[λ_Integer?NonNegative, μ_Integer, x_, y_, z_] /; Abs[μ] <= λ :=
With[{s = Sign[μ], am = Abs[μ]},
(-1)^((1 - s) am/2) Sqrt[((2 λ + 1) (λ - am)!)/(4 π (λ + am)!)]
dpower[x + I s y, am] Sum[(-1)^((λ + am)/2 - k) (λ + am + 2 k - 1)!!
dpower[z, 2 k] dpower[x^2 + y^2 + z^2, (λ - am)/2 - k]/
((2 k)! (λ - am - 2 k)!!),
{k, Mod[λ - am, 2]/2, (λ - am)/2}]]
I chose to use the direct sum instead of using the hypergeometric representation to avoid having to do a polynomial division, which can be troublesome for zero arguments.
A test:
Table[SolidHarmonicS[λ, μ, x, y, z], {λ, 0, 2}, {μ, -λ, λ}] // Simplify
{{1/(2 Sqrt[π])},
{1/2 Sqrt[3/(2 π)] (x - I y), 1/2 Sqrt[3/π] z, -(1/2) Sqrt[3/(2 π)] (x + I y)},
{1/4 Sqrt[15/(2 π)] (x - I y)^2, 1/2 Sqrt[15/(2 π)] (x - I y) z,
-(1/4) Sqrt[5/π] (x^2 + y^2 - 2 z^2), -(1/2) Sqrt[15/(2 π)] (x + I y) z,
1/4 Sqrt[15/(2 π)] (x + I y)^2}}