§
    OŠtj¢Q  ã                   ó°  — d Z g d¢ZddlmZ ddlmZ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mZ dd
lmZ ddlm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 G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Zd&d„Z d „ Z!d!„ Z"d"„ Z#e#Z$d#„ Z%d$„ Z&d%S )'aÜ  
Gaussian optics.

The module implements:

- Ray transfer matrices for geometrical and gaussian optics.

  See RayTransferMatrix, GeometricRay and BeamParameter

- Conjugation relations for geometrical and gaussian optics.

  See geometric_conj*, gauss_conj and conjugate_gauss_beams

The conventions for the distances are as follows:

focal distance
    positive for convergent lenses
object distance
    positive for real objects
image distance
    positive for real images
)ÚRayTransferMatrixÚ	FreeSpaceÚFlatRefractionÚCurvedRefractionÚ
FlatMirrorÚCurvedMirrorÚThinLensÚGeometricRayÚBeamParameterÚwaist2rayleighÚrayleigh2waistÚgeometric_conj_abÚgeometric_conj_afÚgeometric_conj_bfÚgaussian_conjÚconjugate_gauss_beamsé    )ÚExpr)ÚIÚpi)Úsympify)ÚimÚre)Úsqrt)Úatan2)ÚMatrixÚMutableDenseMatrix)Útogether)Ú
filldedentc                   óv   — e Zd ZdZd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
dS )	r   aÞ  
    Base class for a Ray Transfer Matrix.

    It should be used if there is not already a more specific subclass mentioned
    in See Also.

    Parameters
    ==========

    parameters :
        A, B, C and D or 2x2 matrix (Matrix(2, 2, [A, B, C, D]))

    Examples
    ========

    >>> from sympy.physics.optics import RayTransferMatrix, ThinLens
    >>> from sympy import Symbol, Matrix

    >>> mat = RayTransferMatrix(1, 2, 3, 4)
    >>> mat
    Matrix([
    [1, 2],
    [3, 4]])

    >>> RayTransferMatrix(Matrix([[1, 2], [3, 4]]))
    Matrix([
    [1, 2],
    [3, 4]])

    >>> mat.A
    1

    >>> f = Symbol('f')
    >>> lens = ThinLens(f)
    >>> lens
    Matrix([
    [   1, 0],
    [-1/f, 1]])

    >>> lens.C
    -1/f

    See Also
    ========

    GeometricRay, BeamParameter,
    FreeSpace, FlatRefraction, CurvedRefraction,
    FlatMirror, CurvedMirror, ThinLens

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Ray_transfer_matrix_analysis
    c                 ó|  — t          |¦  «        dk    r!|d         |d         f|d         |d         ff}ntt          |¦  «        dk    r5t          |d         t          ¦  «        r|d         j        dk    r	|d         }n,t	          t          dt          |¦  «        z  ¦  «        ¦  «        ‚t          j        | |¦  «        S )Né   r   é   é   é   )r#   r#   z`
                Expecting 2x2 Matrix or the 4 elements of
                the Matrix but got %s©ÚlenÚ
