+
    
þÎj[  ã                   óŠ  € R t ^ RIHt ^ RIHt ^ RIHt ^ RI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 ^ RIHtHt ^ RIHt ^ RIH t H!t!H"t"H#t# ^ RI$H%t% . R&Ot& ! R R]4      t' ! R R]'4      t( ! R R]4      t) ! R R]4      t*R t+R t,R t-R t.R t/R t0R'R  lt1R! t2R" t3R# t4R$ t5R% t6R# )(zClebsch-Gordon Coefficients.)ÚSum)ÚAdd)ÚExpr)Úexpand)ÚMul)ÚPow)ÚEq)ÚS)ÚWildÚsymbols)Úsympify)Úsqrt)Ú	Piecewise)Ú
prettyFormÚ
stringPict)ÚKroneckerDelta)Úclebsch_gordanÚ	wigner_3jÚ	wigner_6jÚ	wigner_9j)Ú
PRECEDENCEÚCGÚWigner3jÚWigner6jÚWigner9jc                   ó°   a € ] tR t^&t o RtRtR t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R	 4       t]R
 4       tR tR tR tRtV tR# )r   a8  Class for the Wigner-3j symbols.

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

Wigner 3j-symbols are coefficients determined by the coupling of
two angular momenta. When created, they are expressed as symbolic
quantities that, for numerical parameters, can be evaluated using the
``.doit()`` method [1]_.

Parameters
==========

j1, m1, j2, m2, j3, m3 : Number, Symbol
    Terms determining the angular momentum of coupled angular momentum
    systems.

Examples
========

Declare a Wigner-3j coefficient and calculate its value

    >>> from sympy.physics.quantum.cg import Wigner3j
    >>> w3j = Wigner3j(6,0,4,0,2,0)
    >>> w3j
    Wigner3j(6, 0, 4, 0, 2, 0)
    >>> w3j.doit()
    sqrt(715)/143

See Also
========

CG: Clebsch-Gordan coefficients

References
==========

.. [1] Varshalovich, D A, Quantum Theory of Angular Momentum. 1988.
Tc           	     óX   € \        \        WW4WV34      p\        P                  ! V .VO5!  # ©N©Úmapr   r   Ú__new__)ÚclsÚj1Úm1Új2Úm2Új3Úm3Úargss   &&&&&&& ÚN/opt/data/home/.local/lib/python3.14/site-packages/sympy/physics/quantum/cg.pyr    ÚWigner3j.__new__Q   s)   € Ü”7˜R R¨RÐ4Ó5ˆÜ�|Š|˜CÐ' $Ó'Ð'ó    c                ó(   € V P                   ^ ,          # ©é    ©r(   ©Úselfs   &r)   r"   ÚWigner3j.j1U   ó   € à�y‰y˜�|Ðr+   c                ó(   € V P                   ^,          # ©é   r/   r0   s   &r)   r#   ÚWigner3j.m1Y   r3   r+   c                ó(   € V P                   ^,          # ©é   r/   r0   s   &r)   r$   ÚWigner3j.j2]   r3   r+   c                ó(   € V P                   ^,          # ©é   r/   r0   s   &r)   r%   ÚWigner3j.m2a   r3   r+   c                ó(   € V P                   ^,          # ©é   r/   r0   s   &r)   r&   ÚWigner3j.j3e   r3   r+   c                ó(   € V P                   ^,          # ©é   r/   r0   s   &r)   r'   ÚWigner3j.m3i   r3   r+   c                ó°   € \         ;QJ d0    R  V P                   4       F  '       d   K   R'       * # 	  R'       * # ! R  V P                   4       4      '       * # )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   ©Ú	is_number©Ú.0Úargs   & r)   Ú	<genexpr>Ú'Wigner3j.is_symbolic.<locals>.<genexpr>o   ó   é € Ð:±	¨—}–}³	ùó   ‚FT©Úallr(   r0   s   &r)   Úis_symbolicÚWigner3j.is_symbolicm   ó<   € ç“3Ñ:°·	²	Ó:—3”3Ô:Ð:’3Ô:Ð:�3Ñ:°·	²	Ó:Ó:Ô:Ð:r+   c                ó^  aa€ VP                  V P                  4      VP                  V P                  4      3VP                  V P                  4      VP                  V P                  4      3VP                  V P
                  4      VP                  V P                  4      33o^p^pR.^,          p\        ^4       F%  o\        VV3R l\        ^4       4       4      VS&   K'  	  Rp\        ^4       EF  pRp\        ^4       F¿  oSS,          V,          p	VS,          V	P                  4       ,
          p
V
^,          pW«,
          p\        V	P                  RV,          4      !  p	\        V	P                  RV,          4      !  p	Vf   T	pKˆ  \        VP                  RV,          4      !  p\        VP                  V	4      !  pKÁ  	  Vf   TpKÜ  \        V4       F  p\        VP                  R4      !  pK  	  \        VP                  V4      !  pEK!  	  \        VP                  4       !  pV# )r:   c              3   ó`   <"  € T F#  pSS,          V,          P                  4       x € K%  	  R # 5ir   ©Úwidth©rM   ÚiÚjÚms   & €€r)   rO   Ú#Wigner3j._pretty.<locals>.<genexpr>z   ó!   øé € Ð<±8¨a˜!˜A�$˜q�'Ÿ-™-Ÿ/˜/³8ùó   ƒ+.NÚ éÿÿÿÿ)Ú_printr"   r#   r$   r%   r&   r'   ÚrangeÚmaxr[   r   ÚrightÚleftÚbelowÚparens©r1   Úprinterr(   ÚhsepÚvsepÚmaxwÚDr]   ÚD_rowÚsÚwdeltaÚwleftÚwrightÚ_r^   r_   s   &&*           @@r)   Ú_prettyÚWigner3j._prettyr   sÁ  ù€ Ø�n‰n˜TŸW™WÓ% w§~¡~°d·g±gÓ'>Ð?Ø�^‰^˜DŸG™GÓ$ g§n¡n°T·W±WÓ&=Ð>Ø�^‰^˜DŸG™GÓ$ g§n¡n°T·W±WÓ&=Ð>ð@ˆð ˆØˆØˆt�A�vˆÜ�q–ˆAÜÕ<´5¸´8Ó<Ó<ˆD�‹Gñ àˆÜ�q—ˆAØˆEÜ˜1–X�Ø�a•D˜•G�Ø˜a� 1§7¡7£9Õ,�Ø �
