Ë
    7^(hÉL  ã                   ó8  — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZ ddlmZ ddlmZ g d¢Z G d„ de«      Z G d„ de«      Z G d„ de«      Z  G d„ de«      Z! G d„ de«      Z" G d„ de«      Z#y)a  Quantum mechanical operators.

TODO:

* Fix early 0 in apply_operators.
* Debug and test apply_operators.
* Get cse working with classes in this file.
* Doctests and documentation of special methods for InnerProduct, Commutator,
  AntiCommutator, represent, apply_operators.
é    )ÚOptional)ÚAdd)ÚExpr)Ú
DerivativeÚexpand)ÚMul©Úoo©ÚS©Ú
prettyForm)ÚDagger)ÚOperatorKind)ÚQExprÚdispatch_method)Úeye)Úsympy_deprecation_warning)ÚOperatorÚHermitianOperatorÚUnitaryOperatorÚIdentityOperatorÚOuterProductÚDifferentialOperatorc                   ó¢   — e Zd ZU dZdZee   ed<   dZee   ed<   e	d„ «       Z
eZdZd„ ZeZd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZd„ Zy)r   a
  Base class for non-commuting quantum operators.

    An operator maps between quantum states [1]_. In quantum mechanics,
    observables (including, but not limited to, measured physical values) are
    represented as Hermitian operators [2]_.

    Parameters
    ==========

    args : tuple
        The list of numbers or parameters that uniquely specify the
        operator. For time-dependent operators, this will include the time.

    Examples
    ========

    Create an operator and examine its attributes::

        >>> from sympy.physics.quantum import Operator
        >>> from sympy import I
        >>> A = Operator('A')
        >>> A
        A
        >>> A.hilbert_space
        H
        >>> A.label
        (A,)
        >>> A.is_commutative
        False

    Create another operator and do some arithmetic operations::

        >>> B = Operator('B')
        >>> C = 2*A*A + I*B
        >>> C
        2*A**2 + I*B

    Operators do not commute::

        >>> A.is_commutative
        False
        >>> B.is_commutative
        False
        >>> A*B == B*A
        False

    Polymonials of operators respect the commutation properties::

        >>> e = (A+B)**3
        >>> e.expand()
        A*B*A + A*B**2 + A**2*B + A**3 + B*A*B + B*A**2 + B**2*A + B**3

    Operator inverses are handle symbolically::

        >>> A.inv()
        A**(-1)
        >>> A*A.inv()
        1

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Operator_%28physics%29
    .. [2] https://en.wikipedia.org/wiki/Observable
    NÚis_hermitianÚ