isinstancer   ÚshapeÚ
ValueErrorr   ÚstrÚ__new__©ÚclsÚargsÚtemps      ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/physics/optics/gaussopt.pyr+   zRayTransferMatrix.__new__s   s½   € åˆt‰9Œ9˜Š>ˆ>Ø˜!”W˜d 1œgÐ&¨¨a¬°$°q´'Ð(:Ð;ˆDˆDÝ�‰YŒY˜!Š^ˆ^Ý˜4 œ7¥FÑ+Ô+ð à˜”G”M VÒ+Ð+Ø˜”7ˆDˆDå�Zð ))å+.¨t©9¬9ñ)5ñ 6ô 6ñ 7ô 7ð 7õ Œ~˜c 4Ñ(Ô(Ð(ó    c           	      óˆ  — t          |t          ¦  «        r,t          t          | ¦  «        t          |¦  «        z  ¦  «        S t          |t          ¦  «        r,t          t          | ¦  «        t          |¦  «        z  ¦  «        S t          |t          ¦  «        r—t          | ¦  «        t          |j        fdf¦  «        z  }|d         |d         z                       d¬¦  «        }t	          |j        t          t          |¦  «        ¦  «        t          t          |¦  «        ¦  «        ¬¦  «        S t          j        | |¦  «        S )N©r"   r   r"   T)Úcomplex)Úz_r)r'   r   r   r	   r
   ÚqÚexpandÚwavelenr   r   r   Ú__mul__)ÚselfÚotherr/   r6   s       r0   r9   zRayTransferMatrix.__mul__�   s  € Ý�eÕ.Ñ/Ô/ð 	/Ý$¥V¨D¡\¤\µ&¸±-´-Ñ%?Ñ@Ô@Ð@Ý˜�|Ñ,Ô,ð 		/Ý¥ t¡¤­V°E©]¬]Ñ :Ñ;Ô;Ð;Ý˜�}Ñ-Ô-ð 	/Ý˜$‘<”<¥¨¬¨