�Ø��ä §¡¨¨F­
Ó 3Ñ4�Ü §¡ s¨5¥yÓ 1Ñ2�à’=Ø�EÙÜ" E§K¡K°°DµÓ$9Ñ:�Ü" E§K¡K°£NÑ3’ñ ð ŠyØ�ÙÜ˜4–[�Ü §¡¨£Ñ-’ñ !ä˜AŸG™G E›NÑ+‹Añ+ ô, ˜Ÿ™›
Ñ#ˆØˆr+   c           	     óÖ   € \        VP                  V P                  V P                  V P                  V P
                  V P                  V P                  34      pR \        V4      ,          # )zH\left(\begin{array}{ccc} %s & %s & %s \\ %s & %s & %s \end{array}\right))	r   re   r"   r$   r&   r#   r%   r'   Útuple©r1   rm   r(   Úlabels   &&* r)   Ú_latexÚWigner3j._latex•   sP   € Ü�G—N‘N T§W¡W¨d¯g©g°t·w±wØ—G‘G˜TŸW™W d§g¡gð%/ó 0ˆàZÜ�%‹Lõð 	r+   c                óÔ   € V P                   '       d   \        R 4      h\        V P                  V P                  V P
                  V P                  V P                  V P                  4      # ©zCoefficients must be numerical)	rU   Ú
ValueErrorr   r"   r$   r&   r#   r%   r'   ©r1   Úhintss   &,r)   ÚdoitÚWigner3j.doit›   sG   € Ø××ÐÜÐ=Ó>Ð>Ü˜Ÿ™ $§'¡'¨4¯7©7°D·G±G¸T¿W¹WÀdÇgÁgÓNÐNr+   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úis_commutativer    Úpropertyr"   r#   r$   r%   r&   r'   rU   rx   r~   r…   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r)   r   r   &   sº   ø‡ € ñ&ðP €Nò(ð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñ;ó ð;ò!òF÷Oð Or+   c                   óV   a € ] tR t^¡t o Rt]R,          ^,
          tR tR tR t	Rt
V tR# )r   a_  Class for Clebsch-Gordan coefficient.

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

Clebsch-Gordan coefficients describe the angular momentum coupling between
two systems. The coefficients give the expansion of a coupled total angular
momentum state and an uncoupled tensor product state. The Clebsch-Gordan
coefficients are defined as [1]_:

.. math ::
    C^{j_3,m_3}_{j_1,m_1,j_2,m_2} = \left\langle j_1,m_1;j_2,m_2 | j_3,m_3\right\rangle

Parameters
==========

j1, m1, j2, m2 : Number, Symbol
    Angular momenta of states 1 and 2.

j3, m3: Number, Symbol
    Total angular momentum of the coupled system.

Examples
========

Define a Clebsch-Gordan coefficient and evaluate its value

    >>> from sympy.physics.quantum.cg import CG
    >>> from sympy import S
    >>> cg = CG(S(3)/2, S(3)/2, S(1)/2, -S(1)/2, 1, 1)
    >>> cg
    CG(3/2, 3/2, 1/2, -1/2, 1, 1)
    >>> cg.doit()
    sqrt(3)/2
    >>> CG(j1=S(1)/2, m1=-S(1)/2, j2=S(1)/2, m2=+S(1)/2, j3=1, m3=0).doit()
    sqrt(2)/2


Compare [2]_.

See Also
========

Wigner3j: Wigner-3j symbols

References
==========

.. [1] Varshalovich, D A, Quantum Theory of Angular Momentum. 1988.
.. [2] `Clebsch-Gordan Coefficients, Spherical Harmonics, and d Functions
    <https://pdg.lbl.gov/2020/reviews/rpp2020-rev-clebsch-gordan-coefs.pdf>`_
    in P.A. Zyla *et al.* (Particle Data Group), Prog. Theor. Exp. Phys.
    2020, 083C01 (2020).
r   c                óÔ   € V P                   '       d   \        R 4      h\        V P                  V P                  V P
                  V P                  V P                  V P                  4      # r�   )	rU   r‚   r   r"   r$   r&   r#   r%   r'   rƒ   s   &,r)   r…   ÚCG.doitÚ   sG   € Ø××ÐÜÐ=Ó>Ð>Ü˜dŸg™g t§w¡w°·±¸¿¹À$Ç'Á'È4Ï7É7ÓSÐSr+   c                ó4  € VP                  V P                  V P                  V P                  V P                  3R R7      pVP                  V P
                  V P                  3R R7      p\        VP                  4       VP                  4       4      p\        VP                  R4      !  p\        VP                  R4      !  pWSP                  4       8X  g4   \        VP                  RWSP                  4       ,
          ,          4      !  pWTP                  4       8X  g4   \        VP                  RWTP                  4       ,
          ,          4      !  p\        RRV,          ,           4      p\        VP                  V4      !  p\        VP                  V4      !  pV# )Ú,)Ú	delimiterrc   ÚC)Ú
_print_seqr"   r#   r$   r%   r&   r'   rg   r[   r   ri   rh   r   rj   Úabove)r1   rm   r(   ÚbotÚtopÚpadrs   s   &&*    r)   rx   Ú
CG._prettyß   s)  € Ø× Ñ Ø�W‰W�d—g‘g˜tŸw™w¨¯©Ð0¸Cð !ó Aˆà× Ñ  $§'¡'¨4¯7©7Ð!3¸sÐ ÓCˆä�#—)‘)“+˜sŸy™y›{Ó+ˆÜ˜#Ÿ(™( 3›-Ñ(ˆÜ˜#Ÿ(™( 3›-Ñ(ˆà—i‘i“kÔ!Ü˜cŸi™i¨¨S·9±9³;Õ->Õ(?Ó@ÑAˆCØ—i‘i“kÔ!Ü˜cŸi™i¨¨S·9±9³;Õ->Õ(?Ó@ÑAˆCÜ�s˜S �W•}Ó%ˆÜ˜Ÿ™ ›Ñ%ˆÜ˜Ÿ™ ›Ñ%ˆØˆr+   c           	     óÖ   € \        VP                  V P                  V P                  V P                  V P
                  V P                  V P                  34      pR \        V4      ,          # )zC^{%s,%s}_{%s,%s,%s,%s})	r   re   r&   r'   r"   r#   r$   r%   r{   r|   s   &&* r)   r~   Ú	CG._latexñ   sK   € Ü�G—N‘N T§W¡W¨d¯g©g°t·w±wØ—G‘G˜TŸW™W d§g¡gð%/ó 0ˆà)¬E°%«LÕ8Ð8r+   r‡   N)rˆ   r‰   rŠ   r‹   rŒ   r   Ú
