ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 15 Jun 2020 15:26:01 +0200Spherical Harmonicshttps://ask.sagemath.org/question/51994/spherical-harmonics/Hello,
I was wondering the difference between Sage's spherical_harmonic (as well as Maxima's spherical_harmonic) and Mathematica's SphericalHarmonicY for the same arguments.
Sage's
print(spherical_harmonic(1,1,pi/3,pi/6).n())
print(spherical_harmonic(1,-1,pi/3,pi/6).n())
gives the following result:
0.149603355150537 - 0.259120612103502*I
-0.259120612103502 + 0.149603355150537*I
Maxima's
print(maxima.spherical_harmonic(1,1,pi/3,pi/6).n())
print(maxima.spherical_harmonic(1,-1,pi/3,pi/6).n())
gives
0.259120612103502 + 0.149603355150537*I
-0.259120612103502 + 0.149603355150537*I
and Mathematica,
SphericalHarmonicY[1, 1, Pi/3, Pi/6] // N
SphericalHarmonicY[1, -1, Pi/3, Pi/6] // N
gives
-0.259121 - 0.149603*I
0.259121 - 0.149603*I
I have come across the convention difference between Maxima and Mathematica in some textbooks-- that is the (-1)^m factor, but I am not quite sure if I get it for between Sage's and Mathematica's.
So, **what is the mathematical relationship between Sage's spherical_harmonic and Mathematica's SphericalHarmonicY in terms of l and m?**
Thanks alot.Mon, 15 Jun 2020 00:04:06 +0200https://ask.sagemath.org/question/51994/spherical-harmonics/Answer by eric_g for <p>Hello,</p>
<p>I was wondering the difference between Sage's spherical_harmonic (as well as Maxima's spherical_harmonic) and Mathematica's SphericalHarmonicY for the same arguments. </p>
<p>Sage's</p>
<pre><code>print(spherical_harmonic(1,1,pi/3,pi/6).n())
print(spherical_harmonic(1,-1,pi/3,pi/6).n())
</code></pre>
<p>gives the following result:</p>
<pre><code>0.149603355150537 - 0.259120612103502*I
-0.259120612103502 + 0.149603355150537*I
</code></pre>
<p>Maxima's </p>
<pre><code>print(maxima.spherical_harmonic(1,1,pi/3,pi/6).n())
print(maxima.spherical_harmonic(1,-1,pi/3,pi/6).n())
</code></pre>
<p>gives </p>
<pre><code>0.259120612103502 + 0.149603355150537*I
-0.259120612103502 + 0.149603355150537*I
</code></pre>
<p>and Mathematica,</p>
<pre><code>SphericalHarmonicY[1, 1, Pi/3, Pi/6] // N
SphericalHarmonicY[1, -1, Pi/3, Pi/6] // N
</code></pre>
<p>gives</p>
<pre><code>-0.259121 - 0.149603*I
0.259121 - 0.149603*I
</code></pre>
<p>I have come across the convention difference between Maxima and Mathematica in some textbooks-- that is the (-1)^m factor, but I am not quite sure if I get it for between Sage's and Mathematica's.</p>
<p>So, <strong>what is the mathematical relationship between Sage's spherical_harmonic and Mathematica's SphericalHarmonicY in terms of l and m?</strong></p>
<p>Thanks alot.</p>
https://ask.sagemath.org/question/51994/spherical-harmonics/?answer=52009#post-id-52009Unfortunately, spherical harmonics in Sage have various issues, which are tracked in the ticket [#25034](https://trac.sagemath.org/ticket/25034). See this [thread](https://groups.google.com/d/msg/sage-support/I_d_meMxRbM/spKcXIj-AQAJ) for a possible workaround.Mon, 15 Jun 2020 11:47:57 +0200https://ask.sagemath.org/question/51994/spherical-harmonics/?answer=52009#post-id-52009Comment by curios_mind for <p>Unfortunately, spherical harmonics in Sage have various issues, which are tracked in the ticket <a href="https://trac.sagemath.org/ticket/25034">#25034</a>. See this <a href="https://groups.google.com/d/msg/sage-support/I_d_meMxRbM/spKcXIj-AQAJ">thread</a> for a possible workaround.</p>
https://ask.sagemath.org/question/51994/spherical-harmonics/?comment=52013#post-id-52013Wow.. this problem was reported 2 years ago with "major" priority. I am suprised that it has been resolved yet. At the moment, my work around is to use Maxima's spherical_harmonic with ".sage()" at the end; converting it to sage.
Thanks for the warning, though. I was digging all the math books to figure out if there were a different convention to represent spherical_harmonics that mathces sage's.Mon, 15 Jun 2020 15:26:01 +0200https://ask.sagemath.org/question/51994/spherical-harmonics/?comment=52013#post-id-52013