+
    
þÎ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
.t ! R R
]4      t]P,                  P/                  ]]4      R 4       tR# )z"The commutator: [A,B] = A*B - B*A.)ÚAdd)ÚExpr)ÚKindDispatcher)ÚMul)ÚPow)ÚS)Ú
prettyForm)ÚDagger)Ú_OperatorKindÚOperatorKindÚ
Commutatorc                   ó’   a € ] tR t^t o RtRt]! RRR7      t]R 4       t	R t
]R 4       tR	 tR
 tR tR tR tR tR tR tRtV tR# )r   as  The standard commutator, in an unevaluated state.

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

Evaluating a commutator is defined [1]_ as: ``[A, B] = A*B - B*A``. This
class returns the commutator in an unevaluated form. To evaluate the
commutator, use the ``.doit()`` method.

Canonical ordering of a commutator is ``[A, B]`` for ``A < B``. The
arguments of the commutator are put into canonical order using ``__cmp__``.
If ``B < A``, then ``[B, A]`` is returned as ``-[A, B]``.

Parameters
==========

A : Expr
    The first argument of the commutator [A,B].
B : Expr
    The second argument of the commutator [A,B].

Examples
========

>>> from sympy.physics.quantum import Commutator, Dagger, Operator
>>> from sympy.abc import x, y
>>> A = Operator('A')
>>> B = Operator('B')
>>> C = Operator('C')

Create a commutator and use ``.doit()`` to evaluate it:

>>> comm = Commutator(A, B)
>>> comm
[A,B]
>>> comm.doit()
A*B - B*A

The commutator orders it arguments in canonical order:

>>> comm = Commutator(B, A); comm
-[A,B]

Commutative constants are factored out:

>>> Commutator(3*x*A, x*y*B)
3*x**2*y*[A,B]

Using ``.expand(commutator=True)``, the standard commutator expansion rules
can be applied:

>>> Commutator(A+B, C).expand(commutator=True)
[A,C] + [B,C]
>>> Commutator(A, B+C).expand(commutator=True)
[A,B] + [A,C]
>>> Commutator(A*B, C).expand(commutator=True)
[A,C]*B + A*[B,C]
>>> Commutator(A, B*C).expand(commutator=True)
[A,B]*C + B*[A,C]

Adjoint operations applied to the commutator are properly applied to the
arguments:

>>> Dagger(Commutator(A, B))
-[Dagger(A),Dagger(B)]

References
==========

.. [1] https://en.wikipedia.org/wiki/Commutator
FÚCommutator_kind_dispatcherT)Úcommutativec                óH   € R  V P                    4       pV P                  ! V!  # )c              3   ó8   "  € T F  qP                   x € K  	  R # 5i©N)Úkind)Ú.0Úas   & ÚV/opt/data/home/.local/lib/python3.14/site-packages/sympy/physics/quantum/commutator.pyÚ	<genexpr>Ú"Commutator.kind.<locals>.<genexpr>f   s   é € Ð/¡Y —V–V£Yùs   ‚)ÚargsÚ_kind_dispatcher)ÚselfÚ	arg_kindss   & r   r   ÚCommutator.kindd   s!   € á/ T§Y¢YÓ/ˆ	Ø×$Ò$ iÑ0Ð0ó    c                ób   € V P                  W4      pVe   V# \        P                  ! WV4      pV# r   )Úevalr   Ú__new__)ÚclsÚAÚBÚrÚobjs   &&&  r   r!   ÚCommutator.__new__i   s.   € Ø�H‰H�Q‹NˆØŠ=ØˆHÜ�lŠl˜3 1Ó%ˆØˆ
r   c           	     ó,  € V'       d	   V'       g   \         P                  # W8X  d   \         P                  # VP                  '       g   VP                  '       d   \         P                  # VP                  4       w  r4VP                  4       w  rVW5,           pV'       dC   \	        \	        V!  V ! \        P
                  ! V4      \        P
                  ! V4      4      4      # VP                  V4      ^8X  d   \         P                  V ! W!4      ,          # R# )é   N)r   ÚZeroÚis_commutativeÚargs_cncr   Ú
_from_argsÚcompareÚNegativeOne)r"   r   ÚbÚcaÚncaÚcbÚncbÚc_parts   &&&     r   r    ÚCommutator.evalp   s¸   € ç—aÜ—6‘6ˆMØŒ6Ü—6‘6ˆMØ××Ð˜q×/×/Ð/Ü—6‘6ˆMð —*‘*“,‰ˆØ—*‘*“,‰ˆØ•ˆßÜ”s˜F‘|¡S¬¯ª¸Ó)<¼c¿nºnÈSÓ>QÓ%RÓSÐSð �9‰9�Q‹<˜1ÔÜ—=‘=¡ Q£Õ*Ð*ñ r   c                ó  € VP                   pVP                  '       d'   VP                  4       '       d   \        V4      ^8:  d   V # VP                  pVP
                  '       d   VP                  R,          pV) p\        WR4      P                  RR7      pWT^,
          ,          V,          p\        ^V4       F4  pWuV^,
          V,
          ,          V,          WX,          ,          ,          pK6  	  W7P                  4       ,          # )r)   T)Ú
