moble / spherical_functions

Python/numba package for evaluating Wigner D matrices and spin-weighted spherical harmonics
MIT License
52 stars 11 forks source link

Deal with overflow #5

Closed moble closed 9 years ago

moble commented 9 years ago

When |Ra| is small enough and mp-m is large enough, or when |Rb| is small enough and -mp-m is large enough, the power appearing in the prefactor can overflow, leaving us with nans. These values should cancel with other values coming from the rho_min value in the polynomial, to leave us with very small values. Thus, I should be able to deal with them properly and get finite results.

This problem appears, for example, when one of the components of the rotor is ~1e-10 and ell>15, though it will also appear at lower ell values for smaller components.

I've written a test to detect this behavior in test_WignerD_overflow.

I think that incorporating the powers of |Ra| and |Rb| into the computation of Prefactor should deal with this nicely. However, it may require decomposing them into abs and angle parts.