precedencer…   rx   r~   r�   r�   r‘   s   @r)   r   r   ¡   s1   ø‡ € ñ5ðl ˜EÕ" QÕ&€JòTò
÷$9ð 9r+   c                   ó¬   a € ] tR t^÷t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R	 4       tR
 tR tR tRtV tR# )r   zQClass for the Wigner-6j symbols

See Also
========

Wigner3j: Wigner-3j symbols

c           	     óX   € \        \        WW4WV34      p\        P                  ! V .VO5!  # r   r   )r!   r"   r$   Új12r&   r^   Új23r(   s   &&&&&&& r)   r    ÚWigner6j.__new__   s)   € Ü”7˜R S¨aÐ5Ó6ˆÜ�|Š|˜CÐ' $Ó'Ð'r+   c                ó(   € V P                   ^ ,          # r-   r/   r0   s   &r)   r"   ÚWigner6j.j1  r3   r+   c                ó(   € V P                   ^,          # r5   r/   r0   s   &r)   r$   ÚWigner6j.j2  r3   r+   c                ó(   € V P                   ^,          # r9   r/   r0   s   &r)   r¥   ÚWigner6j.j12  r3   r+   c                ó(   € V P                   ^,          # r=   r/   r0   s   &r)   r&   ÚWigner6j.j3  r3   r+   c                ó(   € V P                   ^,          # rA   r/   r0   s   &r)   r^   Ú
Wigner6j.j  r3   r+   c                ó(   € V P                   ^,          # rE   r/   r0   s   &r)   r¦   ÚWigner6j.j23  r3   r+   c                ó°   € \         ;QJ d0    R  V P                   4       F  '       d   K   R'       * # 	  R'       * # ! R  V P                   4       4      '       * # )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   rJ   rL   s   & r)   rO   Ú'Wigner6j.is_symbolic.<locals>.<genexpr>  rQ   rR   FTrS   r0   s   &r)   rU   ÚWigner6j.is_symbolic  rW   r+   c                ód  aa€ VP                  V P                  4      VP                  V P                  4      3VP                  V P                  4      VP                  V P                  4      3VP                  V P
                  4      VP                  V P                  4      33o^p^pR.^,          p\        ^4       F%  o\        VV3R l\        ^4       4       4      VS&   K'  	  Rp\        ^4       EF  pRp\        ^4       F¿  oSS,          V,          p	VS,          V	P                  4       ,
          p
V
^,          pW«,
          p\        V	P                  RV,          4      !  p	\        V	P                  RV,          4      !  p	Vf   T	pKˆ  \        VP                  RV,          4      !  p\        VP                  V	4      !  pKÁ  	  Vf   TpKÜ  \        V4       F  p\        VP                  R4      !  pK  	  \        VP                  V4      !  pEK!  	  \        VP                  RRR7      !  pV# )r:   c              3   ó`   <"  € T F#  pSS,          V,          P                  4       x € K%  	  R # 5ir   rZ   r\   s   & €€r)   rO   Ú#Wigner6j._pretty.<locals>.<genexpr>)  ra   rb   Nrc   Ú{Ú}©ri   rh   rd   )re   r"   r&   r$   r^   r¥   r¦   rf   rg   r[   r   rh   ri   rj   rk   rl   s   &&*           @@r)   rx   ÚWigner6j._pretty!  sÈ  ù€ Ø�n‰n˜TŸW™WÓ% w§~¡~°d·g±gÓ'>Ð?Ø�^‰^˜DŸG™GÓ$ g§n¡n°T·V±VÓ&<Ð=Ø�^‰^˜DŸH™HÓ% w§~¡~°d·h±hÓ'?Ð@ðBˆð ˆØˆØˆt�A�vˆÜ�q–ˆAÜÕ<´5¸´8Ó<Ó<ˆD�‹Gñ àˆÜ�q—ˆAØˆEÜ˜1–X�Ø�a•D˜•G�Ø˜a� 1§7¡7£9Õ,�Ø �
�Ø��ä §¡¨¨F­
Ó 3Ñ4�Ü §¡ s¨5¥yÓ 1Ñ2�à’=Ø�EÙÜ" E§K¡K°°DµÓ$9Ñ:�Ü" E§K¡K°£NÑ3’ñ ð ŠyØ�ÙÜ˜4–[�Ü §¡¨£Ñ-’ñ !ä˜AŸG™G E›NÑ+‹Añ+ ô, ˜Ÿ™ c°˜Ó5Ñ6ˆØˆr+   c           	     óÖ   € \        VP                  V P                  V P                  V P                  V P
                  V P                  V P                  34      pR \        V4      ,          # )zJ\left\{\begin{array}{ccc} %s & %s & %s \\ %s & %s & %s \end{array}\right\})	r   re   r"   r$   r¥   r&   r^   r¦   r{   r|   s   &&* r)   r~   ÚWigner6j._latexD  sP   € Ü�G—N‘N T§W¡W¨d¯g©g°t·x±xØ—G‘G˜TŸV™V T§X¡Xð%/ó 0ˆà\Ü�%‹Lõð 	r+   c                óÔ   € V P                   '       d   \        R 4      h\        V P                  V P                  V P
                  V P                  V P                  V P                  4      # r�   )	rU   r‚   r   r"   r$   r¥   r&   r^   r¦   rƒ   s   &,r)   r…   ÚWigner6j.doitJ  sG   € Ø××ÐÜÐ=Ó>Ð>Ü˜Ÿ™ $§'¡'¨4¯8©8°T·W±W¸d¿f¹fÀdÇhÁhÓOÐOr+   r‡   N)rˆ   r‰   rŠ   r‹   rŒ   r    rŽ   r"   r$   r¥   r&   r^   r¦   rU   rx   r~   r…   r�   r�   r‘   s   @r)   r   r   ÷   s²   ø‡ € ñò(ð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñ;ó ð;ò!òF÷Pð Pr+   c                   óÜ   a € ] tR tRt o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R	 4       t]R
 4       t]R 4       t]R 4       t]R 4       tR tR tR tRtV tR# )r   iP  zQClass for the Wigner-9j symbols

