
    Цi                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJrJrJrJrJr  SS
KJr  / SQr " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)zBosonic quantum operators.    )Mul)Integer)S)	conjugate)exp)sqrt)Operator)HilbertSpace	FockSpaceKetBraIdentityOperator)KroneckerDelta)BosonOpBosonFockKetBosonFockBraBosonCoherentKetBosonCoherentBrac                   ~    \ rS rSrSr\S 5       r\S 5       r\S 5       r	S r
S rS rS	 rS
 rS rS rS rS rSrg)r      a  A bosonic operator that satisfies [a, Dagger(a)] == 1.

Parameters
==========

name : str
    A string that labels the bosonic mode.

annihilation : bool
    A bool that indicates if the bosonic operator is an annihilation (True,
    default value) or creation operator (False)

Examples
========

>>> from sympy.physics.quantum import Dagger, Commutator
>>> from sympy.physics.quantum.boson import BosonOp
>>> a = BosonOp("a")
>>> Commutator(a, Dagger(a)).doit()
1
c                      U R                   S   $ Nr   )argsselfs    Z/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/sympy/physics/quantum/boson.pynameBosonOp.name.   s    yy|    c                 2    [        U R                  S   5      $ N   )boolr   r   s    r   is_annihilationBosonOp.is_annihilation2   s    DIIaL!!r   c                     g)N)aT r   s    r   default_argsBosonOp.default_args6   s    r   c                     [        U5      S;  a  [        SU-  5      e[        U5      S:X  a  US   [        R                  4n[        U5      S:X  a  US   [	        US   5      4n[
        R                  " U /UQ76 $ )N)r"      z"1 or 2 parameters expected, got %sr"   r   r,   )len
ValueErrorr   Oner   r	   __new__)clsr   hintss      r   r0   BosonOp.__new__:   st    4yF"ADHIIt9>GQUU#Dt9>GWT!W-.D+d++r   c                     U R                   UR                   :X  a3  U R                  (       d!  UR                  (       a  [        R                  $ g SU;   a  US   (       a  [        R                  $ g )Nindependent)r   r$   r   NegativeOneZeror   otherr2   s      r   _eval_commutator_BosonOp BosonOp._eval_commutator_BosonOpF   sO    99

"''E,A,A}}$ 	 e#m(<66Mr   c                 "    [         R                  $ N)r   r7   r8   s      r   _eval_commutator_FermionOp"BosonOp._eval_commutator_FermionOpR   s    vvr   c                 4    SU;   a  US   (       a  SU -  U-  $ g )Nr5   r,   r(   r8   s      r   _eval_anticommutator_BosonOp$BosonOp._eval_anticommutator_BosonOpU   s#    E!eM&:t8e##r   c                 ^    [        [        U R                  5      U R                  (       + 5      $ r=   )r   strr   r$   r   s    r   _eval_adjointBosonOp._eval_adjoint\   s     s499~4+?+?'?@@r   c                    U[        S5      :X  a  U $ [        U[        5      (       aR  [        S UR                   5       5      n[        S UR                   5       5      nU nU H  nXE-  nM	     [        U6 U-  $ [        X5      $ )Nr,   c              3   J   #    U  H  oR                   (       d  M  Uv   M     g 7fr=   is_commutative.0args     r   	<genexpr>"BosonOp.__mul__.<locals>.<genexpr>e   s     J#7I7I##   #	#c              3   J   #    U  H  oR                   (       a  M  Uv   M     g 7fr=   rI   rK   s     r   rN   rO   f   s     N#;M;M##rP   )r   
isinstancer   tupler   )r   r9   args1args2xys         r   __mul__BosonOp.__mul___   sy    $Q''KeS!!JJJENNNEAE ;?"4r   c                     U R                   (       a  S[        U R                  5      -  $ S[        U R                  5      -  $ )Nz{%s}z{{%s}^\dagger}r$   rD   r   r   printerr   s      r   _print_contents_latexBosonOp._print_contents_latexn   s1    S^++$s499~55r   c                     U R                   (       a  S[        U R                  5      -  $ S[        U R                  5      -  $ )Nz%sz
Dagger(%s)r[   r\   s      r   _print_contentsBosonOp._print_contentst   s1    3tyy>)) 3tyy>11r   c                     SSK Jn  UR                  " U R                  S   /UQ76 nU R                  (       a  U$ XC" S5      -  $ )Nr   )
prettyFormu   †) sympy.printing.pretty.stringpictrd   _printr   r$   )r   r]   r   rd   pforms        r   _print_contents_prettyBosonOp._print_contents_prettyz   s>    ?tyy|3d3L*\222r   r(   N)__name__
__module____qualname____firstlineno____doc__propertyr   r$   classmethodr)   r0   r:   r>   rA   rE   rX   r^   ra   rh   __static_attributes__r(   r   r   r   r      sq    ,   " "  
,
A 623r   r   c                   Z    \ rS rSrSrS r\S 5       r\S 5       r	\S 5       r
S rS rS	rg
)r      zbFock state ket for a bosonic mode.

Parameters
==========