commutatoréÿÿÿÿ)	ÚexpÚ
is_integerÚis_constantÚabsÚbaseÚis_negativer   ÚexpandÚrange)	r   r#   r$   Úsignr:   r>   ÚcommÚresultÚis	   &&&&     r   Ú_expand_powÚCommutator._expand_pow…   s½   € Ø�e‰eˆØ�~�~ˆ~ S§_¡_×%6Ò%6¼#¸c»(Àa¼-àˆKØ�v‰vˆØ�?�?ˆ?Ø—6‘6˜2•:ˆDØ�$ˆCÜ˜$Ó"×)Ñ)°TÐ)Ó:ˆà˜a�• 4Õ'ˆÜ�q˜#–ˆAØ˜S 1�W q�[Õ)¨DÕ0°4µ7Õ:Õ:ŠFñ à—M‘M“OÕ#Ð#r   c                óê  € V P                   ^ ,          pV P                   ^,          p\        V\        4      '       da   . pVP                    FE  p\        WS4      p\        V\        4      '       d   VP	                  4       pVP                  V4       KG  	  \        V!  # \        V\        4      '       da   . pVP                    FE  p\        W%4      p\        V\        4      '       d   VP	                  4       pVP                  V4       KG  	  \        V!  # \        V\        4      '       d³   VP                   ^ ,          p\        VP                   R,          !  pTp	\        W‰4      p
\        Wy4      p\        V
\        4      '       d   V
P	                  4       p
\        V\        4      '       d   VP	                  4       p\        Wz4      p\        W¸4      p\        WÍ4      # \        V\        4      '       d³   TpVP                   ^ ,          p\        VP                   R,          !  p	\        Wx4      p
\        Wy4      p\        V
\        4      '       d   V
P	                  4       p
\        V\        4      '       d   VP	                  4       p\        W©4      p\        W‹4      p\        WÍ4      # \        V\        4      '       d   V P                  W#^4      # \        V\        4      '       d   V P                  W2R4      # V # )é    :r)   NNr9   )	r   Ú
isinstancer   r   Ú_eval_expand_commutatorÚappendr   r   rF   )r   Úhintsr#   r$   ÚsargsÚtermrC   r   r0   ÚcÚcomm1Úcomm2ÚfirstÚseconds   &,            r   rK   Ú"Commutator._eval_expand_commutator•   sM  € Ø�I‰I�a�LˆØ�I‰I�a�Lˆä�aœ×ÒàˆEØŸœ�Ü! $Ó*�Ü˜d¤J×/Ò/Ø×7Ñ7Ó9�DØ—‘˜TÖ"ñ	 ô
 ˜‘;ÐÜ˜œ3×ÒàˆEØŸœ�Ü! !Ó*�Ü˜d¤J×/Ò/Ø×7Ñ7Ó9�DØ—‘˜TÖ"ñ	 ô
 ˜‘;ÐÜ˜œ3×Òà—‘�q•	ˆAÜ�Q—V‘V˜B•ZÑ ˆAØˆAÜ˜qÓ$ˆEÜ˜qÓ$ˆEÜ˜%¤×,Ò,Ø×5Ñ5Ó7�Ü˜%¤×,Ò,Ø×5Ñ5Ó7�Ü˜“MˆEÜ˜“]ˆFÜ�uÓ%Ð%Ü˜œ3×ÒàˆAØ—‘�q•	ˆAÜ�Q—V‘V˜B•ZÑ ˆAÜ˜qÓ$ˆEÜ˜qÓ$ˆEÜ˜%¤×,Ò,Ø×5Ñ5Ó7�Ü˜%¤×,Ò,Ø×5Ñ5Ó7�Ü˜“MˆEÜ˜“]ˆFÜ�uÓ%Ð%Ü˜œ3×Òà×#Ñ# A¨!Ó,Ð,Ü˜œ3×Òà×#Ñ# A¨"Ó-Ð-ð ˆr   c                ó¼  € ^ RI Hp V P                  ^ ,          pV P                  ^,          p\        W24      '       d<   \        WB4      '       d+    VP                  ! V3/ VB pTe   TP                  ! R/ TB # W4,          WC,          ,
          P                  ! R/ VB #   \
         d3     RTP                  ! T3/ TB ,          p Lc  \
         d    Rp  Lsi ; ii ; i)zEvaluate commutator )ÚOperatorNr9   © )Úsympy.physics.quantum.operatorrW   r   rJ   Ú_eval_commutatorÚNotImplementedErrorÚdoit)r   rM   rW   r#   r$   rC   s   &,    r   r\   ÚCommutator.doitÑ   sÊ   € õ 	<Ø�I‰I�a�LˆØ�I‰I�a�LˆÜ�a×"Ò"¤z°!×'>Ò'>ð Ø×)Ò)¨!Ñ5¨uÑ5�ð ÒØ—y’yÑ) 5Ñ)Ð)Ø•�a•c•	×ÒÑ( %Ñ(Ð(øô 'ô  ð Ø˜a×0Ò0°Ñ<°eÑ<Õ<’DøÜ*ô  Ø“Dð úð ús*   ÁB ÂCÂ*CÃCÃCÃCÃCc                ó‚   € \        \        V P                  ^,          4      \        V P                  ^ ,          4      4      # )r)   )r   r	   r   )r   s   &r   Ú_eval_adjointÚCommutator._eval_adjointä   s)   € Üœ& §¡¨1¥Ó.´°t·y±yÀµ|Ó0DÓEÐEr   c                óÆ   € V P                   P                  : R VP                  V P                  ^ ,          4      : RVP                  V P                  ^,          4      : R2# )Ú(Ú,Ú))Ú	__class__Ú__name__Ú_printr   ©r   Úprinterr   s   &&*r   Ú
