+
    i                         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   & ^/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/physics/quantum/commutator.py	<genexpr>"Commutator.kind.<locals>.<genexpr>f   s     /YVVYs   )args_kind_dispatcher)self	arg_kindss   & r   r   Commutator.kindd   s!    /TYY/	$$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.    HHQN=Hll31%
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66M666Mq///66M **,**,sF|S)<cnnS>Q%RSS 99Q<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    ee~~~S__%6%6#c(a-Kvv???662:D$C$"))T):a4'q#AS1Wq[)D047::F MMO##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	\        W4      p
\        Wy4      p\        V
\        4      '       d   V
P	                  4       p
\        V\        4      '       d   VP	                  4       p\        Wz4      p\        W4      p\        W4      # \        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\        W4      p\        W4      p\        W4      # \        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   IIaLIIaLaE!$*dJ//779DT"	 
 ;3E!!*dJ//779DT"	 
 ;3q	AQVVBZ AAq$Eq$E%,,557%,,557ME]Fu%%3Aq	AQVVBZ Aq$Eq$E%,,557%,,557ME]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     	<IIaLIIaLa""z!'>'> ))!5u5 yy)5))ac	(%(( '   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.tyy|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    NN##W^^		!&&~~dii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    NN499Q<('..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    tyy|3d3EKK
389EKKtyy|(Kd(KLMELLc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;3NN3&&)/= )> > 	> /=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%&BPT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   