MultipoleMoment - crowlogic/arb4j GitHub Wiki
Spherical-Harmonic Multipole Moments
Firstly, spherical harmonics are a solution to the angular part of Laplace's equation in spherical coordinates. They are often represented as:
$$Y_l^m(\theta, \phi) = \sqrt{\frac{2l+1}{4\pi} \cdot \frac{(l-m)!}{(l+m)!}} \cdot P_l^m(\cos(\theta)) \cdot e^{im\phi}$$
where $P_l^m$ is an associated Legendre polynomial, $\theta$ and $\phi$ are the polar and azimuthal angles respectively, $l$ is the degree, and $m$ is the order of the harmonic.
Multipole expansion, like in electrostatics, can be represented as:
$$V(r, \theta, \phi) = \sum_{l=0}^{\infty} \sum_{m=-l}^{l} \frac{4\pi}{2l+1} \cdot \left(\frac{r}{|r|}\right)^{l+1} \cdot Q_l^m \cdot Y_l^m(\theta, \phi)$$
where $V$ is the potential, $r$ is the position vector, and $Q_l^m$ are the multipole moments. The multipole moments can be calculated from the source distribution.
For instance, in electrostatics, if $\rho(r')$ is the charge distribution, $Q_l^m$ can be calculated as:
$$Q_l^m = \int \rho(r') \cdot r'^l \cdot Y_l^m(\theta', \phi') , d^3r'$$
In gravitation, $\rho$ would be replaced with the mass distribution.
Each term in the expansion (monopole, dipole, quadrupole, etc.) corresponds to a different $l$ value. For instance, the monopole term ($l=0$) gives the total charge or mass, the dipole term ($l=1$) gives the first moment or center of mass, the quadrupole term ($l=2$) gives information about the spread or shape of the distribution, and so on.
These are high-level equations. In practical situations, the actual calculations can get very complex depending on the specifics of the problem at hand.