See Also
========

Wigner3j: Wigner-3j symbols

c
                ó\   € \        \        WW4WVWxV	3	4      p
\        P                  ! V .V
O5!  # r   r   )r!   r"   r$   r¥   r&   Új4Új34Új13Új24r^   r(   s   &&&&&&&&&& r)   r    ÚWigner9j.__new__Y  s-   € Ü”7˜R S¨b°sÀÐCÓDˆÜ�|Š|˜CÐ' $Ó'Ð'r+   c                ó(   € V P                   ^ ,          # r-   r/   r0   s   &r)   r"   ÚWigner9j.j1]  r3   r+   c                ó(   € V P                   ^,          # r5   r/   r0   s   &r)   r$   ÚWigner9j.j2a  r3   r+   c                ó(   € V P                   ^,          # r9   r/   r0   s   &r)   r¥   ÚWigner9j.j12e  r3   r+   c                ó(   € V P                   ^,          # r=   r/   r0   s   &r)   r&   ÚWigner9j.j3i  r3   r+   c                ó(   € V P                   ^,          # rA   r/   r0   s   &r)   rÅ   ÚWigner9j.j4m  r3   r+   c                ó(   € V P                   ^,          # rE   r/   r0   s   &r)   rÆ   ÚWigner9j.j34q  r3   r+   c                ó(   € V P                   ^,          # )é   r/   r0   s   &r)   rÇ   ÚWigner9j.j13u  r3   r+   c                ó(   € V P                   ^,          # )é   r/   r0   s   &r)   rÈ   ÚWigner9j.j24y  r3   r+   c                ó(   € V P                   ^,          # )é   r/   r0   s   &r)   r^   Ú
Wigner9j.j}  r3   r+   c                ó°   € \         ;QJ d0    R  V P                   4       F  '       d   K   R'       * # 	  R'       * # ! R  V P                   4       4      '       * # )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   rJ   rL   s   & r)   rO   Ú'Wigner9j.is_symbolic.<locals>.<genexpr>ƒ  rQ   rR   FTrS   r0   s   &r)   rU   ÚWigner9j.is_symbolic�  rW   r+   c                ó   aa€ VP                  V P                  4      VP                  V P                  4      VP                  V P                  4      3VP                  V P                  4      VP                  V P
                  4      VP                  V P                  4      3VP                  V P                  4      VP                  V P                  4      VP                  V P                  4      33o^p^pR.^,          p\        ^4       F%  o\        VV3R l\        ^4       4       4      VS&   K'  	  Rp\        ^4       EF  pRp\        ^4       F¿  oSS,          V,          p	VS,          V	P                  4       ,
          p
V
^,          pW«,
          p\        V	P                  RV,          4      !  p	\        V	P                  RV,          4      !  p	Vf   T	pKˆ  \        VP                  RV,          4      !  p\        VP                  V	4      !  pKÁ  	  Vf   TpKÜ  \        V4       F  p\        VP!                  R4      !  pK  	  \        VP!                  V4      !  pEK!  	  \        VP#                  RRR7      !  pV# )r:   c              3   ó`   <"  € T F#  pSS,          V,          P                  4       x € K%  	  R # 5ir   rZ   r\   s   & €€r)   rO   Ú#Wigner9j._pretty.<locals>.<genexpr>‘  ra   rb   Nrc   r»   r¼   r½   rd   )re   r"   r&   rÇ   r$   rÅ   rÈ   r¥   rÆ   r^   rf   rg   r[   r   rh   ri   rj   rk   rl   s   &&*           @@r)   rx   ÚWigner9j._pretty†  s  ù€ à�^‰^Ø—‘óØ!Ÿ.™.¨¯©Ó1°7·>±>À$Ç(Á(Ó3KðMà�^‰^Ø—‘óØ!Ÿ.™.¨¯©Ó1°7·>±>À$Ç(Á(Ó3KðMà�^‰^˜DŸH™HÓ% w§~¡~°d·h±hÓ'?ÀÇÁÐPT×PVÑPVÓAWÐXðZˆð ˆØˆØˆt�A�vˆÜ�q–ˆAÜÕ<´5¸´8Ó<Ó<ˆD�‹Gñ àˆÜ�q—ˆAØˆEÜ˜1–X�Ø�a•D˜•G�Ø˜a� 1§7¡7£9Õ,�Ø �
�Ø��ä §¡¨¨F­
Ó 3Ñ4�Ü §¡ s¨5¥yÓ 1Ñ2�à’=Ø�EÙÜ" E§K¡K°°DµÓ$9Ñ:�Ü" E§K¡K°£NÑ3’ñ ð ŠyØ�ÙÜ˜4–[�Ü §¡¨£Ñ-’ñ !ä˜AŸG™G E›NÑ+‹Añ+ ô, ˜Ÿ™ c°˜Ó5Ñ6ˆØˆr+   c                ó  € \        VP                  V P                  V P                  V P                  V P
                  V P                  V P                  V P                  V P                  V P                  3	4      pR \        V4      ,          # )zZ\left\{\begin{array}{ccc} %s & %s & %s \\ %s & %s & %s \\ %s & %s & %s \end{array}\right\})r   re   r"   r$   r¥   r&   rÅ   rÆ   rÇ   rÈ   r^   r{   r|   s   &&* r)   r~   ÚWigner9j._latex¬  sc   € Ü�G—N‘N T§W¡W¨d¯g©g°t·x±xÀÇÁØ—‘˜Ÿ™ 4§8¡8¨T¯X©X°t·v±vð%?ó @ˆàlÜ�%‹Lõð 	r+   c                ó  € V P                   '       d   \        R 4      h\        V P                  V P                  V P
                  V P                  V P                  V P                  V P                  V P                  V P                  4	      # r�   )rU   r‚   r   r"   r$   r¥   r&   rÅ   rÆ   rÇ   rÈ   r^   rƒ   s   &,r)   r…   ÚWigner9j.doit²  sb   € Ø××ÐÜÐ=Ó>Ð>Ü˜Ÿ™ $§'¡'¨4¯8©8°T·W±W¸d¿g¹gÀtÇxÁxÐQU×QYÑQYÐ[_×[cÑ[cÐei×ekÑekÓlÐlr+   r‡   N)rˆ   r‰   rŠ   r‹   rŒ   r    rŽ   r"   r$   r¥   r&   rÅ   rÆ   rÇ   rÈ   r^   rU   rx   r~   r…   r�   r�   r‘   s   @r)   r   r   P  sî   ø‡ € ñò(ð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñ;ó ð;ò$òL÷mð mr+   c                ó–  € \        V \        4      '       d   \        V 4      # \        V \        4      '       d   \	        V 4      # \        V \
        4      '       d-   \        V P                   Uu. uF  p\        V4      NK  	  up!  # \        V \        4      '       d*   \        \        V P                  4      V P                  4      # V # u upi )ao  Simplify and combine CG coefficients.

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

This function uses various symmetry and properties of sums and
products of Clebsch-Gordan coefficients to simplify statements
involving these terms [1]_.

Examples
========

Simplify the sum over CG(a,alpha,0,0,a,alpha) for all alpha to
2*a+1

    >>> from sympy.physics.quantum.cg import CG, cg_simp
    >>> a = CG(1,1,0,0,1,1)
    >>> b = CG(1,0,0,0,1,0)
    >>> c = CG(1,-1,0,0,1,-1)
    >>> cg_simp(a+b+c)
    3

See Also
========

CG: Clebsh-Gordan coefficients

References
==========

.. [1] Varshalovich, D A, Quantum Theory of Angular Momentum. 1988.
)Ú
isinstancer   Ú_cg_simp_addr   Ú_cg_simp_sumr   r(   Úcg_simpr   ÚbaseÚexp)ÚerN   s   & r)   rï   rï   ¸  s’   € ôB �!”S×ÒÜ˜A‹ÐÜ	�A”s×	Ò	Ü˜A‹ÐÜ	�A”s×	Ò	Ü¨Q¯VªVÓ4©V c”W˜S–\©VÑ4Ñ5Ð5Ü	�A”s×	Ò	Ü”7˜1Ÿ6™6“? A§E¡EÓ*Ð*àˆùò	 5s   Á,Cc                óL  € . p. p\        V 4      p V P                   EF  pVP                  \        4      '       då   \	        V\
        4      '       d   VP                  \        V4      4       KQ  \	        V\        4      '       d‰   ^pVP                   F5  p\	        V\
        4      '       d   V\        V4      ,          pK-  WE,          pK7  	  VP                  \        4      '       d   VP                  V4       KÜ  VP                  V4       Kï  VP                  V4       EK  VP                  V4       EK  	  \        V4      w  rVP                  V4       \        V4      w  rVP                  V4       \        V4      w  rVP                  V4       \        V!  \        V!  ,           # )a‚  Takes a sum of terms involving Clebsch-Gordan coefficients and
simplifies the terms.

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

First, we create two lists, cg_part, which is all the terms involving CG
coefficients, and other_part, which is all other terms. The cg_part list
is then passed to the simplification methods, which return the new cg_part
and any additional terms that are added to other_part
)r   r(   Úhasr   rì   r   Úappendrî   r   Ú_check_varsh_871_1Ú_check_varsh_871_2Ú_check_varsh_872_9r   )rò   Úcg_partÚ
other_partrN   ÚtermsÚtermÚothers   &      r)   rí   rí   å  s<  € ð €GØ€Jäˆq‹	€AØ�v�vˆØ�7‰7”2�;Š;Ü˜#œs×#Ò#Ø×!Ñ!¤,¨sÓ"3Ö4Ü˜C¤×%Ò%Ø�ØŸHœH�DÜ! $¬×,Ò,Ø¤¨dÓ!3Õ3šà�šñ	 %ð
 —9‘9œR—=’=Ø—N‘N 5Ö)à×%Ñ% eÖ,à—‘˜s×#à×Ñ˜c×"ñ% ô( (¨Ó0�N€GØ×Ñ�eÔÜ'¨Ó0�N€GØ×Ñ�eÔÜ'¨Ó0�N€GØ×Ñ�eÔÜ�‰=œ3 