°DÐ'9Ñ :Ô :Ñ:ˆDØ�a”˜˜aœ‘×(Ò(°Ð(Ñ6Ô6ˆAÝ  ¤Ý!)­"¨Q©%¬%¡¤Ý%-­b°©e¬e¡_¤_ð6ñ 6ô 6ð 6õ ”> $¨Ñ.Ô.Ð.r1   c                 ó   — | d         S )zß
        The A parameter of the Matrix.

        Examples
        ========

        >>> from sympy.physics.optics import RayTransferMatrix
        >>> mat = RayTransferMatrix(1, 2, 3, 4)
        >>> mat.A
        1
        )r   r   © ©r:   s    r0   ÚAzRayTransferMatrix.A�   ó   € ð �DŒzÐr1   c                 ó   — | d         S )zß
        The B parameter of the Matrix.

        Examples
        ========

        >>> from sympy.physics.optics import RayTransferMatrix
        >>> mat = RayTransferMatrix(1, 2, 3, 4)
        >>> mat.B
        2
        )r   r"   r=   r>   s    r0   ÚBzRayTransferMatrix.Bž   r@   r1   c                 ó   — | d         S )zß
        The C parameter of the Matrix.

        Examples
        ========

        >>> from sympy.physics.optics import RayTransferMatrix
        >>> mat = RayTransferMatrix(1, 2, 3, 4)
        >>> mat.C
        3
        )r"   r   r=   r>   s    r0   ÚCzRayTransferMatrix.C­   r@   r1   c                 ó   — | d         S )zß
        The D parameter of the Matrix.

        Examples
        ========

        >>> from sympy.physics.optics import RayTransferMatrix
        >>> mat = RayTransferMatrix(1, 2, 3, 4)
        >>> mat.D
        4
        )r"   r"   r=   r>   s    r0   ÚDzRayTransferMatrix.D¼   r@   r1   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+   r9   Úpropertyr?   rB   rD   rF   r=   r1   r0   r   r   ;   s©   € € € € € ð5ð 5ðn)ð )ð )ð/ð /ð /ð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ð r1   r   c                   ó   — e Zd ZdZd„ ZdS )r   aQ  
    Ray Transfer Matrix for free space.

    Parameters
    ==========

    distance

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import FreeSpace
    >>> from sympy import symbols
    >>> d = symbols('d')
    >>> FreeSpace(d)
    Matrix([
    [1, d],
    [0, 1]])
    c                 ó>   — t                                | d|dd¦  «        S ©Nr"   r   ©r   r+   )r-   Úds     r0   r+   zFreeSpace.__new__å   ó   € Ý ×(Ò(¨¨a°°A°qÑ9Ô9Ð9r1   N©rG   rH   rI   rJ   r+   r=   r1   r0   r   r   Ì   s-   € € € € € ðð ð0:ð :ð :ð :ð :r1   r   c                   ó   — e Zd ZdZd„ ZdS )r   aÈ  
    Ray Transfer Matrix for refraction.

    Parameters
    ==========

    n1 :
        Refractive index of one medium.
    n2 :
        Refractive index of other medium.

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import FlatRefraction
    >>> from sympy import symbols
    >>> n1, n2 = symbols('n1 n2')
    >>> FlatRefraction(n1, n2)
    Matrix([
    [1,     0],
    [0, n1/n2]])
    c                 óx   — t          t          ||f¦  «        \  }}t                               | ddd||z  ¦  «        S rN   ©Úmapr   r   r+   )r-   Ún1Ún2s      r0   r+   zFlatRefraction.__new__  s9   € Ý•W˜r 2˜hÑ'Ô'‰ˆˆBÝ ×(Ò(¨¨a°°A°r¸"±uÑ=Ô=Ð=r1   NrR   r=   r1   r0   r   r   é   s-   € € € € € ðð ð6>ð >ð >ð >ð >r1   r   c                   ó   — e Zd ZdZd„ ZdS )r   aB  
    Ray Transfer Matrix for refraction on curved interface.

    Parameters
    ==========

    R :
        Radius of curvature (positive for concave).
    n1 :
        Refractive index of one medium.
    n2 :
        Refractive index of other medium.

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import CurvedRefraction
    >>> from sympy import symbols
    >>> R, n1, n2 = symbols('R n1 n2')
    >>> CurvedRefraction(R, n1, n2)
    Matrix([
    [               1,     0],
    [(n1 - n2)/(R*n2), n1/n2]])
    c                 óŽ   — t          t          |||f¦  «        \  }}}t                               | dd||z
  |z  |z  ||z  ¦  «        S rN   rU   )r-   ÚRrW   rX   s       r0   r+   zCurvedRefraction.__new__(  sI   € Ý� ! R¨ Ñ-Ô-‰	ˆˆ2ˆrÝ ×(Ò(¨¨a°°R¸"±W¸a±KÀ±NÀBÀrÁEÑJÔJÐJr1   NrR   r=   r1   r0   r   r   
  s2   € € € € € ðð ð:Kð Kð Kð Kð Kr1   r   c                   ó   — e Zd ZdZd„ ZdS )r   zê
    Ray Transfer Matrix for reflection.

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import FlatMirror
    >>> FlatMirror()
    Matrix([
    [1, 0],
    [0, 1]])
    c                 ó>   — t                                | dddd¦  «        S rN   rO   )r-   s    r0   r+   zFlatMirror.__new__?  rQ   r1   NrR   r=   r1   r0   r   r   -  s-   € € € € € ðð ð":ð :ð :ð :ð :r1   r   c                   ó   — e Zd ZdZd„ ZdS )r   a—  
    Ray Transfer Matrix for reflection from curved surface.

    Parameters
    ==========

    R : radius of curvature (positive for concave)

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import CurvedMirror
    >>> from sympy import symbols
    >>> R = symbols('R')
    >>> CurvedMirror(R)
    Matrix([
    [   1, 0],
    [-2/R, 1]])
    c                 ób   — t          |¦  «        }t                               | ddd|z  d¦  «        S )Nr"   r   éþÿÿÿ©r   r   r+   )r-   r[   s     r0   r+   zCurvedMirror.__new__\  ó-   € Ý�A‰JŒJˆÝ ×(Ò(¨¨a°°B°q±D¸!Ñ<Ô<Ð<r1   NrR   r=   r1   r0   r   r   C  s-   € € € € € ðð ð0=ð =ð =ð =ð =r1   r   c                   ó   — e Zd ZdZd„ ZdS )r   am  
    Ray Transfer Matrix for a thin lens.

    Parameters
    ==========

    f :
        The focal distance.

    See Also
    ========

    RayTransferMatrix

    Examples
    ========

    >>> from sympy.physics.optics import ThinLens
    >>> from sympy import symbols
    >>> f = symbols('f')
    >>> ThinLens(f)
    Matrix([
    [   1, 0],
    [-1/f, 1]])
    c                 ób   — t          |¦  «        }t                               | ddd|z  d¦  «        S )Nr"   r   éÿÿÿÿra   )r-   Úfs     r0   r+   zThinLens.__new__{  rb   r1   NrR   r=   r1   r0   r   r   a  s-   € € € € € ðð ð2=ð =ð =ð =ð =r1   r   c                   óD   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         ZdS )r	   aÂ  
    Representation for a geometric ray in the Ray Transfer Matrix formalism.

    Parameters
    ==========

    h : height, and
    angle : angle, or
    matrix : a 2x1 matrix (Matrix(2, 1, [height, angle]))

    Examples
    ========

    >>> from sympy.physics.optics import GeometricRay, FreeSpace
    >>> from sympy import symbols, Matrix
    >>> d, h, angle = symbols('d, h, angle')

    >>> GeometricRay(h, angle)
    Matrix([
    [    h],
    [angle]])

    >>> FreeSpace(d)*GeometricRay(h, angle)
    Matrix([
    [angle*d + h],
    [      angle]])

    >>> GeometricRay( Matrix( ((h,), (angle,)) ) )
    Matrix([
    [    h],
    [angle]])

    See Also
    ========

    RayTransferMatrix

    c                 ó`  — t          |¦  «        dk    r5t          |d         t          ¦  «        r|d         j        dk    r	|d         }nRt          |¦  «        dk    r|d         f|d         ff}n,t	          t          dt          |¦  «        z  ¦  «        ¦  «        ‚t          j        | |¦  «        S )Nr"   r   )r#   r"   r#   z`
                Expecting 2x1 Matrix or the 2 elements of
                the Matrix but got %sr%   r,   s      r0   r+   zGeometricRay.__new__¬  s«   € Ýˆt‰9Œ9˜Š>ˆ>�j¨¨a¬µ&Ñ9Ô9ˆ>Ø˜”G”M VÒ+Ð+Ø˜”7ˆDˆDÝ�‰YŒY˜!Š^ˆ^Ø˜!”W�J  a¤ 
