Unfortunately, the current implementation of spherical harmonics in Sage
suffers from various issues. One is the sign convention, which is different
from the standard one, as you pointed out. Another issue is getting false
results for some parameters, like
sage: theta, phi = var('theta phi')
sage: spherical_harmonic(1, 1, theta, phi)
-1/4*sqrt(3)*sqrt(2)*sqrt(-sin(theta)^2)*e^(I*phi)/sqrt(pi)
The term sqrt(-sin(theta)^2) in the above expression is plain false. It
should be sin(theta).
This issue is related to the bug reported in
https://trac.sagemath.org/ticket/25034
As a workaround, I would recommend to use the function
spin_weighted_spherical_harmonic with the spin weight set to zero instead
of spherical_harmonic. The function spin_weighted_spherical_harmonic is not
part of the main SageMath, but of the SageMath package kerrgeodesics_gw
<https://pypi.org/project/kerrgeodesic-gw/>. So you have to install the
later via
sage -pip install kerrgeodesic_gw
NB: on CoCalc, you have to add the option --user:
sage -pip install --user kerrgeodesic_gw
Then, you will get (the first argument, i.e. 0, is the spin weight; if
zero, one gets the standard spherical harmonics):
sage: from kerrgeodesic_gw import spin_weighted_spherical_harmonic
sage: spin_weighted_spherical_harmonic(0, 2, 1, theta, phi)
-1/4*sqrt(15)*sqrt(2)*cos(theta)*e^(I*phi)*sin(theta)/sqrt(pi)
sage: spin_weighted_spherical_harmonic(0, 1, 1, theta, phi)
-1/4*sqrt(6)*e^(I*phi)*sin(theta)/sqrt(pi)
Both results agree with the standard values, as given e.g. in
https://en.wikipedia.org/wiki/Table_of_spherical_harmonics
Eric.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/633d5f7d-dbb1-441d-9688-cd12a7ac7720%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.