Ñ+Õ+Ð+r+   c                 ó  € \        \        R4      w  rr4V\        WV^ W4      ,          p^V,          ^,           \        V^ 4      ,          pV\	        V4      ,          p^V,          ^,           pW,           p	\        WVWtWW#V3W3W‰4	      # )Úa)rÿ   ÚalphaÚbÚlt)r   r
   r   r   ÚabsÚ_check_cg_simp)
Ú	term_listrÿ   r   r  r  ÚexprÚsimpÚsignÚ
build_exprÚ
index_exprs
   &         r)   rö   rö     s   € äœ$Ð 9Ó:�O€AˆaØŒb�˜1˜a Ó*Õ*€DØˆa�C�!�G”^ A qÓ)Õ)€DØŒc�"‹g�:€DØ�1•�q•€JØ•€JÜ˜$ d°	¸uÈÐ;LÈqÈfÐV`ÓmÐmr+   c                 óJ  € \        \        R4      w  rr4V\        WW) V^ 4      ,          p\        ^V,          ^,           4      \	        V^ 4      ,          pRW,
          ,          V,          \        V4      ,          p^V,          ^,           pW,           p	\        WVWtWW#V3W3W‰4	      # )rÿ   )rÿ   r   Úcr  rd   )r   r
   r   r   r   r  r  )
r  rÿ   r   r  r  r  r  r  r	  r
  s
   &         r)   r÷   r÷     s’   € äœ$Ð 9Ó:�O€AˆaØŒb�˜1˜f a¨Ó+Õ+€DÜ��!•�a•‹=œ¨¨1Ó-Õ-€DØ�!•)Õ˜RÕ¤ B£Õ'€DØ�1•�q•€JØ•€JÜ˜$ d°	¸uÈÐ;LÈqÈfÐV`ÓmÐmr+   c                 ó€  € \        \        R4      w	  rr4rVrxp	V	\        WWEWx4      ^,          ,          p
\        P                  pV	\        V	4      ,          p\        W,
          4      p\        W%,           4      pW,           ^,           \        WÝV8„  3^ \        WÞ4      3WîV8„  34      ,
          pW,           V,
          p\        W«WÉWW$WWW‰3WWE3VV4	      w  p p\        W,
          4      pW,           pV^,           V,
          WÞ,           ^,           ,          pW},
          W×,           ,          V,           V,           p\        W«WÉWW$WWW‰3WWE3VV4	      w  p p\        WWEWx4      \        WWFWx4      ,          p
\        W#4      \        WV4      ,          p\        P                  p\        W,
          4      p\        W%,           4      pW,           ^,           \        WÝV8„  3^ \        WÞ4      3WîV8„  34      ,
          pW,           V,
          p\        W«V\        P                  WW#WEWgV3WW4WV3VV4	      w  p p\        W,
          4      pW,           pV^,           V,
          WÞ,           ^,           ,          pW},
          W×,           ,          V,           V,           p\        W«V\        P                  WW#WEWgV3WW4WV3VV4	      w  p pV VV,           V,           3# )rÿ   )	rÿ   r   Úalphapr  ÚbetaÚbetapr  Úgammar  )
r   r
   r   r	   ÚOner  r   r   r  r   )r  rÿ   r   r  r  r  r  r  r  r  r  r  r  ÚxÚyr	  r
  Úother1Úother2Úother3Úother4s   &                    r)   rø   rø   )  sÔ  € ä58¼ð @Jó 6KÑ2€Aˆf˜ a°ð
 Œb�˜1 AÓ-¨qÕ0Õ0€DÜ�5‰5€DØŒc�"‹g�:€DÜˆA�E‹
€AÜˆE�LÓ€AØ•˜•œY¨¨q©5 z°A´r¸!³x°=À1È!ÁeÀ*ÓMÕM€JØ•˜•€JÜ& t°4¸YÈEÐVZÐ_dÐHiÐlmÐvwÐk~ð  AKð  MWó  XÑ€Iˆvô 	ˆA�E‹
€AØ	�€AØ�a•%˜!•)˜a�e a�iÕ(€JØ•%˜!�%• 1Õ$ uÕ,€JÜ& t°4¸YÈEÐVZÐ_dÐHiÐlmÐvwÐk~ð  AKð  MWó  XÑ€Iˆvô
 ˆa˜ Ó*¬2¨a¸À1Ó+LÕL€DÜ˜%Ó(¬¸Ó)DÕD€DÜ�5‰5€DÜˆA�E‹
€AÜˆE�LÓ€AØ•˜•œY¨¨q©5 z°A´r¸!³x°=À1È!ÁeÀ*ÓMÕM€JØ•˜•€JÜ& t°4¼¿¹À	ÈuÐ^_ÐglÐqvÐKwÐz{ð  EKð  PTð  z\ð  ^hð  jtó  uÑ€Iˆvô 	ˆA�E‹
€AØ	�€AØ�a•%˜!•)˜a�e a�iÕ(€JØ•%˜!�%• 1Õ$ uÕ,€JÜ& t°4¼¿¹À	ÈuÐ^_ÐglÐqvÐKwÐz{ð  EKð  PTð  z\ð  ^hð  jtó  uÑ€Iˆvà�f˜v•o¨Õ.Ð.Ð.r+   c	           
     óh  € ^ p	^ p
V
\        V4      8  Ed   \        WJ,          V \        V4      4      pVf   V
^,          p
K<  VP                  V4      P                  '       g   V
^,          p
Kh  V Uu. uF  qÌW¼,          3NK  	  ppR.VP                  V4      ,          p\	        V
\        V4      4       EF  p\        WO,          V P                  V4      \        V4      \        V4      ,
          VP                  V4      VP                  V4      3R7      pVf   Kg  VP                  V4      P                  V4      P                  '       g   K™  WðP                  V^4      P                  V4      P                  V4      VP                  V4      VP                  V4      P                  V4      3WèP                  V4      P                  V4      &   EK  	  \
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       Eg   \        V Uu. uF  p\        V^,          4      NK  	  up!  pV Uu. uF  pV^ ,          NK  	  ppVP                  4        VP                  4        V Uu. uF  qôP                  V4      NK  	   pV FW  p\        V^,          4      V8”  g   K  VP                  V^,          VV^,          ,          ,
          V^,          ,          4       KY  	  V	VW!,          P                  V4      ,          ,          p	EK  V
^,          p
EK  WI3# u upi u upi u upi u upi )aL  Checks for simplifications that can be made, returning a tuple of the
simplified list of terms and any terms generated by simplification.

Parameters
==========

expr: expression
    The expression with Wild terms that will be matched to the terms in
    the sum

simp: expression
    The expression with Wild terms that is substituted in place of the CG
    terms in the case of simplification

sign: expression
    The expression with Wild terms denoting the sign that is on expr that
    must match

lt: expression
    The expression with Wild terms that gives the leading term of the
    matched expr

term_list: list
    A list of all of the terms is the sum to be simplified

variables: list
    A list of all the variables that appears in expr

dep_variables: list
    A list of the variables that must match for all the terms in the sum,
    i.e. the dependent variables

build_index_expr: expression
    Expression with Wild terms giving the number of elements in cg_index

index_expr: expression
    Expression with Wild terms giving the index terms have when storing
    them to cg_index

N)r  c              3   ó(   "  € T F  qR J x € K
  	  R # 5ir   r‡   )rM   r]   s   & r)   rO   Ú!_check_cg_simp.<locals>.<genexpr>’  s   é € Ð/¡h ˜•9£hùs   ‚TF)ÚlenÚ	_check_cgÚsubsrK   rf   ÚanyÚminr  ÚsortÚreverseÚpoprõ   )r  r  r  r  r  Ú	variablesÚdep_variablesÚbuild_index_exprr
  rú   r]   Úsub_1r  Úsub_depÚcg_indexr^   Úsub_2rü   Úmin_ltÚindicess   &&&&&&&&&           r)   r  r  V  sÚ  € ðR €JØ	€AØ
Œc�)‹nÕ
Ü˜)�,¨¬c°)«nÓ=ˆØŠ=Ø��FˆAÙØ×$Ñ$ UÓ+×5×5Ð5Ø��FˆAÙÙ*7Ó8©- Q�u•x“=©-ˆÐ8Ø�6Ð*×/Ñ/°Ó6Õ6ˆÜ�qœ#˜i›.×)ˆAÜ˜i�l¨D¯I©I°gÓ,>ÄÀIÃÔQTÐUbÓQcÕ@cÐko×ktÑktÐuzÓk{ð  ~B÷  ~Gñ  ~Gð  HOó  ~Pð  kQô  RˆEØŠ}ÙØ—?‘? 7Ó+×0Ñ0°Ó7×A×AÐAÙØ=>Ç	Á	È"ÈaÓ@P×@UÑ@UÐV]Ó@^×@cÑ@cÐdiÓ@jÐln×lsÑlsÐtyÓlzð  }A÷  }Fñ  }Fð  GNó  }O÷  }Tñ  }Tð  UZó  }[ð  >[ˆH—_‘_ WÓ-×2Ñ2°5Ó9Ô:ñ *÷ ‹sÑ/¡hÓ/�s�sŠsÑ/¡hÓ/×/Ó/Ü±XÓ?±X¨TœC  Q¥žL±XÑ?Ñ@ˆFÙ,4Ó5©H D˜˜QŸ˜©HˆGÐ5Ø�L‰LŒNØ�O‰OÔÙ(/Ó1© 1�m‰m˜AÖ©Ñ1Û �Ü�t˜A•w“< &Ö(Ø×$Ñ$ t¨A¥w°¸¸Q½µÕ'?ÀÀaÅÕ&HÖJñ !ð ˜& $¥)×!1Ñ!1°%Ó!8Õ8Õ8‹Jà��F‹AØÐ Ð ùò+ 9ùò @ùÚ5ùò 2s   Á1L ÈL%È9L*É1L/Nc                óî   € V P                  V4      pVf   R# VeH   \        V\        4      '       g   \        R4      hV^ ,          V^,          P	                  V4      8X  g   R# \        V4      V8X  d   V# R# )z2Checks whether a term matches the given expressionNzsign must be a tuple)Úmatchrì   r{   Ú	TypeErrorr  r  )Úcg_termr  Úlengthr  Úmatchess   &&&& r)   r  r  ¡  sk   € ð �m‰m˜DÓ!€GØ‚ÙØÒÜ˜$¤×&Ò&ÜÐ2Ó3Ð3Ø�A�w˜4 �7Ÿ.™.¨Ó1Ô1ÙÜ
ˆ7ƒ|�vÔØˆñ r+   c                 óH   € \        V 4      p \        V 4      p \        V 4      p V # r   )Ú_check_varsh_sum_871_1Ú_check_varsh_sum_871_2Ú_check_varsh_sum_872_4)rò   s   &r)   rî   rî   °  s%   € Ü˜qÓ!€AÜ˜qÓ!€AÜ˜qÓ!€AØ€Hr+   c                 ó$  € \        R 4      p\        R4      p\        R4      pV P                  \        \	        WV^ W4      W!) V34      4      pVeA   \        V4      ^8X  d1   ^V,          ^,           \        V^ 4      ,          P                  V4      # V # )rÿ   r   r  )r
   r   r.  r   r   r  r   r  )rò   rÿ   r   r  r.  s   &    r)   r4  r4  ·  s~   € ÜˆS‹	€AÜ�GÓ€EÜˆS‹	€AØ�G‰G”Cœ˜1 Q¨¨1Ó4°u¸bÀ!°nÓEÓF€EØÒœS ›Z¨1œ_Ø�1•�q•œ.¨¨AÓ.Õ.×4Ñ4°UÓ;Ð;Ø€Hr+   c                 ó`  € \        R 4      p\        R4      p\        R4      pV P                  \        RW,
          ,          \	        WW) V^ 4      ,          W!) V34      4      pVeJ   \        V4      ^8X  d:   \        ^V,          ^,           4      \        V^ 4      ,          P                  V4      # V # )rÿ   r   r  rd   )	r
   r   r.  r   r   r  r   r   r  )rò   rÿ   r   r  r.  s   &    r)   r5  r5  Á  s”   € ÜˆS‹	€AÜ�GÓ€EÜˆS‹	€AØ�G‰GÜˆR�1•9Õœb ¨1¨f°a¸Ó;Õ;¸eÀRÈ¸^ÓLóN€EàÒœS ›Z¨1œ_Ü�Q�q•S˜1•W“œn¨Q°Ó2Õ2×8Ñ8¸Ó?Ð?Ø€Hr+   c           	      óP  € \        R 4      p\        R4      p\        R4      p\        R4      p\        R4      p\        R4      p\        R4      p\        R4      p\        W1WBWW4      p	\        W1WBWh4      p
V P                  \	        Wš,          W) V3W$) V34      4      pVe;   \        V4      ^8X  d+   \        WV4      \        Wx4      ,          P                  V4      # V P                  \	        V	^,          W) V3W$) V34      4      pVe!   \        V4      ^8X  d   \        P                  # V # )r   r  rÿ   r  r  Úcpr  Úgammap)
r   r
   r   r.  r   r  r   r  r	   r  )rò   r   r  rÿ   r  r  r:  r  r;  Úcg1Úcg2Úmatch1Úmatch2s   &            r)   r6  r6  Ì  s  € Ü�GÓ€EÜ�6‹?€DÜˆS‹	€AÜˆS‹	€AÜˆS‹	€AÜ	ˆd‹€BÜ�‹M€EÜ�(‹^€FÜ
ˆQ�q Ó
)€CÜ
ˆQ�q Ó
+€CØ�W‰W”S˜� 5¨"¨a .°4¸¸Q°-Ó@ÓA€FØÒœc &›k¨QÔ.Ü˜qÓ%¤n°UÓ&CÕC×IÑIÈ&ÓQÐQØ�W‰W”S˜˜a� %¨¨Q °$¸¸A°Ó?Ó@€FØÒœc &›k¨QÔ.Ü�u‰uˆØ€Hr+   c                 óœ  € \        V \        4      '       d   V 3^^3# . p^p\        V \        \        34      '       g   \	        R4      h\        V \        4      '       d|   V P
                  P                  '       d`   V P
                  P                  '       d>   \        V P
                  4       Uu. uF  q1P                  V P                  4      NK  	   pMV 3^^3# \        V \        4      '       dY   V P                   F4  p\        V\        4      '       d   VP                  V4       K,  W$,          pK6  	  WV\        V4      ,          3# R# u upi )r6   z term must be CG, Add, Mul or PowN)rì   r   r   r   ÚNotImplementedErrorrñ   rK   rf   rõ   rð   r(   r  )rü   ÚcgÚcoeffrw   rN   s   &    r)   Ú_cg_listrD  à  sý   € Ü�$œ×ÒØˆw˜˜1ˆ}ÐØ	€BØ€EÜ�dœS¤#˜J×'Ò'Ü!Ð"DÓEÐEÜ�$œ×Ò §¡×!3×!3Ð!3Ø�8‰8××ÐÜ,1°$·(±(¬OÓ=©O q�i‰i˜Ÿ	™	Ö"©OÒ=à�7˜A˜q�=Ð Ü�$œ×ÒØ—9”9ˆCÜ˜#œr×"Ò"Ø—	‘	˜#–à•’ñ	 ð
 ˜%¤ E£