Ð+ˆDˆDå�Zð ))å+.¨t©9¬9ñ)5ñ 6ô 6ñ 7ô 7ð 7õ Œ~˜c 4Ñ(Ô(Ð(r1   c                 ó   — | d         S )a0  
        The distance from the optical axis.

        Examples
        ========

        >>> from sympy.physics.optics import GeometricRay
        >>> from sympy import symbols
        >>> h, angle = symbols('h, angle')
        >>> gRay = GeometricRay(h, angle)
        >>> gRay.height
        h
        r   r=   r>   s    r0   ÚheightzGeometricRay.height¸  ó   € ð �AŒwˆr1   c                 ó   — | d         S )a0  
        The angle with the optical axis.

        Examples
        ========

        >>> from sympy.physics.optics import GeometricRay
        >>> from sympy import symbols
        >>> h, angle = symbols('h, angle')
        >>> gRay = GeometricRay(h, angle)
        >>> gRay.angle
        angle
        r"   r=   r>   s    r0   ÚanglezGeometricRay.angleÉ  rk   r1   N)rG   rH   rI   rJ   r+   rK   rj   rm   r=   r1   r0   r	   r	   „  sd   € € € € € ð%ð %ðN
)ð 
)ð 
)ð ðð ñ „Xðð  ðð ñ „Xðð ð r1   r	   c                   ó  — e Zd ZdZd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ed„ ¦   «         Zed„ ¦   «         ZdS )r
   a²  
    Representation for a gaussian ray in the Ray Transfer Matrix formalism.

    Parameters
    ==========

    wavelen : the wavelength,
    z : the distance to waist, and
    w : the waist, or
    z_r : the rayleigh range.
    n : the refractive index of medium.

    Examples
    ========

    >>> from sympy.physics.optics import BeamParameter
    >>> p = BeamParameter(530e-9, 1, w=1e-3)
    >>> p.q
    1 + 1.88679245283019*I*pi

    >>> p.q.n()
    1.0 + 5.92753330865999*I
    >>> p.w_0.n()
    0.00100000000000000
    >>> p.z_r.n()
    5.92753330865999

    >>> from sympy.physics.optics import FreeSpace
    >>> fs = FreeSpace(10)
    >>> p1 = fs*p
    >>> p.w.n()
    0.00101413072159615
    >>> p1.w.n()
    0.00210803120913829

    See Also
    ========

    RayTransferMatrix

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Complex_beam_parameter
    .. [2] https://en.wikipedia.org/wiki/Gaussian_beam
    Nr"   c                 ó   — t          |¦  «        }t          |¦  «        }t          |¦  «        }|�|€t          |¦  «        }n6|�!|€t          t          |¦  «        ||¦  «        }n|€|€t          d¦  «        ‚t          j        | ||||¦  «        S )NzMust specify one of w and z_r.)r   r   r)   r   r+   )r-   r8   Úzr5   ÚwÚns         r0   r+   zBeamParameter.__new__  s�   € Ý˜'Ñ"Ô"ˆÝ�A‰JŒJˆÝ�A‰JŒJˆàˆ?˜q˜yÝ˜#‘,”,ˆCˆCØˆ]˜s˜{Ý ¥¨¡¤¨W°aÑ8Ô8ˆCˆCØˆ[˜Q˜YÝÐ=Ñ>Ô>Ð>åŒ|˜C ¨!¨S°!Ñ4Ô4Ð4r1   c                 ó   — | j         d         S )Nr   ©r.   r>   s    r0   r8   zBeamParameter.wavelen   ó   € àŒy˜Œ|Ðr1   c                 ó   — | j         d         S )Nr"   rt   r>   s    r0   rp   zBeamParameter.z$  ru   r1   c                 ó   — | j         d         S )Nr#   rt   r>   s    r0   r5   zBeamParameter.z_r(  ru   r1   c                 ó   — | j         d         S )Nr$   rt   r>   s    r0   rr   zBeamParameter.n,  ru   r1   c                 ó0   — | j         t          | j        z  z   S )a   
        The complex parameter representing the beam.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.q
        1 + 1.88679245283019*I*pi
        )rp   r   r5   r>   s    r0   r6   zBeamParameter.q0  s   € ð Œv�˜$œ(™
Ñ"Ð"r1   c                 ó<   — | j         d| j        | j         z  dz  z   z  S )a  
        The radius of curvature of the phase front.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.radius
        1 + 3.55998576005696*pi**2
        r"   r#   )rp   r5   r>   s    r0   ÚradiuszBeamParameter.radius?  s#   € ð Œv�q˜DœH T¤V™O¨aÑ/Ñ/Ñ0Ð0r1   c                 óV   — | j         t          d| j        | j        z  dz  z   ¦  «        z  S )a«  
        The radius of the beam w(z), at any position z along the beam.
        The beam radius at `1/e^2` intensity (axial value).

        See Also
        ========

        w_0 :
            The minimal radius of beam.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.w
        0.001*sqrt(0.2809/pi**2 + 1)
        r"   r#   )Úw_0r   rp   r5   r>   s    r0   rq   zBeamParameter.wN  s+   € ð( Œx�˜Q $¤&¨¬¡/°AÑ!5Ñ5Ñ6Ô6Ñ6Ð6r1   c                 óZ   — t          | j        t          | j        z  z  | j        z  ¦  «        S )ar  
         The minimal radius of beam at `1/e^2` intensity (peak value).

        See Also
        ========

        w : the beam radius at `1/e^2` intensity (axial value).

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.w_0
        0.00100000000000000
        )r   r5   r   rr   r8   r>   s    r0   r}   zBeamParameter.w_0d  s&   € õ$ �D”H�b ¤™iÑ(¨¬Ñ5Ñ6Ô6Ð6r1   c                 ó0   — | j         t          z  | j        z  S )zï
        Half of the total angular spread.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.divergence
        0.00053/pi
        )r8   r   r}   r>   s    r0   Ú