n : Number
    The Fock state number.

c                 .    [         R                  " X5      $ r=   r   r0   r1   ns     r   r0   BosonFockKet.__new__       {{3""r   c                      U R                   S   $ r   labelr   s    r   rw   BosonFockKet.n       zz!}r   c                     [         $ r=   )r   r   s    r   
dual_classBosonFockKet.dual_class       r   c                     [        5       $ r=   r   r1   r|   s     r   _eval_hilbert_space BosonFockKet._eval_hilbert_space   
    {r   c                 B    [        U R                  UR                  5      $ r=   )r   rw   r   brar2   s      r   _eval_innerproduct_BosonFockBra,BosonFockKet._eval_innerproduct_BosonFockBra   s    dffcee,,r   c                     UR                   (       a.  [        U R                  5      [        U R                  S-
  5      -  $ [        U R                  S-   5      [        U R                  S-   5      -  $ r!   )r$   r   rw   r   r   opoptionss      r   _apply_from_right_to_BosonOp)BosonFockKet._apply_from_right_to_BosonOp   sP    <,tvvz":::
#l466A:&>>>r   r(   N)rj   rk   rl   rm   rn   r0   ro   rw   rp   r   r   r   r   rq   r(   r   r   r   r      sR    #      -?r   r   c                   N    \ rS rSrSrS r\S 5       r\S 5       r	\S 5       r
Srg)	r      zbFock state bra for a bosonic mode.

Parameters
==========

n : Number
    The Fock state number.

c                 .    [         R                  " X5      $ r=   r   r0   rv   s     r   r0   BosonFockBra.__new__   ry   r   c                      U R                   S   $ r   r{   r   s    r   rw   BosonFockBra.n   r~   r   c                     [         $ r=   )r   r   s    r   r   BosonFockBra.dual_class   r   r   c                     [        5       $ r=   r   r   s     r   r    BosonFockBra._eval_hilbert_space   r   r   r(   N)rj   rk   rl   rm   rn   r0   ro   rw   rp   r   r   rq   r(   r   r   r   r      sH    #      r   r   c                   Z    \ rS rSrSrS r\S 5       r\S 5       r	\S 5       r
S rS rS	rg
)r      zCoherent state ket for a bosonic mode.

Parameters
==========

alpha : Number, Symbol
    The complex amplitude of the coherent state.

c                 .    [         R                  " X5      $ r=   ru   r1   alphas     r   r0   BosonCoherentKet.__new__       {{3&&r   c                      U R                   S   $ r   r{   r   s    r   r   BosonCoherentKet.alpha   r~   r   c                     [         $ r=   )r   r   s    r   r   BosonCoherentKet.dual_class       r   c                     [        5       $ r=   )r
   r   s     r   r   $BosonCoherentKet._eval_hilbert_space   s
    ~r   c                    U R                   UR                   :X  a  [        R                  $ [        [	        U R                   5      S-  [	        UR                   5      S-  -   S[        UR                   5      -  U R                   -  -
  * S-  5      $ )Nr,   )r   r   r/   r   absr   r   s      r   #_eval_innerproduct_BosonCoherentBra4BosonCoherentKet._eval_innerproduct_BosonCoherentBra   sp    ::"55LTZZ!+c#))na.??!iPSPYPYFZBZ]a]g]gBgghijjkkr   c                 D    UR                   (       a  U R                  U -  $ g r=   r$   r   r   s      r   r   -BosonCoherentKet._apply_from_right_to_BosonOp   s    ::$$r   r(   N)rj   rk   rl   rm   rn   r0   ro   r   rp   r   r   r   r   rq   r(   r   r   r   r      sS    '        lr   r   c                   D    \ rS rSrSrS r\S 5       r\S 5       r	S r
Srg)	r      zCoherent state bra for a bosonic mode.

Parameters
==========

alpha : Number, Symbol
    The complex amplitude of the coherent state.

c                 .    [         R                  " X5      $ r=   r   r   s     r   r0   BosonCoherentBra.__new__   r   r   c                      U R                   S   $ r   r{   r   s    r   r   BosonCoherentBra.alpha   r~   r   c                     [         $ r=   )r   r   s    r   r   BosonCoherentBra.dual_class   r   r   c                 D    UR                   (       d  U R                  U -  $ g r=   r   r   s      r   _apply_operator_BosonOp(BosonCoherentBra._apply_operator_BosonOp   s    !!::$$r   r(   N)rj   rk   rl   rm   rn   r0   ro   r   rp   r   r   rq   r(   r   r   r   r      s9    '      r   r   N)rn   sympy.core.mulr   sympy.core.numbersr   sympy.core.singletonr   $sympy.functions.elementary.complexesr   &sympy.functions.elementary.exponentialr   (sympy.functions.elementary.miscellaneousr   sympy.physics.quantumr	   r
   r   r   r   r   (sympy.functions.special.tensor_functionsr   __all__r   r   r   r   r   r(   r   r   <module>r      sn       & " : 6 9 * U U Ci3h i3X!?3 !?H3 6$s $Ns r   