Skip to content

Restore the Condon-Shortley phase in spherical harmonics and fix their derivatives #33117

@egourgoulhon

Description

@egourgoulhon

As noticed in https://groups.google.com/g/sage-devel/c/2rNGCYg82rE/m/plZsnDN7EgAJ, Sage's spherical harmonics do not include the Condon-Shortley phase, which makes them differ by a factor (-1)m from Wikipedia, SymPy, SciPy and Mathematica spherical harmonics:

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)
sage: from sympy import Ynm
sage: Ynm(1, 1, theta, phi).expand(func=True) # notice the sign difference 
-sqrt(6)*exp(I*phi)*sin(theta)/(4*sqrt(pi))
sage: n(spherical_harmonic(1, 1, pi/2, pi))
-0.345494149471335
sage: from scipy.special import sph_harm  # NB: theta and phi swapped in sph_harm 
sage: sph_harm(1, 1, n(pi), n(pi/2))  # notice the sign difference with Sage's result
(0.3454941494713355-4.231083042742082e-17j)

Furthermore, the computation of derivatives of spherical harmonics is based on a formula which assumes the Condon-Shortley phase! This makes it totally buggy:

sage: l, m, theta, phi = var('l m theta phi')
sage: Ylm = spherical_harmonic(l, m, theta, phi)
sage: DYlm = diff(Ylm, theta)
sage: DYlm
m*cot(theta)*spherical_harmonic(l, m, theta, phi)
 + sqrt((l + m + 1)*(l - m))*e^(-I*phi)*spherical_harmonic(l, m + 1, theta, phi)
sage: DYlm.subs({l: 1, m: 0})
1/2*sqrt(3)*sqrt(sin(theta)^2)/sqrt(pi)
sage: diff(spherical_harmonic(1, 0, theta, phi), theta) # sign opposite to above!
-1/2*sqrt(3)*sin(theta)/sqrt(pi)

Adding the Condon-Shortley phase in the definition of spherical harmonics would make them standard, thereby avoiding many confusions (especially with Wikipedia, SymPy and SciPy) and would fix the derivative computation.

CC: @mjungmath @tscrim

Component: symbolics

Keywords: spherical harmonics

Author: Eric Gourgoulhon

Branch/Commit: dcd0f7a

Reviewer: Samuel Lelièvre, Michael Jung

Issue created by migration from https://trac.sagemath.org/ticket/33117

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions