+
    åûj
+  ã                   óà   € ^ RI Ht ^ RIHtHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHtHtHt ]! R4      t ! R R]4      tR t ! R R]4      tR# )é    )ÚExpr)ÚDefinedFunctionÚArgumentIndexError)ÚIÚpi)ÚS)ÚDummy)Úassoc_legendre)Ú	factorial)ÚAbsÚ	conjugate)Úexp)Úsqrt)ÚsinÚcosÚcotÚxc                   ól   a € ] tR t^t o Rt]R 4       tR tRR ltR t	R t
R tR tRR	 ltR
 tRtV tR# )ÚYnmaè  
Spherical harmonics defined as

.. math::
    Y_n^m(\theta, \varphi) := \sqrt{\frac{(2n+1)(n-m)!}{4\pi(n+m)!}}
                              \exp(i m \varphi)
                              \mathrm{P}_n^m\left(\cos(\theta)\right)

Explanation
===========

``Ynm()`` gives the spherical harmonic function of order $n$ and $m$
in $\theta$ and $\varphi$, $Y_n^m(\theta, \varphi)$. The four
parameters are as follows: $n \geq 0$ an integer and $m$ an integer
such that $-n \leq m \leq n$ holds. The two angles are real-valued
with $\theta \in [0, \pi]$ and $\varphi \in [0, 2\pi]$.

Examples
========

>>> from sympy import Ynm, Symbol, simplify
>>> from sympy.abc import n,m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")

>>> Ynm(n, m, theta, phi)
Ynm(n, m, theta, phi)

Several symmetries are known, for the order:

>>> Ynm(n, -m, theta, phi)
(-1)**m*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

As well as for the angles:

>>> Ynm(n, m, -theta, phi)
Ynm(n, m, theta, phi)

>>> Ynm(n, m, theta, -phi)
exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

For specific integers $n$ and $m$ we can evaluate the harmonics
to more useful expressions:

>>> simplify(Ynm(0, 0, theta, phi).expand(func=True))
1/(2*sqrt(pi))

>>> simplify(Ynm(1, -1, theta, phi).expand(func=True))
sqrt(6)*exp(-I*phi)*sin(theta)/(4*sqrt(pi))

>>> simplify(Ynm(1, 0, theta, phi).expand(func=True))
sqrt(3)*cos(theta)/(2*sqrt(pi))

>>> simplify(Ynm(1, 1, theta, phi).expand(func=True))
-sqrt(6)*exp(I*phi)*sin(theta)/(4*sqrt(pi))

>>> simplify(Ynm(2, -2, theta, phi).expand(func=True))
sqrt(30)*exp(-2*I*phi)*sin(theta)**2/(8*sqrt(pi))

>>> simplify(Ynm(2, -1, theta, phi).expand(func=True))
sqrt(30)*exp(-I*phi)*sin(2*theta)/(8*sqrt(pi))

>>> simplify(Ynm(2, 0, theta, phi).expand(func=True))
sqrt(5)*(3*cos(theta)**2 - 1)/(4*sqrt(pi))

>>> simplify(Ynm(2, 1, theta, phi).expand(func=True))
-sqrt(30)*exp(I*phi)*sin(2*theta)/(8*sqrt(pi))

>>> simplify(Ynm(2, 2, theta, phi).expand(func=True))
sqrt(30)*exp(2*I*phi)*sin(theta)**2/(8*sqrt(pi))

We can differentiate the functions with respect
to both angles:

>>> from sympy import Ynm, Symbol, diff
>>> from sympy.abc import n,m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")

>>> diff(Ynm(n, m, theta, phi), theta)
m*cot(theta)*Ynm(n, m, theta, phi) + sqrt((-m + n)*(m + n + 1))*exp(-I*phi)*Ynm(n, m + 1, theta, phi)

>>> diff(Ynm(n, m, theta, phi), phi)
I*m*Ynm(n, m, theta, phi)

Further we can compute the complex conjugation:

>>> from sympy import Ynm, Symbol, conjugate
>>> from sympy.abc import n,m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")

>>> conjugate(Ynm(n, m, theta, phi))
(-1)**(2*m)*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

To get back the well known expressions in spherical
coordinates, we use full expansion:

>>> from sympy import Ynm, Symbol, expand_func
>>> from sympy.abc import n,m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")

>>> expand_func(Ynm(n, m, theta, phi))
sqrt((2*n + 1)*factorial(-m + n)/factorial(m + n))*exp(I*m*phi)*assoc_legendre(n, m, cos(theta))/(2*sqrt(pi))

See Also
========

Ynm_c, Znm

References
==========

.. [1] https://en.wikipedia.org/wiki/Spherical_harmonics
.. [2] https://mathworld.wolfram.com/SphericalHarmonic.html
.. [3] https://functions.wolfram.com/Polynomials/SphericalHarmonicY/
.. [4] https://dlmf.nist.gov/14.30

c                óÀ  € VP                  4       '       dU   V) p\        P                  V,          \        R\        ,          V,          V,          4      ,          \        WW44      ,          # VP                  4       '       d   V) p\        WW44      # VP                  4       '       d9   V) p\        R\        ,          V,          V,          4      \        WW44      ,          # R# )é   Néþÿÿÿ)Úcould_extract_minus_signr   ÚNegativeOner   r   r   )ÚclsÚnÚmÚthetaÚphis   &&&&&ÚgC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\functions\special\spherical_harmonics.pyÚevalÚYnm.eval‰   sª   € ð ×%Ñ%×'Ò'Ø�ˆAÜ—=‘= !Õ#¤c¨"¬Q­$¨q­&°­*£oÕ5¼¸AÀ%Ó8MÕMÐMØ×)Ñ)×+Ò+Ø�FˆEÜ�q˜UÓ(Ð(Ø×'Ñ'×)Ò)Ø�$ˆCÜ�rœ!•t˜A•v˜c•z“?¤S¨¨uÓ%:Õ:Ð:ñ *ó    c                ó¾  € V P                   w  r#rE\        ^V,          ^,           ^\        ,          ,          \        W#,
          4      ,          \        W#,           4      ,          4      \	        \
        V,          V,          4      ,          \        W#\        V4      4      ,          pVP                  \        \        V4      ^,          ) ^,           4      \        V4      4      # ©r   )
Úargsr   r   r   r   r   r
   r   Úsubsr   )ÚselfÚhintsr   r   r   r   Úrvs   &,     r    Ú_eval_expand_funcÚYnm._eval_expand_func˜   s–   € ØŸ9™9ÑˆˆeÜ�A�a•C˜!•G˜a¤�dÕ#¤i°µÓ&6Õ6´yÀÅÓ7GÕGÓHÜ”A�a•C˜•G“õÜ-¨a´C¸³JÓ?õ@ˆð �w‰w”tœS ›Z¨�]˜N¨QÕ.Ó/´°U³Ó<Ð<r#   c                óö  € V^8X  d   \        W4      hV^8X  d   \        W4      hV^8X  d‘   V P                  w  r#rEV\        V4      ,          \        W#WE4      ,          \	        W#,
          W#,           ^,           ,          4      \        \        ) V,          4      ,          \        W#^,           WE4      ,          ,           # V^8X  d.   V P                  w  r#rE\        V,          \        W#WE4      ,          # \        W4      h)é   )r   r&   r   r   r   r   r   )r(   Úargindexr   r   r   r   s   &&    r    ÚfdiffÚ	Ynm.fdiffŸ   sÈ   € Ø�qŒ=ä$ TÓ4Ð4Ø˜Œ]ä$ TÓ4Ð4Ø˜Œ]à#Ÿy™yÑˆA�%Øœ˜E›
•N¤S¨¨uÓ%:Õ:Ü˜!�% !¥%¨!¥)Õ,Ó-´´Q°B°sµF³Õ;¼cÀ!ÈÅUÈEÓ>WÕWõXð Yà˜Œ]à#Ÿy™yÑˆA�%Ü�q•5œ3˜q UÓ0Õ0Ð0ä$ TÓ4Ð4r#   c                ó&   € V P                  R R7      # )T©Úfunc)Úexpand©r(   r   r   r   r   Úkwargss   &&&&&,r    Ú_eval_rewrite_as_polynomialÚYnm._eval_rewrite_as_polynomial²   s   € ð �{‰{ ˆ{Ó%Ð%r#   c                ó,   € V P                  \        4      # ©N)Úrewriter   r6   s   &&&&&,r    Ú_eval_rewrite_as_sinÚYnm._eval_rewrite_as_sin·   s   € Ø�|‰|œCÓ Ð r#   c                óº   € ^ RI HpHp V! V P                  RR7      4      pVP	                  \        \        V4      4      \        V4      /4      pV! V! V4      4      # )r   )ÚsimplifyÚtrigsimpTr3   )Úsympy.simplifyr@   rA   r5   Úxreplacer   r   )	r(   r   r   r   r   r7   r@   rA   Úterms	   &&&&&,   r    Ú_eval_rewrite_as_cosÚYnm._eval_rewrite_as_cosº   sJ   € ç5ñ ˜Ÿ™¨˜Ó.Ó/ˆà�}‰}œc¤# e£*›o¬c°%«jÐ9Ó:ˆÙ™ ›Ó'Ð'r#   c                ó~   € V P                   w  rr4\        P                  V,          V P                  W) W44      ,          # r;   )r&   r   r   r4   )r(   r   r   r   r   s   &    r    Ú_eval_conjugateÚYnm._eval_conjugateÄ   s1   € àŸ9™9ÑˆˆeÜ�}‰}˜aÕ $§)¡)¨A¨r°5Ó">Õ>Ð>r#   c                óB  € V P                   w  r4rV\        ^V,          ^,           ^\        ,          ,          \        W4,
          4      ,          \        W4,           4      ,          4      \	        WF,          4      ,          \        W4\	        V4      4      ,          p\        ^V,          ^,           ^\        ,          ,          \        W4,
          4      ,          \        W4,           4      ,          4      \        WF,          4      ,          \        W4\	        V4      4      ,          pWx3# r%   )r&   r   r   r   r   r
   r   )	r(   Údeepr)   r   r   r   r   ÚreÚims	   &&,      r    Úas_real_imagÚYnm.as_real_imagÉ   s¿   € àŸ9™9ÑˆˆeÜ�A�a•C˜!•G˜a¤�dÕ#¤i°µÓ&6Õ6´yÀÅÓ7GÕGÓHÜ�!•%‹jõÜ)¨!´°E³
Ó;õ<ˆä�A�a•C˜!•G˜a¤�dÕ#¤i°µÓ&6Õ6´yÀÅÓ7GÕGÓHÜ�!•%‹jõÜ)¨!´°E³
Ó;õ<ˆàˆxˆr#   c                óÌ  € ^ RI HpHp V P                  ^ ,          P	                  V4      pV P                  ^,          P	                  V4      pV P                  ^,          P	                  V4      pV P                  ^,          P	                  V4      pV! V4      ;_uu_ 4        VP                  WEWg4      pRRR4       \        P                  ! XV4      #   + '       g   i     L'; i)r   )ÚmpÚworkprecN)ÚmpmathrQ   rR   r&   Ú
_to_mpmathÚ	spherharmr   Ú_from_mpmath)	r(   ÚprecrQ   rR   r   r   r   r   Úress	   &&       r    Ú_eval_evalfÚYnm._eval_evalfÒ   s    € ÷ 	(Ø�I‰I�a�L×#Ñ# DÓ)ˆØ�I‰I�a�L×#Ñ# DÓ)ˆØ—	‘	˜!•×'Ñ'¨Ó-ˆØ�i‰i˜�l×%Ñ% dÓ+ˆÙ�d�^�^Ø—,‘,˜q UÓ0ˆC÷ ä× Ò   dÓ+Ð+÷ �^ús   Â!CÃC#	© N)é   )T)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úclassmethodr!   r+   r0   r8   r=   rE   rH   rN   rY   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r    r   r      sM   ø‡ € ñwðr ñ
;ó ð
;ò=ô5ò&&ò
!ò(ò?ô
÷,ð ,r#   r   c                ó,   € \        \        WW#4      4      # )aÀ  
Conjugate spherical harmonics defined as

.. math::
    \overline{Y_n^m(\theta, \varphi)} := (-1)^m Y_n^{-m}(\theta, \varphi).

Examples
========

>>> from sympy import Ynm_c, Symbol, simplify
>>> from sympy.abc import n,m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")
>>> Ynm_c(n, m, theta, phi)
(-1)**(2*m)*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)
>>> Ynm_c(n, m, -theta, phi)
(-1)**(2*m)*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

For specific integers $n$ and $m$ we can evaluate the harmonics
to more useful expressions:

>>> simplify(Ynm_c(0, 0, theta, phi).expand(func=True))
1/(2*sqrt(pi))
>>> simplify(Ynm_c(1, -1, theta, phi).expand(func=True))
sqrt(6)*exp(I*(-phi + 2*conjugate(phi)))*sin(theta)/(4*sqrt(pi))

See Also
========

Ynm, Znm

References
==========

.. [1] https://en.wikipedia.org/wiki/Spherical_harmonics
.. [2] https://mathworld.wolfram.com/SphericalHarmonic.html
.. [3] https://functions.wolfram.com/Polynomials/SphericalHarmonicY/

)r   r   )r   r   r   r   s   &&&&r    ÚYnm_crh   à   s   € ôP ”S˜˜uÓ*Ó+Ð+r#   c                   ó4   a € ] tR tRt o Rt]R 4       tRtV tR# )ÚZnmi  a×  
Real spherical harmonics defined as

.. math::

    Z_n^m(\theta, \varphi) :=
    \begin{cases}
      \frac{Y_n^m(\theta, \varphi) + \overline{Y_n^m(\theta, \varphi)}}{\sqrt{2}} &\quad m > 0 \\
      Y_n^m(\theta, \varphi) &\quad m = 0 \\
      \frac{Y_n^m(\theta, \varphi) - \overline{Y_n^m(\theta, \varphi)}}{i \sqrt{2}} &\quad m < 0 \\
    \end{cases}

which gives in simplified form

.. math::

    Z_n^m(\theta, \varphi) =
    \begin{cases}
      \frac{Y_n^m(\theta, \varphi) + (-1)^m Y_n^{-m}(\theta, \varphi)}{\sqrt{2}} &\quad m > 0 \\
      Y_n^m(\theta, \varphi) &\quad m = 0 \\
      \frac{Y_n^m(\theta, \varphi) - (-1)^m Y_n^{-m}(\theta, \varphi)}{i \sqrt{2}} &\quad m < 0 \\
    \end{cases}

Examples
========

>>> from sympy import Znm, Symbol, simplify
>>> from sympy.abc import n, m
>>> theta = Symbol("theta")
>>> phi = Symbol("phi")
>>> Znm(n, m, theta, phi)
Znm(n, m, theta, phi)

For specific integers n and m we can evaluate the harmonics
to more useful expressions:

>>> simplify(Znm(0, 0, theta, phi).expand(func=True))
1/(2*sqrt(pi))
>>> simplify(Znm(1, 1, theta, phi).expand(func=True))
-sqrt(3)*sin(theta)*cos(phi)/(2*sqrt(pi))
>>> simplify(Znm(2, 1, theta, phi).expand(func=True))
-sqrt(15)*sin(2*theta)*cos(phi)/(4*sqrt(pi))

See Also
========

Ynm, Ynm_c

References
==========

.. [1] https://en.wikipedia.org/wiki/Spherical_harmonics
.. [2] https://mathworld.wolfram.com/SphericalHarmonic.html
.. [3] https://functions.wolfram.com/Polynomials/SphericalHarmonicY/

c                ó\  € VP                   '       d0   \        WW44      \        WW44      ,           \        ^4      ,          pV# VP                  '       d   \        WW44      # VP
                  '       d;   \        WW44      \        WW44      ,
          \        ^4      \        ,          ,          pV# R# )r   N)Úis_positiver   rh   r   Úis_zeroÚis_negativer   )r   r   r   r   r   Úzzs   &&&&& r    r!   ÚZnm.evalE  s   € à�=�=ˆ=Ü�a˜EÓ'¬%°°eÓ*AÕAÄTÈ!ÃWÕLˆBØˆIØ�Y�YˆYÜ�q˜UÓ(Ð(Ø�]�]ˆ]Ü�a˜EÓ'¬%°°eÓ*AÕAÄdÈ1ÃgÌaÅiÕPˆBØˆIñ r#   r[   N)	r]   r^   r_   r`   ra   rb   r!   rc   rd   re   s   @r    rj   rj     s   ø‡ € ñ7ðr ñó ör#   rj   N)Úsympy.core.exprr   Úsympy.core.functionr   r   Úsympy.core.numbersr   r   Úsympy.core.singletonr   Úsympy.core.symbolr	   Úsympy.functionsr
   Ú(sympy.functions.combinatorial.factorialsr   Ú$sympy.functions.elementary.complexesr   r   Ú&sympy.functions.elementary.exponentialr   Ú(sympy.functions.elementary.miscellaneousr   Ú(sympy.functions.elementary.trigonometricr   r   r   Ú_xr   rh   rj   r[   r#   r    Ú<module>r}      sU   ðÝ  ß Cß $Ý "Ý #Ý *Ý >ß ?Ý 6Ý 9ß BÑ Bá
ˆ3ƒZ€ôN,ˆ/ô N,òb(,ôVCˆ/ö Cr#   