§
    OŠtj:'  ã                   óú   — d Z dgZddlmZ ddlmZ ddlmZmZ ddl	m
Z
mZmZ ddlmZ ddlmZmZ dd	lmZmZ dd
lmZ ddlmZ ddlmZmZmZ ddlmZmZm Z   ej!        ee z  ¦  «        Z" G d„ de¦  «        Z#dS )zb
This module has all the classes and functions related to waves in optics.

**Contains**

* TWave
ÚTWaveé    )ÚBasic)ÚExpr)Ú
DerivativeÚFunction)ÚNumberÚpiÚI)ÚS)ÚSymbolÚsymbols)Ú_sympifyÚsympify)Úexp)Úsqrt)Úatan2ÚcosÚsin)Úspeed_of_lightÚmeterÚsecondc                   óP  — e Zd ZdZdej        d ed¦  «        fd„Zed„ ¦   «         Z	ed„ ¦   «         Z
ed„ ¦   «         Zed„ ¦   «         Zed	„ ¦   «         Zed
„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Ze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d„ ZdS )r   a4  
    This is a simple transverse sine wave travelling in a one-dimensional space.
    Basic properties are required at the time of creation of the object,
    but they can be changed later with respective methods provided.

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

    It is represented as :math:`A \times cos(k*x - \omega \times t + \phi )`,
    where :math:`A` is the amplitude, :math:`\omega` is the angular frequency,
    :math:`k` is the wavenumber (spatial frequency), :math:`x` is a spatial variable
    to represent the position on the dimension on which the wave propagates,
    and :math:`\phi` is the phase angle of the wave.


    Arguments
    =========

    amplitude : Sympifyable
        Amplitude of the wave.
    frequency : Sympifyable
        Frequency of the wave.
    phase : Sympifyable
        Phase angle of the wave.
    time_period : Sympifyable
        Time period of the wave.
    n : Sympifyable
        Refractive index of the medium.

    Raises
    =======

    ValueError : When neither frequency nor time period is provided
        or they are not consistent.
    TypeError : When anything other than TWave objects is added.


    Examples
    ========

    >>> from sympy import symbols
    >>> from sympy.physics.optics import TWave
    >>> A1, phi1, A2, phi2, f = symbols('A1, phi1, A2, phi2, f')
    >>> w1 = TWave(A1, f, phi1)
    >>> w2 = TWave(A2, f, phi2)
    >>> w3 = w1 + w2  # Superposition of two waves
    >>> w3
    TWave(sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2), f,
        atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2)), 1/f, n)
    >>> w3.amplitude
    sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)
    >>> w3.phase
    atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2))
    >>> w3.speed
    299792458*meter/(second*n)
    >>> w3.angular_velocity
    2*pi*f

    NÚnc                 ó�  — |�t          |¦  «        }t          j        |z  }|�Bt          |¦  «        }t          j        |z  }|�"|t          j        |z  k    rt          d¦  «        ‚|€|€t          d¦  «        ‚|€|}|€|}t          |¦  «        }t          |¦  «        }t	          |¦  «        }t          j        | |||||¦  «        }|S )Nz/frequency and time_period should be consistent.z*Either frequency or time period is needed.)r   r   ÚOneÚ
ValueErrorr   r   Ú__new__)	ÚclsÚ	amplitudeÚ	frequencyÚphaseÚtime_periodr   Ú
_frequencyÚ_time_periodÚobjs	            úX/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/physics/optics/waves.pyr   zTWave.__new__Y   sÙ   € ð Ð"Ý" ;Ñ/Ô/ˆKÝœ˜{Ñ*ˆJØÐ Ý  Ñ+Ô+ˆIÝœ5 ™?ˆLØÐ&Ø¥¤ kÑ 1Ò1Ð1Ý$Ð%VÑWÔWÐWØÐ Ð!4ÝÐIÑJÔJÐJØÐØ"ˆIØÐØ&ˆKå˜YÑ'Ô'ˆ	Ý˜‘”ˆÝ�A‰JŒJˆÝŒm˜C ¨I°u¸kÈ1ÑMÔMˆØˆ
ó    c                 ó   — | j         d         S )a!  
        Returns the amplitude of the wave.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.amplitude
        A
        r   ©Úargs©Úselfs    r&   r   zTWave.amplitudev   s   € ð Œy˜Œ|Ðr'   c                 ó   — | j         d         S )a?  
        Returns the frequency of the wave,
        in cycles per second.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.frequency
        f
        é   r)   r+   s    r&   r    zTWave.frequency‡   ó   € ð  Œy˜Œ|Ðr'   c                 ó   — | j         d         S )a5  
        Returns the phase angle of the wave,
        in radians.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.phase
        phi
        é   r)   r+   s    r&   r!   zTWave.phase™   r/   r'   c                 ó   — | j         d         S )aI  
        Returns the temporal period of the wave,
        in seconds per cycle.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.time_period
        1/f
        é   r)   r+   s    r&   r"   zTWave.time_period«   r/   r'   c                 ó   — | j         d         S )z<
        Returns the refractive index of the medium
        é   r)   r+   s    r&   r   zTWave.n½   s   € ð
 Œy˜Œ|Ðr'   c                 ó0   — t           | j        | j        z  z  S )aš  
        Returns the wavelength (spatial period) of the wave,
        in meters per cycle.
        It depends on the medium of the wave.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.wavelength
        299792458*meter/(second*f*n)
        )Úcr    r   r+   s    r&   Ú