_sympyreprÚCommutator._sympyreprç   sC   € à�N‰N×#Ô# W§^¡^Ø—	‘	˜!•ö&Ø&Ÿ~™~¨d¯i©i¸­lÖ;ð
ð 	
r   c                ó˜   € R VP                  V P                  ^ ,          4      : RVP                  V P                  ^,          4      : R2# )Ú[rc   Ú])rg   r   rh   s   &&*r   Ú	_sympystrÚCommutator._sympystrí   s5   � à�N‰N˜4Ÿ9™9 Q�<Ö(¨'¯.©.¸¿¹À1½Ö*FðHð 	Hr   c                ó<  € VP                   ! V P                  ^ ,          .VO5!  p\        VP                  \        R4      4      !  p\        VP                  VP                   ! V P                  ^,          .VO5!  4      !  p\        VP	                  RRR7      !  pV# )rI   rc   rm   rn   )ÚleftÚright)rg   r   r   rs   Úparens)r   ri   r   Úpforms   &&* r   Ú_prettyÚCommutator._prettyñ   sy   € Ø—’˜tŸy™y¨�|Ð3¨dÓ3ˆÜ˜EŸK™K¬
°3«Ó8Ñ9ˆÜ˜EŸK™K¨¯ª°t·y±yÀµ|Ð(KÀdÓ(KÓLÑMˆÜ˜EŸL™L¨c¸˜LÓ=Ñ>ˆØˆr   c           
     ó†   € R \        V P                   Uu. uF  q1P                  ! V.VO5!  NK  	  up4      ,          # u upi )z\left[%s,%s\right])Útupler   rg   )r   ri   r   Úargs   &&* r   Ú_latexÚCommutator._latexø   sB   € Ø%¬Ø26·)²)ó/=Ù2;¨3�NŠN˜3Ð& Ö&±)ñ/=ó )>õ >ð 	>ùò /=s   •>
rX   N)rf   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   r   r   Úpropertyr   r!   Úclassmethodr    rF   rK   r\   r_   rj   ro   rv   r{   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r      s}   ø‡ € ñFðN €Ná%Ð&BÐPTÔUÐàñ1ó ð1òð ñ+ó ð+ò($ò :òx)ò&Fò
òHò÷>ð >r   c                ó   € \         # )z8Find the kind of an anticommutator of two OperatorKinds.)r   )Úe1Úe2s   &&r   Úfind_op_kindr‰   ý   s
   € ô Ðr   N)r€   Úsympy.core.addr   Úsympy.core.exprr   Úsympy.core.kindr   Úsympy.core.mulr   Úsympy.core.powerr   Úsympy.core.singletonr   Ú sympy.printing.pretty.stringpictr   Úsympy.physics.quantum.daggerr	   Úsympy.physics.quantum.kindr
   r   Ú__all__r   r   Úregisterr‰   rX   r   r   Ú<module>r•      sf   ðÙ (å Ý  Ý *Ý Ý  Ý "Ý 7å /ß Bð ð€ôb>�ô b>ðJ ×Ñ×%Ñ% m°]ÓCñó Dòr   