What is the Spherical Harmonic Function Calculator?
Spherical harmonics \(Y_n^m(\theta,\phi)\) are the angular part of the solutions of Laplace's equation in spherical coordinates. They form a complete orthonormal basis on the surface of a sphere and appear throughout physics and engineering: atomic orbitals in quantum mechanics, multipole expansions in electromagnetics and gravitation, the cosmic microwave background in cosmology, geomagnetic models in geophysics, and lighting models in computer graphics. This calculator evaluates the complex-valued harmonic for a chosen degree n, order m, polar (zenith) angle \(\theta\) and azimuthal angle \(\phi\).
How to use it
Pick a convention: type A (Wolfram/Mathematica) uses the phase \(e^{i m \phi}\); type B (Maple) uses \(e^{i m (\phi+\pi)}\), which differs by \((-1)^m\). Enter an integer degree \(n \ge 0\) and an integer order m with \(-n \le m \le n\). Type the zenith angle \(\theta\) and azimuth \(\phi\) using the chosen angle unit (degrees or radians — the same unit applies to both). Choose how many significant digits to display, then read off the real and imaginary parts, plus the magnitude and phase.
The formula
Let \(x = \cos\theta\). The normalization is $$N = \sqrt{\frac{2n+1}{4\pi}\cdot\frac{(n-m)!}{(n+m)!}}.$$ The associated Legendre function \(P_n^m(x)\) is built with the recurrence starting from $$P_m^m(x) = (-1)^m (2m-1)!!\,(1-x^2)^{m/2}.$$ Then type A: $$Y = N \cdot P_n^m(x) \cdot \bigl(\cos(m\phi) + i\cdot\sin(m\phi)\bigr).$$ Negative orders use $$P_n^{-m}(x) = (-1)^m \frac{(n-m)!}{(n+m)!}\,P_n^m(x).$$ At the poles (\(x = \pm 1\)) only \(m = 0\) is nonzero.
Worked example
Defaults, type A: \(n=2\), \(m=1\), \(\theta=45^\circ\), \(\phi=0\). Then \(x = \cos 45^\circ = 0.7071068\), $$\frac{2n+1}{4\pi} = \frac{5}{4\pi} = 0.3978874,$$ $$\frac{(n-m)!}{(n+m)!} = \frac{1}{6},$$ so \(N = \sqrt{0.0663146} = 0.257516\). \(P_2^1(x) = -3x\sqrt{1-x^2} = -3\cdot 0.5 = -1.5\). With \(\phi=0\) the phase is 1, giving $$Y = 0.257516 \cdot (-1.5) = -0.386274 + 0\,i,$$ magnitude 0.386274.
FAQ
Why is the result complex? The \(e^{i m \phi}\) factor makes Y complex unless \(m\phi\) is a multiple of \(\pi\) (e.g. \(\phi=0\)), where the imaginary part vanishes.
Why does my reference book show +0.386274? Some sources omit the Condon–Shortley \((-1)^m\) phase. The Wolfram/type-A convention includes it inside \(P_n^m\), giving the negative value.
What happens at the poles? At \(\theta=0\) or \(180^\circ\) the factor \((1-x^2)^{m/2}\) is zero, so \(Y = 0\) for every \(m \ne 0\); only \(m=0\) survives.