Õ*Ð*Ð*ñ ùò >s   Â-#E	)r   r   r   r   rï   r   )7rŒ   Úsympy.concrete.summationsr   Úsympy.core.addr   Úsympy.core.exprr   Úsympy.core.functionr   Úsympy.core.mulr   Úsympy.core.powerr   Úsympy.core.relationalr   Úsympy.core.singletonr	   Úsympy.core.symbolr
   r   Úsympy.core.sympifyr   Ú(sympy.functions.elementary.miscellaneousr   Ú$sympy.functions.elementary.piecewiser   Ú sympy.printing.pretty.stringpictr   r   Ú(sympy.functions.special.tensor_functionsr   Úsympy.physics.wignerr   r   r   r   Úsympy.printing.precedencer   Ú__all__r   r   r   r   rï   rí   rö   r÷   rø   r  r  rî   r4  r5  r6  rD  r‡   r+   r)   Ú<module>rV     sÉ   ðñ
 #å )Ý Ý  Ý &Ý Ý  Ý $Ý "ß -Ý &Ý 9Ý :ß Cå Cß PÓ PÝ 0ò€ôxOˆtô xOôvS9ˆô S9ôlVPˆtô VPôremˆtô emòP*òZ+,ò\nònò*/òZH!ôVòòòòô(+r+   