is_unitaryc                  ó   — y)N)ÚO© ©Úselfs    ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/physics/quantum/operator.pyÚdefault_argszOperator.default_argsn   s   € àó    ú,c                 ó.   — | j                   j                  S ©N)Ú	__class__Ú__name__©r"   ÚprinterÚargss      r#   Ú_print_operator_namezOperator._print_operator_namez   s   € Ø�~‰~×&Ñ&Ð&r%   c                 ó@   — t        | j                  j                  «      S r(   )r   r)   r*   r+   s      r#   Ú_print_operator_name_prettyz$Operator._print_operator_name_pretty   s   € Ü˜$Ÿ.™.×1Ñ1Ó2Ð2r%   c                 ó¬   — t        | j                  «      dk(  r | j                  |g|¢­Ž S  | j                  |g|¢­Ž ›d | j                  |g|¢­Ž ›d�S )Né   ú(ú))ÚlenÚlabelÚ_print_labelr.   r+   s      r#   Ú_print_contentszOperator._print_contents‚   s`   € Üˆt�z‰z‹?˜aÒØ$�4×$Ñ$ WÐ4¨tÒ4Ð4ð *�×)Ñ)¨'Ð9°DÔ9Ø!�×!Ñ! 'Ð1¨DÔ1ðð r%   c                 ó  — t        | j                  «      dk(  r | j                  |g|¢­Ž S  | j                  |g|¢­Ž } | j                  |g|¢­Ž }t	        |j                  dd¬«      Ž }t	        |j                  |«      Ž }|S )Nr2   r3   r4   ©ÚleftÚright)r5   r6   Ú_print_label_prettyr0   r   Úparensr<   ©r"   r,   r-   ÚpformÚlabel_pforms        r#   Ú_print_contents_prettyzOperator._print_contents_pretty‹   s�   € Üˆt�z‰z‹?˜aÒØ+�4×+Ñ+¨GÐ;°dÒ;Ð;à4�D×4Ñ4°WÐD¸tÒDˆEØ2˜$×2Ñ2°7ÐB¸TÒBˆKÜ$Ø×#Ñ#¨°CÐ#Ó8ðˆKô  §¡¨KÓ 8Ð9ˆEØˆLr%   c                 ó¬   — t        | j                  «      dk(  r | j                  |g|¢­Ž S  | j                  |g|¢­Ž ›d | j                  |g|¢­Ž ›d�S )Nr2   z\left(z\right))r5   r6   Ú_print_label_latexÚ_print_operator_name_latexr+   s      r#   Ú_print_contents_latexzOperator._print_contents_latex—   s`   € Üˆt�z‰z‹?˜aÒØ*�4×*Ñ*¨7Ð:°TÒ:Ð:ð 0�×/Ñ/°Ð?¸$Ô?Ø'�×'Ñ'¨Ð7°$Ô7ðð r%   c                 ó   — t        | d|fi |¤ŽS )z:Evaluate [self, other] if known, return None if not known.Ú_eval_commutator©r   ©r"   ÚotherÚoptionss      r#   rH   zOperator._eval_commutator¤   s   € ä˜tÐ%7¸ÑJÀ'ÑJÐJr%   c                 ó   — t        | d|fi |¤ŽS )z Evaluate [self, other] if known.Ú_eval_anticommutatorrI   rJ   s      r#   rN   zOperator._eval_anticommutator¨   s   € ä˜tÐ%;¸UÑNÀgÑNÐNr%   c                 ó   — t        | d|fi |¤ŽS )NÚ_apply_operatorrI   ©r"   ÚketrL   s      r#   rP   zOperator._apply_operator°   s   € Ü˜tÐ%6¸ÑG¸wÑGÐGr%   c                  ó   — y r(   r    ©r"   ÚbrarL   s      r#   Ú_apply_from_right_tozOperator._apply_from_right_to³   s   € Ør%   c                 ó   — t        d«      ‚)Nzmatrix_elements is not defined)ÚNotImplementedError)r"   r-   s     r#   Úmatrix_elementzOperator.matrix_element¶   s   € Ü!Ð"BÓCÐCr%   c                 ó"   — | j                  «       S r(   ©Ú_eval_inverser!   s    r#   ÚinversezOperator.inverse¹   ó   € Ø×!Ñ!Ó#Ð#r%   c                 ó   — | dz  S ©Néÿÿÿÿr    r!   s    r#   r\   zOperator._eval_inverse¾   s   € Ø�b‰zÐr%   )r*   Ú
__module__Ú__qualname__Ú__doc__r   r   ÚboolÚ__annotations__r   Úclassmethodr$   r   ÚkindÚ_label_separatorr.   rE   r0   r8   rB   rF   rH   rN   rP   rV   rY   r]   Úinvr\   r    r%   r#   r   r   *   s—   … ñ@ðB $(€L�(˜4‘.Ó'Ø!%€J�˜‘Ó%Øñó ðð €Dð Ðò'ð "6Ðò3òò
òòKòOòHòòDò$ð €Cór%   r   c                   ó    — e Zd ZdZdZd„ Zd„ Zy)r   a”  A Hermitian operator that satisfies H == Dagger(H).

    Parameters
    ==========

    args : tuple
        The list of numbers or parameters that uniquely specify the
        operator. For time-dependent operators, this will include the time.

    Examples
    ========

    >>> from sympy.physics.quantum import Dagger, HermitianOperator
    >>> H = HermitianOperator('H')
    >>> Dagger(H)
    H
    Tc                 óP   — t        | t        «      r| S t        j                  | «      S r(   )Ú