divergencezBeamParameter.divergencex  s   € ð Œ|�B‰˜tœxÑ'Ð'r1   c                 ó6   — t          | j        | j        ¦  «        S )zÚ
        The Gouy phase.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.gouy
        atan(0.53/pi)
        )r   rp   r5   r>   s    r0   ÚgouyzBeamParameter.gouy‡  s   € õ �T”V˜TœXÑ&Ô&Ð&r1   c                 ó&   — d| j         z  t          z  S )aÓ  
        The minimal waist for which the gauss beam approximation is valid.

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

        The gauss beam is a solution to the paraxial equation. For curvatures
        that are too great it is not a valid approximation.

        Examples
        ========

        >>> from sympy.physics.optics import BeamParameter
        >>> p = BeamParameter(530e-9, 1, w=1e-3)
        >>> p.waist_approximation_limit
        1.06e-6/pi
        r#   )r8   r   r>   s    r0   Úwaist_approximation_limitz'BeamParameter.waist_approximation_limit–  s   € ð& �”‰~�bÑ Ð r1   )NNr"   )rG   rH   rI   rJ   r+   rK   r8   rp   r5   rr   r6   r{   rq   r}   r€   r‚   r„   r=   r1   r0   r
   r
   ß  s\  € € € € € ð-ð -ðd5ð 5ð 5ð 5ð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ð#ð #ñ „Xð#ð ð1ð 1ñ „Xð1ð ð7ð 7ñ „Xð7ð* ð7ð 7ñ „Xð7ð& ð(ð (ñ „Xð(ð ð'ð 'ñ „Xð'ð ð!ð !ñ „Xð!ð !ð !r1   r
   r"   c                 ó\   — t          t          | |f¦  «        \  } }| dz  |z  t          z  |z  S )a^  
    Calculate the rayleigh range from the waist of a gaussian beam.

    See Also
    ========

    rayleigh2waist, BeamParameter

    Examples
    ========

    >>> from sympy.physics.optics import waist2rayleigh
    >>> from sympy import symbols
    >>> w, wavelen = symbols('w wavelen')
    >>> waist2rayleigh(w, wavelen)
    pi*w**2/wavelen
    r#   )rV   r   r   )rq   r8   rr   s      r0   r   r   °  s2   € õ$ •W˜q '˜lÑ+Ô+�J€A€wØˆa‰4�‰6•"‰9�WÑÐr1   c                 ój   — t          t          | |f¦  «        \  } }t          | t          z  |z  ¦  «        S )aj  Calculate the waist from the rayleigh range of a gaussian beam.

    See Also
    ========

    waist2rayleigh, BeamParameter

    Examples
    ========

    >>> from sympy.physics.optics import rayleigh2waist
    >>> from sympy import symbols
    >>> z_r, wavelen = symbols('z_r wavelen')
    >>> rayleigh2waist(z_r, wavelen)
    sqrt(wavelen*z_r)/sqrt(pi)
    )rV   r   r   r   )r5   r8   s     r0   r   r   Æ  s1   € õ" •w  g Ñ/Ô/�L€CˆÝ�•B‘�w‘ÑÔÐr1   c                 ó~   — t          t          | |f¦  «        \  } }| j        s|j        r|j        r| n|S | |z  | |z   z  S )a×  
    Conjugation relation for geometrical beams under paraxial conditions.

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

    Takes the distances to the optical element and returns the needed
    focal distance.

    See Also
    ========

    geometric_conj_af, geometric_conj_bf

    Examples
    ========

    >>> from sympy.physics.optics import geometric_conj_ab
    >>> from sympy import symbols
    >>> a, b = symbols('a b')
    >>> geometric_conj_ab(a, b)
    a*b/(a + b)
    )rV   r   Úis_infinite)ÚaÚbs     r0   r   r   Û  sQ   € õ0 �w˜˜A˜ÑÔ�D€A€qØ„}ð ˜œð Ø”MÐ(ˆqˆq qÐ(à�‰s�A˜‘E‰{Ðr1   c                 óZ   — t          t          | |f¦  «        \  } }t          | | ¦  «         S )a‘  
    Conjugation relation for geometrical beams under paraxial conditions.

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

    Takes the object distance (for geometric_conj_af) or the image distance
    (for geometric_conj_bf) to the optical element and the focal distance.
    Then it returns the other distance needed for conjugation.

    See Also
    ========

    geometric_conj_ab

    Examples
    ========

    >>> from sympy.physics.optics.gaussopt import geometric_conj_af, geometric_conj_bf
    >>> from sympy import symbols
    >>> a, b, f = symbols('a b f')
    >>> geometric_conj_af(a, f)
    a*f/(a - f)
    >>> geometric_conj_bf(b, f)
    b*f/(b - f)
    )rV   r   r   )r‰   rf   s     r0   r   r   ú  s0   € õ6 �w˜˜A˜ÑÔ�D€A€qÝ˜a ! Ñ$Ô$Ð$Ð$r1   c                 óî   — t          t          | ||f¦  «        \  } }}dd| |dz  | |z
  z  z   z  d|z  z   z  }dt          d| |z  dz  z
  ||z  dz  z   ¦  «        z  }|d| |z  dz  z
  ||z  dz  z   z  }|||fS )aÕ  
    Conjugation relation for gaussian beams.

    Parameters
    ==========

    s_in :
        The distance to optical element from the waist.
    z_r_in :
        The rayleigh range of the incident beam.
    f :
        The focal length of the optical element.

    Returns
    =======

    a tuple containing (s_out, z_r_out, m)
    s_out :
        The distance between the new waist and the optical element.
    z_r_out :
        The rayleigh range of the emergent beam.
    m :
        The ration between the new and the old waists.

    Examples
    ========

    >>> from sympy.physics.optics import gaussian_conj
    >>> from sympy import symbols
    >>> s_in, z_r_in, f = symbols('s_in z_r_in f')

    >>> gaussian_conj(s_in, z_r_in, f)[0]
    1/(-1/(s_in + z_r_in**2/(-f + s_in)) + 1/f)

    >>> gaussian_conj(s_in, z_r_in, f)[1]
    z_r_in/(1 - s_in**2/f**2 + z_r_in**2/f**2)

    >>> gaussian_conj(s_in, z_r_in, f)[2]
    1/sqrt(1 - s_in**2/f**2 + z_r_in**2/f**2)
    r"   re   r#   )rV   r   r   )Ús_inÚz_r_inrf   Ús_outÚmÚz_r_outs         r0   r   r     s¦   € õR �' D¨&°!Ð#4Ñ5Ô5�O€Dˆ&�!Ø�"�d˜V Q™Y¨¨q©Ñ1Ñ1Ñ2°Q°q±SÑ8Ñ:€EØ	�$��T˜!‘V˜a‘K‘ F¨1¡H¨q¡=Ñ0Ñ