wavelengthzTWave.wavelengthÄ   s   € õ" �$”. ¤Ñ'Ñ(Ð(r'   c                 ó    — | j         | j        z  S )a�  
        Returns the propagation speed of the wave,
        in meters per second.
        It is dependent on the propagation medium.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.speed
        299792458*meter/(second*n)
        )r8   r    r+   s    r&   ÚspeedzTWave.speedØ   s   € ð" Œ˜tœ~Ñ-Ð-r'   c                 ó&   — dt           z  | j        z  S )aS  
        Returns the angular velocity of the wave,
        in radians per second.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.angular_velocity
        2*pi*f
        r1   )r	   r    r+   s    r&   Úangular_velocityzTWave.angular_velocityë   s   € ð  •‰t�D”NÑ"Ð"r'   c                 ó&   — dt           z  | j        z  S )a_  
        Returns the wavenumber of the wave,
        in radians per meter.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.wavenumber
        pi*second*f*n/(149896229*meter)
        r1   )r	   r8   r+   s    r&   Ú
wavenumberzTWave.wavenumberý   s   € ð  •‰t�D”OÑ#Ð#r'   c                 óX   — ddl m} t          | ¦  «        j         || j        ¦  «        z   S )z!String representation of a TWave.r   )Ússtr)Úsympy.printingr@   ÚtypeÚ__name__r*   )r,   r@   s     r&   Ú__str__zTWave.__str__  s2   € à'Ð'Ð'Ð'Ð'Ð'Ý�D‰zŒzÔ" T T¨$¬)¡_¤_Ñ4Ð4r'   c                 ó˜  — t          |t          ¦  «        �r| j        |j        k    rò| j        |j        k    rât          t	          | j        dz  |j        dz  z   d| j        z  |j        z  t          | j        |j        z
  ¦  «        z  z   ¦  «        | j        t          | j        t          | j        ¦  «        z  |j        t          |j        ¦  «        z  z   | j        t          | j        ¦  «        z  |j        t          |j        ¦  «        z  z   ¦  «        ¦  «        S t          d¦  «        ‚t          t          |¦  «        j        dz   ¦  «        ‚)z�
        Addition of two waves will result in their superposition.
        The type of interference will depend on their phase angles.
        r1   zJInterference of waves with different frequencies has not been implemented.z# and TWave objects cannot be added.)Ú
isinstancer   r    r8   r   r   r   r!   r   r   ÚNotImplementedErrorÚ	TypeErrorrB   rC   ©r,   Úothers     r&   Ú__add__zTWave.__add__  sR  € õ
 �e�UÑ#Ô#ñ 	ZØŒ~ ¤Ò0Ð0°T´_ÈÔHXÒ5XÐ5XÝ�T $¤.°!Ñ"3°e´oÀqÑ6HÑ"HÈ1Ø"&¤.ñL1Ø16´ñLAÝADØ&*¤j°5´;Ñ&>ñB@ô B@ñL@ñ #@ñ Aô Að "œ^Ý" 4¤>µ#°d´j±/´/Ñ#AØ$œ­s°5´;Ñ/?Ô/?Ñ?ñ$@à!œ^­C°´
©O¬OÑ;Ø$œ­s°5´;Ñ/?Ô/?Ñ?ñ@ñAô Añ	ô ð õ *ð +1ñ 2ô 2ð 2õ �D ™KœKÔ0Ð3XÑXÑYÔYÐYr'   c                 óÖ   — t          |¦  «        }t          |t          ¦  «        r"t          | j        |z  g| j        dd…         ¢R Ž S t          t          |¦  «        j        dz   ¦  «        ‚)zT
        Multiplying a wave by a scalar rescales the amplitude of the wave.
        r.   Nz( and TWave objects cannot be multiplied.)	r   rF   r   r   r   r*   rH   rB   rC   rI   s     r&   Ú__mul__zTWave.__mul__,  sf   € õ ˜‘”ˆÝ�e�VÑ$Ô$ð 	_Ý˜œ¨Ñ-Ð>°´	¸!¸"¸"´Ð>Ð>Ð>Ð>å�D ™KœKÔ0Ð3]Ñ]Ñ^Ô^Ð^r'   c                 ó2   — |                       d|z  ¦  «        S ©Néÿÿÿÿ©rK   rI   s     r&   Ú__sub__zTWave.__sub__6  s   € Ø�|Š|˜B˜u™HÑ%Ô%Ð%r'   c                 ó,   — |                       d¦  «        S rO   ©rM   r+   s    r&   Ú__neg__zTWave.__neg__9  s   € Ø�|Š|˜BÑÔÐr'   c                 ó,   — |                       |¦  «        S ©NrQ   rI   s     r&   Ú__radd__zTWave.__radd__<  ó   € Ø�|Š|˜EÑ"Ô"Ð"r'   c                 ó,   — |                       |¦  «        S rW   rT   rI   s     r&   Ú__rmul__zTWave.__rmul__?  rY   r'   c                 ó.   — |                        |¦  «        S rW   )rX   rI   s     r&   Ú__rsub__zTWave.__rsub__B  s   € Ø�×Ò Ñ&Ô&Ð&r'   c                 ó´   — | j         t          | j        t          d¦  «        z  | j        t          d¦  «        z  z
  | j        z   t          dz  z   d¬¦  «        z  S )NÚxÚtr1   F)Úevaluate)r   r   r>   r   r<   r!   r	   ©r,   r*   Úkwargss      r&   Ú_eval_rewrite_as_sinzTWave._eval_rewrite_as_sinE  sf   € ØŒ~�c $¤/µ&¸±+´+Ñ"=ØÔ#¥F¨3¡K¤KÑ/ñ#0Ø26´*ñ#=Ý?AÀ!¹tñ#DØNSðUñ Uô Uñ Uð 	Ur'   c                 óš   — | j         t          | j        t          d¦  «        z  | j        t          d¦  «        z  z
  | j        z   ¦  «        z  S ©Nr_   r`   )r   r   r>   r   r<   r!   rb   s      r&   Ú_eval_rewrite_as_coszTWave._eval_rewrite_as_cosI  sL   € ØŒ~�c $¤/µ&¸±+´+Ñ"=ØÔ#¥F¨3¡K¤KÑ/ñ#0Ø26´*ñ#=ñ >ô >ñ >ð 	>r'   c                 óÂ   — t          d¦  «        \  }}}}t          d¦  «        }t           |||¦  «        |d¦  «        ||z  t           |||¦  «        |d¦  «        z  z   S )Nzmu, epsilon, x, tÚEr1   )r   r   r   )r,   r*   rc   ÚmuÚepsilonr_   r`   ri   s           r&   Ú_eval_rewrite_as_pdezTWave._eval_rewrite_as_pdeM  sd   € Ý#Ð$7Ñ8Ô8ÑˆˆG�Q˜Ý�S‰MŒMˆÝ˜!˜!˜A˜q™'œ' 1 aÑ(Ô(¨2¨g©:µjÀÀÀ1ÀaÁÄÈ!ÈQÑ6OÔ6OÑ+OÑOÐOr'   c           	      óª   — | j         t          t          | j        t	          d¦  «        z  | j        t	          d¦  «        z  z
  | j        z   z  ¦  «        z  S rf   )r   r   r
   r>   r   r<   r!   rb   s      r&   Ú_eval_rewrite_as_expzTWave._eval_rewrite_as_expR  sS   € ØŒ~�c¥! T¤_µV¸C±[´[Ñ%@ØÔ#¥F¨3¡K¤KÑ/ñ&0Ø26´*ñ&=ñ #>ñ ?ô ?ñ ?ð 	?r'   )rC   Ú
__module__Ú__qualname__Ú__doc__r   ÚZeror   r   Úpropertyr   r    r!   r"   r   r8   r:   r<   r>   rD   Ú__repr__rK   rM   rR   rU   rX   r[   r]   rd   rg   rl   rn   © r'   r&   r   r      s  € € € € € ð:ð :ð~ Ø”&ØØˆf�S‰kŒkðð ð ð ð: ðð ñ „Xðð  ðð ñ „Xðð" ðð ñ „Xðð" ðð ñ „Xðð" ðð ñ „Xðð ð)ð )ñ „Xð)ð& ð.ð .ñ „Xð.ð$ ð#ð #ñ „Xð#ð" ð$ð $ñ „Xð$ð"5ð 5ð 5ð
 €HðZð Zð Zð,_ð _ð _ð&ð &ð &ð ð  ð  ð#ð #ð #ð#ð #ð #ð'ð 'ð 'ðUð Uð Uð>ð >ð >ðPð Pð Pð
?ð ?ð ?ð ?ð ?r'   N)$rq   Ú__all__Úsympy.core.basicr   Úsympy.core.exprr   Úsympy.core.functionr   r   Úsympy.core.numbersr   r	   r
   Úsympy.core.singletonr   Úsympy.core.symbolr   r   Úsympy.core.sympifyr   r   Ú&sympy.functions.elementary.exponentialr   Ú(sympy.functions.elementary.miscellaneousr   Ú(sympy.functions.elementary.trigonometricr   r   r   Úsympy.physics.unitsr   r   r   Ú
convert_tor7   r   ru   r'   r&   ú<module>rƒ      sj  ððð ð ˆ)€à "Ð "Ð "Ð "Ð "Ð "Ø  Ð  Ð  Ð  Ð  Ð  Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø "Ð "Ð "Ð "Ð "Ð "Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =ð €NÔ˜e F™lÑ+Ô+€ðy?ð y?ð y?ð y?ð y?ˆDñ y?ô y?ð y?ð y?ð y?r'   