isinstancer   r   r\   r!   s    r#   r\   zHermitianOperator._eval_inverse×   s"   € Ü�dœOÔ,ØˆKä×)Ñ)¨$Ó/Ð/r%   c                 ó¦   — t        | t        «      r,|j                  rddlm} |j
                  S |j                  r| S t        j                  | |«      S )Nr   r   )	rm   r   Úis_evenÚsympy.core.singletonr   ÚOneÚis_oddr   Ú_eval_power)r"   Úexpr   s      r#   rs   zHermitianOperator._eval_powerÝ   s>   € Ü�dœOÔ,à�{Š{Ý2Ø—u‘u�Ø—’Ø�ä×#Ñ# D¨#Ó.Ð.r%   N)r*   rb   rc   rd   r   r\   rs   r    r%   r#   r   r   Â   s   „ ñð$ €Lò0ó	/r%   r   c                   ó   — e Zd ZdZdZd„ Zy)r   a’  A unitary operator that satisfies U*Dagger(U) == 1.

    Parameters
    ==========

    args : tuple
        The list of numbers or parameters that uniquely specify the
        operator. For time-dependent operators, this will include the time.

    Examples
    ========

    >>> from sympy.physics.quantum import Dagger, UnitaryOperator
    >>> U = UnitaryOperator('U')
    >>> U*Dagger(U)
    1
    Tc                 ó"   — | j                  «       S r(   r[   r!   s    r#   Ú_eval_adjointzUnitaryOperator._eval_adjointü   r^   r%   N)r*   rb   rc   rd   r   rw   r    r%   r#   r   r   é   s   „ ñð" €Jó$r%   r   c                   ó€   — e Zd ZdZdZdZed„ «       Zed„ «       Z	d„ Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)r   a,  An identity operator I that satisfies op * I == I * op == op for any
    operator op.

    .. deprecated:: 1.14.
        Use the scalar S.One instead as the multiplicative identity for
        operators and states.

    Parameters
    ==========

    N : Integer
        Optional parameter that specifies the dimension of the Hilbert space
        of operator. This is used when generating a matrix representation.

    Examples
    ========

    >>> from sympy.physics.quantum import IdentityOperator
    >>> IdentityOperator() # doctest: +SKIP
    I
    Tc                 ó   — | j                   S r(   )ÚNr!   s    r#   Ú	dimensionzIdentityOperator.dimension  s   € à�v‰vˆr%   c                 ó   — t         fS r(   r	   r!   s    r#   r$   zIdentityOperator.default_args  s	   € äˆuˆr%   c                 ó¨   — t        ddd¬«       t        |«      dvrt        d|z  «      ‚t        |«      dk(  r|d   r|d   | _        y t        | _        y )	Nz�
            IdentityOperator has been deprecated. In the future, please use
            S.One as the identity for quantum operators and states.
            z1.14zdeprecated-operator-identity)Údeprecated_since_versionÚactive_deprecations_target)r   r2   z"0 or 1 parameters expected, got %sr2   r   )r   r5   Ú
ValueErrorr
   rz   )r"   r-   Úhintss      r#   Ú__init__zIdentityOperator.__init__   sW   € Ü!ðð &,Ø'Eõ	
ô �4‹y˜FÑ"ÜÐAÀDÑHÓIÐIä  ›Y¨!š^°°Q²��a‘ˆ�¼bˆ�r%   c                 ó"   — t         j                  S r(   )r   ÚZero©r"   rK   r�   s      r#   rH   z!IdentityOperator._eval_commutator.  s   € Ü�v‰vˆr%   c                 ó   — d|z  S )Né   r    r…   s      r#   rN   z%IdentityOperator._eval_anticommutator1  s   € Ø�5‰yÐr%   c                 ó   — | S r(   r    r!   s    r#   r\   zIdentityOperator._eval_inverse4  ó   € Øˆr%   c                 ó   — | S r(   r    r!   s    r#   rw   zIdentityOperator._eval_adjoint7  r‰   r%   c                 ó   — |S r(   r    rQ   s      r#   rP   z IdentityOperator._apply_operator:  ó   € Øˆ
r%   c                 ó   — |S r(   r    rT   s      r#   rV   z%IdentityOperator._apply_from_right_to=  rŒ   r%   c                 ó   — | S r(   r    )r"   rt   s     r#   rs   zIdentityOperator._eval_power@  r‰   r%   c                  ó   — y©NÚIr    r+   s      r#   r8   z IdentityOperator._print_contentsC  s   € Ør%   c                 ó   — t        d«      S r�   r   r+   s      r#   rB   z'IdentityOperator._print_contents_prettyF  s   € Ü˜#‹Ðr%   c                  ó   — y)Nz{\mathcal{I}}r    r+   s      r#   rF   z&IdentityOperator._print_contents_latexI  s   € Ør%   c                 óÐ   — | j                   r| j                   t        k(  rt        d«      ‚|j                  dd«      }|dk7  rt        dd|z  z   «      ‚t	        | j                   «      S )NzCCannot represent infinite dimensional identity operator as a matrixÚformatÚsympyzRepresentation in format z%s not implemented.)rz   r
   rX   Úgetr   )r"   rL   r•   s      r#   Ú_represent_default_basisz)IdentityOperator._represent_default_basisL  sr   € Ø�vŠv˜Ÿ™¤2šÜ%ð 'Gó Hð Hð —‘˜X wÓ/ˆØ�WÒÜ%Ð&AØ&;¸fÑ&Dñ'Eó Fð Fô �4—6‘6‹{Ðr%   N)r*   rb   rc   rd   r   r   Úpropertyr{   rg   r$   r‚   rH   rN   r\   rw   rP   rV   rs   r8   rB   rF   r˜   r    r%   r#   r   r      sv   „ ñð* €LØ€JØñó ðð ñó ðòAòòòòòòòòòò ó
r%   r   c                   ód   — e Zd ZdZdZd„ Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zy)r   aß  An unevaluated outer product between a ket and bra.

    This constructs an outer product between any subclass of ``KetBase`` and
    ``BraBase`` as ``|a><b|``. An ``OuterProduct`` inherits from Operator as they act as
    operators in quantum expressions.  For reference see [1]_.

    Parameters
    ==========

    ket : KetBase
        The ket on the left side of the outer product.
    bar : BraBase
        The bra on the right side of the outer product.

    Examples
    ========

    Create a simple outer product by hand and take its dagger::

        >>> from sympy.physics.quantum import Ket, Bra, OuterProduct, Dagger

        >>> k = Ket('k')
        >>> b = Bra('b')
        >>> op = OuterProduct(k, b)
        >>> op
        |k><b|
        >>> op.hilbert_space
        H
        >>> op.ket
        |k>
        >>> op.bra
        <b|
        >>> Dagger(op)
        |b><k|

    In quantum expressions, outer products will be automatically
    identified and created::

        >>> k*b
        |k><b|

    However, the creation of inner products always has higher priority than that of
    outer products:

        >>> b*k*b
        <b|k>*<b|

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Outer_product
    Fc           	      ó  — ddl m}m} t        |«      dk7  rt	        dt        |«      z  «      ‚t        |d   «      }t        |d   «      }t        ||t        f«      �r,t        ||t        f«      �r|j                  «       \  }}|j                  «       \  }	}