1Ô
1Ñ1€AØ˜˜d 1™f q™[™¨V°A©X¸©MÑ9Ñ:€GØ�7˜AÐÐr1   c                 ó  — t          t          | ||f¦  «        \  } }}||z  }t          || ¦  «        }t          |¦  «        dk    rt	          d¦  «        ‚d|v rt          t          d¦  «        ¦  «        ‚d|v rTt          |d         ¦  «        }|dt          d|dz  z  |dz  |dz  z  z
  ¦  «        z
  z  }t          |||¦  «        d         }n<d|v rt          t          d¦  «        ¦  «        ‚t	          t          d	¦  «        ¦  «        ‚|||fS )
a  
    Find the optical setup conjugating the object/image waists.

    Parameters
    ==========

    wavelen :
        The wavelength of the beam.
    waist_in and waist_out :
        The waists to be conjugated.
    f :
        The focal distance of the element used in the conjugation.

    Returns
    =======

    a tuple containing (s_in, s_out, f)
    s_in :
        The distance before the optical element.
    s_out :
        The distance after the optical element.
    f :
        The focal distance of the optical element.

    Examples
    ========

    >>> from sympy.physics.optics import conjugate_gauss_beams
    >>> from sympy import symbols, factor
    >>> l, w_i, w_o, f = symbols('l w_i w_o f')

    >>> conjugate_gauss_beams(l, w_i, w_o, f=f)[0]
    f*(1 - sqrt(w_i**2/w_o**2 - pi**2*w_i**4/(f**2*l**2)))

    >>> factor(conjugate_gauss_beams(l, w_i, w_o, f=f)[1])
    f*w_o**2*(w_i**2/w_o**2 - sqrt(w_i**2/w_o**2 -
              pi**2*w_i**4/(f**2*l**2)))/w_i**2

    >>> conjugate_gauss_beams(l, w_i, w_o, f=f)[2]
    f
    r"   z,The function expects only one named argumentÚdistzD
            Currently only focal length is supported as a parameterrf   r#   r   r�   zG
            The functions expects the focal length as a named argument)	rV   r   r   r&   r)   ÚNotImplementedErrorr   r   r   )	r8   Úwaist_inÚ	waist_outÚkwargsr�   rp   rf   r�   r�   s	            r0   r   r   K  s]  € õV $'¥w°¸(ÀIÐ0NÑ#OÔ#OÑ €GˆX�yØ�HÑ€AÝ�x Ñ)Ô)€AÝ
