[sage-devel] Re: spherical harmonics still broken in 9.5.beta8

2022-01-04 Thread Eric Gourgoulhon
Hi,

Le mercredi 5 janvier 2022 à 00:36:11 UTC+1, Jonathan Thornburg a écrit :

> Sage has long had problems with spherical harmonics, e.g., this thread 
> from June 2019: 
> https://groups.google.com/g/sage-support/c/I_d_meMxRbM/m/Esxo5UO2BAAJ 
>
> As of 9.5.beta8, spherical harmonics are (still) broken for some 
> arguments, 
> with the test case noted in that earlier thread still giving the same 
> (wrong) result: 
> 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 correct result would be 
> -1/4*sqrt(6)*e^(I*phi)*sin(theta)/sqrt(pi) 
> (see, e.g., https://en.wikipedia.org/wiki/Table_of_spherical_harmonics). 
>
>  
Actually, the difference between the two results is essentially due to a 
different convention in the Condon-Shortley phase
(cf. 
https://en.wikipedia.org/wiki/Spherical_harmonics#Condon%E2%80%93Shortley_phase),
which makes Sage's spherical harmonics Y_l^m differ from Wikipedia and 
Mathematica ones by a factor (-1)^m.
The other difference in the above example is a lack of simplification of 
sqrt(sin(theta)^2). 

I would vote for including the Condon-Shortley phase in Sage's spherical 
harmonics, since this is standard in quantum mechanics and this would make 
Sage agree with Wikipedia and Mathematica. 

Eric.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/b7f40005-d3f0-4289-a51d-7b7c216c85fen%40googlegroups.com.


[sage-devel] spherical harmonics still broken in 9.5.beta8

2022-01-04 Thread Jonathan Thornburg
Sage has long had problems with spherical harmonics, e.g., this thread
from June 2019:
https://groups.google.com/g/sage-support/c/I_d_meMxRbM/m/Esxo5UO2BAAJ

As of 9.5.beta8, spherical harmonics are (still) broken for some arguments,
with the test case noted in that earlier thread still giving the same
(wrong) result:
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 correct result would be
-1/4*sqrt(6)*e^(I*phi)*sin(theta)/sqrt(pi)
(see, e.g., https://en.wikipedia.org/wiki/Table_of_spherical_harmonics).

In that earlier thread, Eric Gourgoulhon noted that the problem was related
to
https://trac.sagemath.org/ticket/25034
Unfortunately, even though that ticket is now marked "closed defect (fixed)",
spherical harmonics are still broken.

Eric suggested a workaround, using the spin-weighted spherical harmonics
from the /kerrgeodesics_gw/ package, which for spin 0 should reduce to
the standard spherical harmonics.

This works if ell and emm are specific integers, but it can't handle the
case where they are generic variables.  E.g., this works with Sage's
native spherical harmonics
sage: ell,emm = var('ell,emm')
sage: theta,phi = var('theta,phi')
sage: diff(spherical_harmonic(ell,emm, theta,phi), theta)
but the analogous
sage: from kerrgeodesic_gw import spin_weighted_spherical_harmonic
sage: diff(spin_weighted_spherical_harmonic(0, ell,emm, theta,phi), theta)
fails.

--
-- "Jonathan Thornburg [remove color- to reply]" 
   on the west coast of Canada, eh?
   "There was of course no way of knowing whether you were being watched
at any given moment.  How often, or on what system, the Thought Police
plugged in on any individual wire was guesswork.  It was even conceivable
that they watched everybody all the time."  -- George Orwell, "1984"

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/YdTZEHWuPGRnsh9c%40gold.bkis-orchard.net.