t        |«      dk7  st        |d   |«      st        dt        |Ž z  «      ‚t        |
«      dk7  st        |
d   |«      st        dt        |
Ž z  «      ‚|d   j                  «       |
d   j                  k(  s+t        d|d   j                  ›d	|
d   j                  ›�«      ‚t        j                  | g|d   |
d   f¢­i |¤Ž}|d   j                  |_        t        ||	z   Ž |z  S g }t        |t        «      rVt        |t        «      rF|j                   D ]/  }|j                   D ]  }|j#                  t%        ||fi |¤Ž«       Œ  Œ1 t        |Ž S t        |t        «      r5|j                   D ]  }|j#                  t%        ||fi |¤Ž«       Œ  t        |Ž S t        |t        «      r5|j                   D ]  }|j#                  t%        ||fi |¤Ž«       Œ  t        |Ž S t        d
|›d	|›�«      ‚)Nr   )ÚKetBaseÚBraBaser‡   z2 parameters expected, got %dr2   z"KetBase subclass expected, got: %rz"BraBase subclass expected, got: %rz"ket and bra are not dual classes: z, z&Expected ket and bra expression, got: )Úsympy.physics.quantum.staterœ   r�   r5   r€   r   rm   r   Úargs_cncÚ	TypeErrorÚ
dual_classr)   r   Ú__new__Úhilbert_spacer   r-   Úappendr   )Úclsr-   Úold_assumptionsrœ   r�   Úket_exprÚbra_exprÚket_cÚketsÚbra_cÚbrasÚobjÚop_termsÚket_termÚbra_terms                  r#   r¢   zOuterProduct.__new__�  s­  € ß@äˆt‹9˜Š>ÜÐ<¼sÀ4»yÑHÓIÐIä˜$˜q™'“?ˆÜ˜$˜q™'“?ˆä�x '¬3 Õ0Ü˜8 g¬s ^Õ4Ø"×+Ñ+Ó-‰KˆE�4Ø"×+Ñ+Ó-‰KˆE�4ä�4‹y˜AŠ~¤Z°°Q±¸Ô%AÜð !,Ü.1°4¨jñ!9ó :ð :ô �4‹y˜AŠ~¤Z°°Q±¸Ô%AÜð !,Ü.1°4¨jñ!9ó :ð :ð ˜‘7×%Ñ%Ó'¨4°©7×+<Ñ+<Ò<Ýà˜!‘W×&Ó&¨¨Q©×(9Ò(9ð;óð ô —,‘,˜sÐK d¨1¡g¨t°A©wÐ%7ÒK¸?ÑKˆCØ $ Q¡× 5Ñ 5ˆCÔÜ˜ ™Ð(¨3Ñ.Ð.àˆÜ�h¤Ô$¬°H¼cÔ)BØ$ŸM™Mò E�Ø (§¡ò E�HØ—O‘O¤L°¸8ñ %DØ3Bñ%Dõ EñEðEô$ �Hˆ~Ðô ˜¤#Ô&Ø$ŸM™Mò A�Ø—‘¤¨X°xñ !@Ø/>ñ!@õ AðAô �Hˆ~Ðô ˜¤#Ô&Ø$ŸM™Mò A�Ø—‘¤¨X°xñ !@Ø/>ñ!@õ AðAô �Hˆ~Ðõ â™8ð%óð r%   c                 ó    — | j                   d   S )z5Return the ket on the left side of the outer product.r   ©r-   r!   s    r#   rR   zOuterProduct.ketÈ  ó   € ð �y‰y˜‰|Ðr%   c                 ó    — | j                   d   S )z6Return the bra on the right side of the outer product.r2   r²   r!   s    r#   rU   zOuterProduct.braÍ  r³   r%   c                 óf   — t        t        | j                  «      t        | j                  «      «      S r(   )r   r   rU   rR   r!   s    r#   rw   zOuterProduct._eval_adjointÒ  s!   € ÜœF 4§8¡8Ó,¬f°T·X±XÓ.>Ó?Ð?r%   c                 óp   — |j                  | j                  «      |j                  | j                  «      z   S r(   ©Ú_printrR   rU   r+   s      r#   Ú	_sympystrzOuterProduct._sympystrÕ  s'   € Ø�~‰~˜dŸh™hÓ'¨'¯.©.¸¿¹Ó*BÑBÐBr%   c                 ó¬   — | j                   j                  ›d |j                  | j                  g|¢­Ž ›d |j                  | j                  g|¢­Ž ›d�S )Nr3   r&   r4   )r)   r*   r¸   rR   rU   r+   s      r#   Ú
_sympyreprzOuterProduct._sympyreprØ  sH   € Ø"Ÿn™n×5Ó5ØˆG�N‰N˜4Ÿ8™8Ð+ dÔ+¨^¨W¯^©^¸D¿H¹HÐ-LÀtÔ-LðNð 	Nr%   c                 ó    —  | j                   j                  |g|¢­Ž }t        |j                   | j                  j                  |g|¢­Ž «      Ž S r(   )rR   Ú_prettyr   r<   rU   )r"   r,   r-   r@   s       r#   r½   zOuterProduct._prettyÜ  sH   € Ø �—‘× Ñ  Ð0¨4Ò0ˆÜ˜5Ÿ;™;Ð'7 t§x¡x×'7Ñ'7¸Ð'GÀ$Ò'GÓHÐIÐIr%   c                 ó€   —  |j                   | j                  g|¢­Ž } |j                   | j                  g|¢­Ž }||z   S r(   r·   )r"   r,   r-   ÚkÚbs        r#   Ú_latexzOuterProduct._latexà  s=   € ØˆG�N‰N˜4Ÿ8™8Ð+ dÒ+ˆØˆG�N‰N˜4Ÿ8™8Ð+ dÒ+ˆØ�1‰uˆr%   c                 ó|   —  | j                   j                  di |¤Ž} | j                  j                  di |¤Ž}||z  S )Nr    )rR   Ú
_representrU   )r"   rL   r¿   rÀ   s       r#   rÃ   zOuterProduct._representå  s=   € ØˆD�H‰H×ÑÑ* 'Ñ*ˆØˆD�H‰H×ÑÑ* 'Ñ*ˆØ�‰sˆ
r%   c                 óP   —  | j                   j                  | j                  fi |¤ŽS r(   )rR   Ú_eval_tracerU   )r"   Úkwargss     r#   rÅ   zOuterProduct._eval_traceê  s$   € ð $ˆt�x‰x×#Ñ# D§H¡HÑ7°Ñ7Ð7r%   N)r*   rb   rc   rd   Úis_commutativer¢   r™   rR   rU   rw   r¹   r»   r½   rÁ   rÃ   rÅ   r    r%   r#   r   r   Y  sd   „ ñ3ðh €Nò6ðp ñó ðð ñó ðò@òCòNòJòò
ó
8r%   r   c                   óh   — e Zd ZdZed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zd	„ Zy
)r   a+  An operator for representing the differential operator, i.e. d/dx

    It is initialized by passing two arguments. The first is an arbitrary
    expression that involves a function, such as ``Derivative(f(x), x)``. The
    second is the function (e.g. ``f(x)``) which we are to replace with the
    ``Wavefunction`` that this ``DifferentialOperator`` is applied to.

    Parameters
    ==========

    expr : Expr
           The arbitrary expression which the appropriate Wavefunction is to be
           substituted into

    func : Expr
           A function (e.g. f(x)) which is to be replaced with the appropriate
           Wavefunction when this DifferentialOperator is applied

    Examples
    ========

    You can define a completely arbitrary expression and specify where the
    Wavefunction is to be substituted

    >>> from sympy import Derivative, Function, Symbol
    >>> from sympy.physics.quantum.operator import DifferentialOperator
    >>> from sympy.physics.quantum.state import Wavefunction
    >>> from sympy.physics.quantum.qapply import qapply
    >>> f = Function('f')
    >>> x = Symbol('x')
    >>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x))
    >>> w = Wavefunction(x**2, x)
    >>> d.function
    f(x)
    >>> d.variables
    (x,)
    >>> qapply(d*w)
    Wavefunction(2, x)

    c                 ó4   — | j                   d   j                   S )a�  
        Returns the variables with which the function in the specified
        arbitrary expression is evaluated

        Examples
        ========

        >>> from sympy.physics.quantum.operator import DifferentialOperator
        >>> from sympy import Symbol, Function, Derivative
        >>> x = Symbol('x')
        >>> f = Function('f')
        >>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x))
        >>> d.variables
        (x,)
        >>> y = Symbol('y')
        >>> d = DifferentialOperator(Derivative(f(x, y), x) +
        ...                          Derivative(f(x, y), y), f(x, y))
        >>> d.variables
        (x, y)
        ra   r²   r!   s    r#   Ú	variableszDifferentialOperator.variables  s   € ð. �y‰y˜‰}×!Ñ!Ð!r%   c                 ó    — | j                   d   S )ad  
        Returns the function which is to be replaced with the Wavefunction

        Examples
        ========

        >>> from sympy.physics.quantum.operator import DifferentialOperator
        >>> from sympy import Function, Symbol, Derivative
        >>> x = Symbol('x')
        >>> f = Function('f')
        >>> d = DifferentialOperator(Derivative(f(x), x), f(x))
        >>> d.function
        f(x)
        >>> y = Symbol('y')
        >>> d = DifferentialOperator(Derivative(f(x, y), x) +
        ...                          Derivative(f(x, y), y), f(x, y))
        >>> d.function
        f(x, y)
        ra   r²   r!   s    r#   ÚfunctionzDifferentialOperator.function4  s   € ð, �y‰y˜‰}Ðr%   c                 ó    — | j                   d   S )a¯  
        Returns the arbitrary expression which is to have the Wavefunction
        substituted into it

        Examples
        ========

        >>> from sympy.physics.quantum.operator import DifferentialOperator
        >>> from sympy import Function, Symbol, Derivative
        >>> x = Symbol('x')
        >>> f = Function('f')
        >>> d = DifferentialOperator(Derivative(f(x), x), f(x))
        >>> d.expr
        Derivative(f(x), x)
        >>> y = Symbol('y')
        >>> d = DifferentialOperator(Derivative(f(x, y), x) +
        ...                          Derivative(f(x, y), y), f(x, y))
        >>> d.expr
        Derivative(f(x, y), x) + Derivative(f(x, y), y)
        r   r²   r!   s    r#   ÚexprzDifferentialOperator.exprL  s   € ð. �y‰y˜‰|Ðr%   c                 ó.   — | j                   j                  S )z<
        Return the free symbols of the expression.
        )rÎ   Úfree_symbolsr!   s    r#   rÐ   z!DifferentialOperator.free_symbolse  s   € ð �y‰y×%Ñ%Ð%r%   c                 óÌ   — ddl m} | j                  }|j                  dd  }| j                  }| j
                  j                  | ||Ž «      }|j                  «       } ||g|¢­Ž S )Nr   )ÚWavefunctionr2   )rž   rÒ   rÊ   r-   rÌ   rÎ   ÚsubsÚdoit)r"   ÚfuncrL   rÒ   ÚvarÚwf_varsÚfÚnew_exprs           r#   Ú_apply_operator_Wavefunctionz1DifferentialOperator._apply_operator_Wavefunctionm  sY   € Ý<Ø�n‰nˆØ—)‘)˜A˜B�-ˆà�M‰MˆØ—9‘9—>‘> !¡T¨3 ZÓ0ˆØ—=‘=“?ˆá˜HÐ/ wÒ/Ð/r%   c                 ó`   — t        | j                  |«      }t        || j                  d   «      S r`   )r   rÎ   r   r-   )r"   ÚsymbolrÙ   s      r#   Ú_eval_derivativez%DifferentialOperator._eval_derivativex  s'   € Ü˜dŸi™i¨Ó0ˆÜ# H¨d¯i©i¸©mÓ<Ð<r%   c                 óV   —  | j                   |g|¢­Ž ›d | j                  |g|¢­Ž ›d�S )Nr3   r4   )r.   r7   r+   s      r#   r¸   zDifferentialOperator._print€  s6   € à%ˆD×%Ñ% gÐ5°Ô5ØˆD×Ñ˜gÐ-¨Ô-ð