ˆ6�{„{�aÒÐÝÐGÑHÔHÐHØ	�6Ð	Ð	Ý!¥*ð .Gñ #Hô #Hñ Iô Ið 	Ià	�ˆˆÝ�F˜3”KÑ Ô ˆØ�A�˜Q˜q !™t™V a¨¡d¨1¨a©4¡iÑ/Ñ0Ô0Ñ0Ñ1ˆÝ˜d A qÑ)Ô)¨!Ô,ˆˆØ	�6Ð	Ð	Ý!¥*ð .Gñ #Hô #Hñ Iô Ið 	Iõ �ð %Jñ Kô Kñ Lô Lð 	Là�%˜ÐÐr1   Nr3   )'rJ   Ú__all__Úsympy.core.exprr   Úsympy.core.numbersr   r   Úsympy.core.sympifyr   Ú$sympy.functions.elementary.complexesr   r   Ú(sympy.functions.elementary.miscellaneousr   Ú(sympy.functions.elementary.trigonometricr   Úsympy.matrices.denser   r   Úsympy.polys.rationaltoolsr   Úsympy.utilities.miscr   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r=   r1   r0   ú<module>r¢      sð  ððð ð.ð ð €ð( !Ð  Ð  Ð  Ð  Ð  Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø &Ð &Ð &Ð &Ð &Ð &Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø :Ð :Ð :Ð :Ð :Ð :Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø .Ð .Ð .Ð .Ð .Ð .Ø +Ð +Ð +Ð +Ð +Ð +ðNð Nð Nð Nð NÐ*ñ Nô Nð Nðb:ð :ð :ð :ð :Ð!ñ :ô :ð :ð:>ð >ð >ð >ð >Ð&ñ >ô >ð >ðB Kð  Kð  Kð  Kð  KÐ(ñ  Kô  Kð  KðF:ð :ð :ð :ð :Ð"ñ :ô :ð :ð,=ð =ð =ð =ð =Ð$ñ =ô =ð =ð<=ð =ð =ð =ð =Ð ñ =ô =ð =ðFTð Tð Tð Tð TÐ%ñ Tô Tð TðvJ!ð J!ð J!ð J!ð J!�Dñ J!ô J!ð J!ðbð ð ð ð, ð  ð  ð*ð ð ð>%ð %ð %ð< &Ð ð-ð -ð -ð`=ð =ð =ð =ð =r1   