ð 	
r%   c                 ó²   —  | j                   |g|¢­Ž } | j                  |g|¢­Ž }t        |j                  dd¬«      Ž }t        |j	                  |«      Ž }|S )Nr3   r4   r:   )r0   r=   r   r>   r<   r?   s        r#   Ú_print_prettyz"DifferentialOperator._print_pretty†  sg   € Ø0�×0Ñ0°Ð@¸4Ò@ˆØ.�d×.Ñ.¨wÐ>¸Ò>ˆÜ Ø×Ñ S°ÐÓ4ð
ˆô ˜EŸK™K¨Ó4Ð5ˆØˆr%   N)r*   rb   rc   rd   r™   rÊ   rÌ   rÎ   rÐ   rÚ   rÝ   r¸   rà   r    r%   r#   r   r   ñ  sl   „ ñ'ðR ñ"ó ð"ð0 ñó ðð. ñó ðð0 ñ&ó ð&ò	0ò=ò
ór%   r   N)$rd   Útypingr   Úsympy.core.addr   Úsympy.core.exprr   Úsympy.core.functionr   r   Úsympy.core.mulr   Úsympy.core.numbersr
   rp   r   Ú sympy.printing.pretty.stringpictr   Úsympy.physics.quantum.daggerr   Úsympy.physics.quantum.kindr   Úsympy.physics.quantum.qexprr   r   Úsympy.matricesr   Úsympy.utilities.exceptionsr   Ú__all__r   r   r   r   r   r   r    r%   r#   ú<module>rî      sŽ   ðñ	õ å Ý  ß 4Ý Ý !Ý "Ý 7Ý /Ý 3ß >Ý Ý @ò€ôUˆuô Uôp$/˜ô $/ôN$�hô $ô.V�xô VôrU8�8ô U8ôp\˜8õ \r%   