o
    !ôj0 ã                   @   sÆ  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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mZ d dlmZ d dlmZmZ d dl m!Z!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,m-Z- d dl.m/Z/m0Z0m1Z1m2Z2m3Z3 d dl4m5Z5m6Z6m7Z7 d dl8m9Z9 d dl:m;Z; d dl<m=Z=m>Z> G dd„ deƒZ?G dd„ de?ƒZ@G dd„ de?ƒZAG dd„ de?ƒZBG dd„ de?ƒZCG d d!„ d!e?ƒZDG d"d#„ d#e?ƒZEd$d%„ ZFG d&d'„ d'e?ƒZGd(d)„ ZHd*d+„ ZIG d,d-„ d-eGƒZJG d.d/„ d/eGƒZKG d0d1„ d1eGƒZLG d2d3„ d3eLƒZMG d4d5„ d5eLƒZNdKd8d9„ZOG d:d;„ d;eƒZPG d<d=„ d=ePƒZQG d>d?„ d?ePƒZRG d@dA„ dAePƒZSG dBdC„ dCePƒZTG dDdE„ dEeƒZUG dFdG„ dGeƒZVG dHdI„ dIeƒZWdJS )Lé    ©Úwraps)ÚS)ÚAdd)Úcacheit)ÚExpr)ÚDefinedFunctionÚArgumentIndexErrorÚ_mexpand)Úfuzzy_orÚ	fuzzy_not)ÚRationalÚpiÚI)ÚPow)ÚDummyÚuniquely_named_symbolÚWild)Úsympify)Ú	factorialÚRisingFactorial)ÚsinÚcosÚcscÚcot)Úceiling)ÚexpÚlog)ÚcbrtÚsqrtÚroot)ÚAbsÚreÚimÚ
polar_liftÚ
unpolarify)ÚgammaÚdigammaÚ
uppergamma)Úhyper)Úspherical_bessel_fn)ÚmpÚworkprecc                   @   s^   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZdd	d
„Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )Ú
BesselBaseað  
    Abstract base class for Bessel-type functions.

    This class is meant to reduce code duplication.
    All Bessel-type functions can 1) be differentiated, with the derivatives
    expressed in terms of similar functions, and 2) be rewritten in terms
    of other Bessel-type functions.

    Here, Bessel-type functions are assumed to have one complex parameter.

    To use this base class, define class attributes ``_a`` and ``_b`` such that
    ``2*F_n' = -_a*F_{n+1} + b*F_{n-1}``.

    c                 C   ó
   | j d S )z( The order of the Bessel-type function. r   ©Úargs©Úself© r3   úq/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/sympy/functions/special/bessel.pyÚorder4   ó   
zBesselBase.orderc                 C   r.   )z+ The argument of the Bessel-type function. é   r/   r1   r3   r3   r4   Úargument9   r6   zBesselBase.argumentc                 C   s   d S ©Nr3   ©ÚclsÚnuÚzr3   r3   r4   Úeval>   s   zBesselBase.evalé   c                 C   sN   |dkr	t | |ƒ‚| jd |  | jd | j¡ | jd |  | jd | j¡  S ©Nr?   r7   )r	   Ú_bÚ	__class__r5   r8   Ú_a©r2   Úargindexr3   r3   r4   ÚfdiffB   s
   
ÿzBesselBase.fdiffc                 C   s*   | j }|jdu r|  | j ¡ | ¡ ¡S d S ©NF)r8   Úis_extended_negativerB   r5   Ú	conjugate©r2   r=   r3   r3   r4   Ú_eval_conjugateH   s   
ÿzBesselBase._eval_conjugatec                 C   sx   | j | j}}| |¡rdS | ||¡sd S | ||¡}|jr2t| ttt	t
ttfƒs-|js2t|jƒS tt|j|jgƒƒS rG   )r5   r8   ÚhasÚ_eval_is_meromorphicÚsubsÚ
is_integerÚ
isinstanceÚbesseljÚbesseliÚhn1Úhn2ÚjnÚynÚis_zeror   Úis_infiniter   )r2   ÚxÚar<   r=   Úz0r3   r3   r4   rM   M   s   

zBesselBase._eval_is_meromorphicc                 K   sÂ   | j | j| j}}}|jr_|d jr7| j | j ||d |ƒ ¡  d| j |d  ||d |ƒ ¡  |  S |d jr_d| j |d  ||d |ƒ ¡  | | j| j ||d |ƒ ¡   S | S ©Nr7   r?   )	r5   r8   rB   Úis_realÚis_positiverC   rA   Ú_eval_expand_funcÚis_negative)r2   Úhintsr<   r=   Úfr3   r3   r4   r_   Z   s   
&ÿ
&ÿzBesselBase._eval_expand_funcc                 K   s   ddl m} || ƒS )Nr   )Ú
besselsimp)Úsympy.simplify.simplifyrc   )r2   Úkwargsrc   r3   r3   r4   Ú_eval_simplifye   s   zBesselBase._eval_simplifyN©r?   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr5   r8   Úclassmethodr>   rF   rK   rM   r_   rf   r3   r3   r3   r4   r-   $   s    



r-   c                       óf   e Zd ZdZejZejZedd„ ƒZ	dd„ Z
dd„ Zdd	„ Z‡ fd
d„Zdd„ Zd‡ fdd„	Z‡  ZS )rQ   a4  
    Bessel function of the first kind.

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

    The Bessel $J$ function of order $\nu$ is defined to be the function
    satisfying Bessel's differential equation

    .. math ::
        z^2 \frac{\mathrm{d}^2 w}{\mathrm{d}z^2}
        + z \frac{\mathrm{d}w}{\mathrm{d}z} + (z^2 - \nu^2) w = 0,

    with Laurent expansion

    .. math ::
        J_\nu(z) = z^\nu \left(\frac{1}{\Gamma(\nu + 1) 2^\nu} + O(z^2) \right),

    if $\nu$ is not a negative integer. If $\nu=-n \in \mathbb{Z}_{<0}$
    *is* a negative integer, then the definition is

    .. math ::
        J_{-n}(z) = (-1)^n J_n(z).

    Examples
    ========

    Create a Bessel function object:

    >>> from sympy import besselj, jn
    >>> from sympy.abc import z, n
    >>> b = besselj(n, z)

    Differentiate it:

    >>> b.diff(z)
    besselj(n - 1, z)/2 - besselj(n + 1, z)/2

    Rewrite in terms of spherical Bessel functions:

    >>> b.rewrite(jn)
    sqrt(2)*sqrt(z)*jn(n - 1/2, z)/sqrt(pi)

    Access the parameter and argument:

    >>> b.order
    n
    >>> b.argument
    z

    See Also
    ========

    bessely, besseli, besselk

    References
    ==========

    .. [1] Abramowitz, Milton; Stegun, Irene A., eds. (1965), "Chapter 9",
           Handbook of Mathematical Functions with Formulas, Graphs, and
           Mathematical Tables
    .. [2] Luke, Y. L. (1969), The Special Functions and Their
           Approximations, Volume 1
    .. [3] https://en.wikipedia.org/wiki/Bessel_function
    .. [4] https://functions.wolfram.com/Bessel-TypeFunctions/BesselJ/

    c                 C   sR  |j r,|j r	tjS |jr|j du st|ƒjrtjS t|ƒjr&|jdur&tjS |j	r,tj
S |tjtjfv r7tjS | ¡ rK|| | |   t|| ƒ S |jrn| ¡ r^tj|  t| |ƒ S | t¡}|rnt| t||ƒ S |jrt|ƒ}||kr~t||ƒS n| ¡ \}}|dkrštd| t | t ƒt||ƒ S t|ƒ}||kr§t||ƒS d S )NFTr   r?   )rW   r   ÚOnerO   r"   r^   ÚZeror`   ÚComplexInfinityÚis_imaginaryÚNaNÚInfinityÚNegativeInfinityÚcould_extract_minus_signrQ   ÚNegativeOneÚextract_multiplicativelyr   rR   r%   Úextract_branch_factorr   r   ©r;   r<   r=   ZnewzÚnZnnur3   r3   r4   r>   ²   s>    

ÿ"
ÿzbesselj.evalc                 K   s(   t tt | d ƒt|tt ƒ| ƒ S ©Nr?   )r   r   r   rR   r$   ©r2   r<   r=   re   r3   r3   r4   Ú_eval_rewrite_as_besseliÖ   ó   (z besselj._eval_rewrite_as_besselic                 K   s<   |j du rtt| ƒt| |ƒ tt| ƒt||ƒ  S d S rG   )rO   r   r   Úbesselyr   r}   r3   r3   r4   Ú_eval_rewrite_as_besselyÙ   ó   
.ÿz besselj._eval_rewrite_as_besselyc                 K   ó"   t d| t ƒt|tj | jƒ S r|   )r   r   rU   r   ÚHalfr8   r}   r3   r3   r4   Ú_eval_rewrite_as_jnÝ   ó   "zbesselj._eval_rewrite_as_jnc           
         sÒ   | j \}}z| |¡}W n ty   |  Y S w | |¡\}}|jr0|| d| t|d ƒ  S |jr^|dkr9dn|}|||  }	|	js\tdƒt|t	d| d  d  ƒ tt	| ƒ S | S t
t| ƒj|||d�S )Nr?   r7   r   é   ©ÚlogxÚcdir)r0   Úas_leading_termÚNotImplementedErrorÚas_coeff_exponentr^   r&   r`   r   r   r   ÚsuperrQ   Ú_eval_as_leading_term©
r2   rY   r‰   rŠ   r<   r=   ÚargÚcÚeÚsign©rB   r3   r4   r�   à   s    
ÿ0zbesselj._eval_as_leading_termc                 C   ó"   | j \}}|jr|jrdS d S d S ©NT©r0   rO   Úis_extended_real©r2   r<   r=   r3   r3   r4   Ú_eval_is_extended_realõ   ó   
ÿzbesselj._eval_is_extended_realr   c              	      s"  ddl m} | j\}}z	| |¡\}}	W n ttfy!   |  Y S w |	jr†t||	 ƒ}
||| |ƒ}|d  ||||¡ 	¡ }|t
ju rE|S t|d ƒ|  	¡ }|| t|d ƒ }|g}td|
d d ƒD ]}|| |||   9 }t|ƒ|  	¡ }| |¡ qet|Ž | S tt| ƒ ||||¡S ©Nr   ©ÚOrderr?   r7   )Úsympy.series.orderrŸ   r0   ÚleadtermÚ
ValueErrorrŒ   r^   r   Ú_eval_nseriesÚremoveOr   rp   r
   r&   ÚrangeÚappendr   rŽ   rQ   ©r2   rY   r{   r‰   rŠ   rŸ   r<   r=   Ú_r   ÚnewnÚoÚrÚtÚtermÚsÚkr•   r3   r4   r£   ú   s,   
ÿ
zbesselj._eval_nseries©r   )rh   ri   rj   rk   r   ro   rC   rA   rm   r>   r~   r�   r…   r�   r›   r£   Ú__classcell__r3   r3   r•   r4   rQ   j   s    D
#rQ   c                       rn   )r€   a`  
    Bessel function of the second kind.

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

    The Bessel $Y$ function of order $\nu$ is defined as

    .. math ::
        Y_\nu(z) = \lim_{\mu \to \nu} \frac{J_\mu(z) \cos(\pi \mu)
                                            - J_{-\mu}(z)}{\sin(\pi \mu)},

    where $J_\mu(z)$ is the Bessel function of the first kind.

    It is a solution to Bessel's equation, and linearly independent from
    $J_\nu$.

    Examples
    ========

    >>> from sympy import bessely, yn
    >>> from sympy.abc import z, n
    >>> b = bessely(n, z)
    >>> b.diff(z)
    bessely(n - 1, z)/2 - bessely(n + 1, z)/2
    >>> b.rewrite(yn)
    sqrt(2)*sqrt(z)*yn(n - 1/2, z)/sqrt(pi)

    See Also
    ========

    besselj, besseli, besselk

    References
    ==========

    .. [1] https://functions.wolfram.com/Bessel-TypeFunctions/BesselY/

    c                 C   sÔ   |j r|j r	tjS t|ƒj du rtjS t|ƒj rtjS |tjtjfv r&tjS |ttj kr<t	tt
 |d  d ƒtj S |ttj krSt	t t
 |d  d ƒtj S |jrf| ¡ rhtj|  t| |ƒ S d S d S )NFr7   r?   )rW   r   ru   r"   rq   rs   rt   rp   r   r   r   rO   rv   rw   r€   r:   r3   r3   r4   r>   F  s$   
 þzbessely.evalc                 K   s<   |j du rtt| ƒtt| ƒt||ƒ t| |ƒ  S d S rG   )rO   r   r   r   rQ   r}   r3   r3   r4   Ú_eval_rewrite_as_besseljZ  r‚   z bessely._eval_rewrite_as_besseljc                 K   ó   | j | jŽ }|r| t¡S d S r9   )r²   r0   ÚrewriterR   ©r2   r<   r=   re   Úajr3   r3   r4   r~   ^  ó   
ÿz bessely._eval_rewrite_as_besselic                 K   rƒ   r|   )r   r   rV   r   r„   r8   r}   r3   r3   r4   Ú_eval_rewrite_as_ync  r†   zbessely._eval_rewrite_as_ync                    sz  | j \}}z| |¡}W n ty   |  Y S w | |¡\}}|jrkdt t|d ƒ t||ƒ }	|jrD|d |   t|d ƒ t nt	j
}
|d |  tt|ƒ  t|d ƒt	j  }t|	|
|gŽ j||d�}|S |jr²|dkrtdn|}|||  }|js°tdƒtt| d | td  ƒ dtt| d | td  ƒ d|    td| ƒ ttƒ S | S tt| ƒj|||d�S )	Nr?   r7   ©r‰   r   r‡   é   é   rˆ   )r0   r‹   rŒ   r�   r^   r   r   rQ   r   r   rp   r'   Ú
EulerGammar   r`   r   r   r   rŽ   r€   r�   )r2   rY   r‰   rŠ   r<   r=   r‘   r’   r“   Zterm_oneZterm_twoZ
term_threer”   r•   r3   r4   r�   f  s(   
ÿ,,bzbessely._eval_as_leading_termc                 C   r–   r—   ©r0   rO   r^   rš   r3   r3   r4   r›     rœ   zbessely._eval_is_extended_realr   c              	      s.  ddl m} | j\}}z	| |¡\}}	W n ttfy!   |  Y S w |	j�r|j�rt||	 ƒ}
t	||ƒ}dt
 t|d ƒ |  ||||¡}g g }}||| |ƒ}|d  ||||¡ ¡ }|tju rf|S t|d ƒ|  ¡ }|tjkr´||  t|d ƒ t
 }| |¡ td|ƒD ]'}|| | }|tjkr ||| 9 }n||| 9 }t|ƒ|  ¡ }| |¡ qŒ|| t
t|ƒ  }|t|d ƒtj  }| |¡ td|
d d ƒD ]*}|| |||   9 }t|ƒ|  ¡ }|t|| d ƒt|d ƒ  }| |¡ q×|t|Ž  t|Ž  S tt| ƒ ||||¡S r�   )r    rŸ   r0   r¡   r¢   rŒ   r^   rO   r   rQ   r   r   r£   r¤   r   rp   r
   r   r¦   r¥   r'   r¼   r   rŽ   r€   )r2   rY   r{   r‰   rŠ   rŸ   r<   r=   r¨   r   r©   ÚbnrZ   Úbr’   rª   r«   r¬   r­   r¯   ÚdenomÚpr•   r3   r4   r£   „  sJ   
ÿ
$





 zbessely._eval_nseriesr°   )rh   ri   rj   rk   r   ro   rC   rA   rm   r>   r²   r~   r¸   r�   r›   r£   r±   r3   r3   r•   r4   r€     s    (
r€   c                       s~   e Zd ZdZej ZejZedd„ ƒZ	ddd„Z
dd„ Zd	d
„ Zdd„ Zdd„ Z‡ fdd„Zd‡ fdd„	Z‡ fdd„Z‡  ZS )rR   a  
    Modified Bessel function of the first kind.

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

    The Bessel $I$ function is a solution to the modified Bessel equation

    .. math ::
        z^2 \frac{\mathrm{d}^2 w}{\mathrm{d}z^2}
        + z \frac{\mathrm{d}w}{\mathrm{d}z} + (z^2 + \nu^2)^2 w = 0.

    It can be defined as

    .. math ::
        I_\nu(z) = i^{-\nu} J_\nu(iz),

    where $J_\nu(z)$ is the Bessel function of the first kind.

    Examples
    ========

    >>> from sympy import besseli
    >>> from sympy.abc import z, n
    >>> besseli(n, z).diff(z)
    besseli(n - 1, z)/2 + besseli(n + 1, z)/2

    See Also
    ========

    besselj, bessely, besselk

    References
    ==========

    .. [1] https://functions.wolfram.com/Bessel-TypeFunctions/BesselI/

    c                 C   sv  |j r,|j r	tjS |jr|j du st|ƒjrtjS t|ƒjr&|jdur&tjS |j	r,tj
S t|ƒtjtjfv r9tjS |tju rAtjS |tju rMd| tj S | ¡ ra|| | |   t|| ƒ S |jr€| ¡ rnt| |ƒS | t¡}|r€t|  t|| ƒ S |jr‘t|ƒ}||kr�t||ƒS n| ¡ \}}|dkr¬td| t | t ƒt||ƒ S t|ƒ}||kr¹t||ƒS d S )NFTéÿÿÿÿr   r?   )rW   r   ro   rO   r"   r^   rp   r`   rq   rr   rs   r#   rt   ru   rv   rR   rx   r   rQ   r%   ry   r   r   rz   r3   r3   r4   r>   á  sF   

 

ÿ"
ÿzbesseli.evalNc                 K   s   |j rt|ƒt||ƒ S d S r9   )r™   r   Ú_besseli©r2   r<   r=   Úlimitvarre   r3   r3   r4   Ú_eval_rewrite_as_tractable	  s   ÿz"besseli._eval_rewrite_as_tractablec                 K   s(   t t t | d ƒt|ttƒ| ƒ S r|   )r   r   r   rQ   r$   r}   r3   r3   r4   r²     r   z besseli._eval_rewrite_as_besseljc                 K   r³   r9   ©r²   r0   r´   r€   rµ   r3   r3   r4   r�     r·   z besseli._eval_rewrite_as_besselyc                 K   s   | j | jŽ  t¡S r9   )r²   r0   r´   rU   r}   r3   r3   r4   r…     ó   zbesseli._eval_rewrite_as_jnc                 C   r–   r—   r˜   rš   r3   r3   r4   r›     rœ   zbesseli._eval_is_extended_realc           
         sº   | j \}}z| |¡}W n ty   |  Y S w | |¡\}}|jr0|| d| t|d ƒ  S |jrR|dkr9dn|}|||  }	|	jsPt|ƒtdt	 | ƒ S | S t
t| ƒj|||d�S )Nr?   r7   r   rˆ   )r0   r‹   rŒ   r�   r^   r&   r`   r   r   r   rŽ   rR   r�   r�   r•   r3   r4   r�     s    
ÿzbesseli._eval_as_leading_termr   c              	      s   ddl m} | j\}}z	| |¡\}}	W n ttfy!   |  Y S w |	jr…t||	 ƒ}
||| |ƒ}|d  ||||¡ 	¡ }|t
ju rE|S t|d ƒ|  	¡ }|| t|d ƒ }|g}td|
d d ƒD ]}|||||   9 }t|ƒ|  	¡ }| |¡ qet|Ž | S tt| ƒ ||||¡S r�   )r    rŸ   r0   r¡   r¢   rŒ   r^   r   r£   r¤   r   rp   r
   r&   r¥   r¦   r   rŽ   rR   r§   r•   r3   r4   r£   2  s,   
ÿ
zbesseli._eval_nseriesc                    s¤   ddl m‰  ddlm} |d }|tjtjfv rI| j\‰‰‡ ‡‡fdd„t|ƒD ƒ|dˆt	d| d dƒ  |ƒg }t
ˆƒtdt ƒ t|Ž  S tƒ  ||||¡S )Nr   ©r   rž   r7   c                    ób   g | ]-}ˆ t d ˆ d d ƒ|ƒˆ t d ˆ d d ƒ|ƒ d | ˆt d | d d ƒ  t|ƒ  ‘qS ©r?   r7   ©r   r   ©Ú.0r¯   ©r   r<   r=   r3   r4   Ú
<listcomp>X  ó
    .ÿ$ÿz)besseli._eval_aseries.<locals>.<listcomp>r?   ©Ú(sympy.functions.combinatorial.factorialsr   r    rŸ   r   rt   ru   r0   r¥   r   r   r   r   r   rŽ   Ú_eval_aseries©r2   r{   Úargs0rY   r‰   rŸ   Úpointr®   r•   rÏ   r4   rÔ   Q  s   
ÿ ÿzbesseli._eval_aseriesr9   r°   )rh   ri   rj   rk   r   ro   rC   rA   rm   r>   rÆ   r²   r�   r…   r›   r�   r£   rÔ   r±   r3   r3   r•   r4   rR   ¶  s    '

'rR   c                       s‚   e Zd ZdZejZej Zedd„ ƒZ	dd„ Z
dd„ Zdd	„ Zd
d„ Zdd„ Zddd„Zdd„ Zd‡ fdd„	Z‡ fdd„Z‡  ZS )Úbesselka  
    Modified Bessel function of the second kind.

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

    The Bessel $K$ function of order $\nu$ is defined as

    .. math ::
        K_\nu(z) = \lim_{\mu \to \nu} \frac{\pi}{2}
                   \frac{I_{-\mu}(z) -I_\mu(z)}{\sin(\pi \mu)},

    where $I_\mu(z)$ is the modified Bessel function of the first kind.

    It is a solution of the modified Bessel equation, and linearly independent
    from $Y_\nu$.

    Examples
    ========

    >>> from sympy import besselk
    >>> from sympy.abc import z, n
    >>> besselk(n, z).diff(z)
    -besselk(n - 1, z)/2 - besselk(n + 1, z)/2

    See Also
    ========

    besselj, besseli, bessely

    References
    ==========

    .. [1] https://functions.wolfram.com/Bessel-TypeFunctions/BesselK/

    c                 C   sz   |j r|j r	tjS t|ƒj du rtjS t|ƒj rtjS |tjttj ttj fv r,tjS |j	r9| 
¡ r;t| |ƒS d S d S rG   )rW   r   rt   r"   rq   rs   r   ru   rp   rO   rv   rØ   r:   r3   r3   r4   r>   ˆ  s   
þzbesselk.evalc                 K   s8   |j du rttt| ƒ t| |ƒt||ƒ  d S d S )NFr?   )rO   r   r   rR   r}   r3   r3   r4   r~   ˜  s   
*ÿz besselk._eval_rewrite_as_besselic                 K   r³   r9   )r~   r0   r´   rQ   )r2   r<   r=   re   Úair3   r3   r4   r²   œ  r·   z besselk._eval_rewrite_as_besseljc                 K   r³   r9   rÇ   rµ   r3   r3   r4   r�   ¡  r·   z besselk._eval_rewrite_as_besselyc                 K   r³   r9   )r�   r0   r´   rV   )r2   r<   r=   re   Úayr3   r3   r4   r¸   ¦  r·   zbesselk._eval_rewrite_as_ync                 C   r–   r—   r½   rš   r3   r3   r4   r›   «  rœ   zbesselk._eval_is_extended_realNc                 K   s   |j rt| ƒt||ƒ S d S r9   )r™   r   Ú_besselkrÄ   r3   r3   r4   rÆ   °  s   ÿz"besselk._eval_rewrite_as_tractablec           
      C   sÜ   | j \}}z| |¡}W n ty   |  Y S w | |¡\}}|jrV|jr2t|ƒ tj tdƒ }	n|j	rGt
t|ƒƒ|d t|ƒ   d }	ntd|› d�ƒ‚|	j||d�S |jrhttƒt| ƒ td| ƒ S |  ||¡S )Nr?   z"Cannot proceed without knowing if z is zero or not.r¹   )r0   r‹   rŒ   r�   r^   rW   r   r   r¼   Ú
is_nonzeror&   r!   r`   r   r   r   Úfunc)
r2   rY   r‰   rŠ   r<   r=   r‘   r¨   r“   r­   r3   r3   r4   r�   ´  s"   
ÿ$zbesselk._eval_as_leading_termr   c              	      s,  ddl m} | j\}}z	| |¡\}}	W n ttfy!   |  Y S w |	j�r‹|d  ||||¡ ¡ }
|
t	j
u rC|||  ||  |ƒS ||| |ƒ}|j�rt||	 ƒ}t||ƒ}d|d  t|d ƒ |  ||||¡}g g }}t|
d ƒ}|t	j
kr®|
|  t|d ƒ d }| |¡ td|ƒD ]}|||| |  9 }t|ƒ|  ¡ }| |¡ q”|
| d|  dt|ƒ  }|t|d ƒt	j  }| |¡ td|d d ƒD ])}|||||   9 }t|ƒ|  ¡ }|t|| d ƒt|d ƒ  }| |¡ qÕ|t|Ž  t|Ž  | S |j�r‡t|| |	 ƒ}t|| |	 ƒ}g g }}t|d d ƒD ]#}t|ƒ|
d| |   dtd| |ƒ t|ƒ  }| t|ƒ¡ �q,t|d d ƒD ]$}t| ƒ|
d| |   dt|d |ƒ t|ƒ  }| t|ƒ¡ �qXt|Ž t|Ž  | S tdƒ‚tt| ƒ ||||¡S )Nr   rž   r?   rÂ   r7   z4besselk expansion is only implemented for real order)r    rŸ   r0   r¡   r¢   rŒ   r^   r£   r¤   r   rp   rO   r   rR   r   r
   r   r¦   r¥   r'   r¼   r   Úis_nonintegerr&   r   rŽ   rØ   )r2   rY   r{   r‰   rŠ   rŸ   r<   r=   r¨   r   r«   rª   r©   r¾   rZ   r¿   r’   r¬   r­   r¯   rÁ   Znewn_aZnewn_br•   r3   r4   r£   Í  s^   
ÿ

(



 

24zbesselk._eval_nseriesc                    s¦   ddl m‰  ddlm} |d }|tjtjfv rJ| j\‰‰‡ ‡‡fdd„t|ƒD ƒ|dˆt	d| d dƒ  |ƒg }t
ˆ ƒttd ƒ t|Ž  S tƒ  ||||¡S )Nr   rÉ   rž   r7   c                    ób   g | ]-}ˆ t d ˆ d d ƒ|ƒˆ t d ˆ d d ƒ|ƒ d| ˆt d | d d ƒ  t|ƒ  ‘qS ©r?   r7   éþÿÿÿrÌ   rÍ   rÏ   r3   r4   rÐ     rÑ   z)besselk._eval_aseries.<locals>.<listcomp>r?   rÒ   rÕ   r•   rÏ   r4   rÔ     s   
ÿ ÿzbesselk._eval_aseriesr9   r°   )rh   ri   rj   rk   r   ro   rC   rA   rm   r>   r~   r²   r�   r¸   r›   rÆ   r�   r£   rÔ   r±   r3   r3   r•   r4   rØ   _  s    %

ErØ   c                   @   ó$   e Zd ZdZejZejZdd„ ZdS )Úhankel1a¤  
    Hankel function of the first kind.

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

    This function is defined as

    .. math ::
        H_\nu^{(1)} = J_\nu(z) + iY_\nu(z),

    where $J_\nu(z)$ is the Bessel function of the first kind, and
    $Y_\nu(z)$ is the Bessel function of the second kind.

    It is a solution to Bessel's equation.

    Examples
    ========

    >>> from sympy import hankel1
    >>> from sympy.abc import z, n
    >>> hankel1(n, z).diff(z)
    hankel1(n - 1, z)/2 - hankel1(n + 1, z)/2

    See Also
    ========

    hankel2, besselj, bessely

    References
    ==========

    .. [1] https://functions.wolfram.com/Bessel-TypeFunctions/HankelH1/

    c                 C   ó(   | j }|jdu rt| j ¡ | ¡ ƒS d S rG   )r8   rH   Úhankel2r5   rI   rJ   r3   r3   r4   rK   H  ó   
ÿzhankel1._eval_conjugateN©	rh   ri   rj   rk   r   ro   rC   rA   rK   r3   r3   r3   r4   rã      s
    $rã   c                   @   râ   )rå   aÖ  
    Hankel function of the second kind.

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

    This function is defined as

    .. math ::
        H_\nu^{(2)} = J_\nu(z) - iY_\nu(z),

    where $J_\nu(z)$ is the Bessel function of the first kind, and
    $Y_\nu(z)$ is the Bessel function of the second kind.

    It is a solution to Bessel's equation, and linearly independent from
    $H_\nu^{(1)}$.

    Examples
    ========

    >>> from sympy import hankel2
    >>> from sympy.abc import z, n
    >>> hankel2(n, z).diff(z)
    hankel2(n - 1, z)/2 - hankel2(n + 1, z)/2

    See Also
    ========

    hankel1, besselj, bessely

    References
    ==========

    .. [1] https://functions.wolfram.com/Bessel-TypeFunctions/HankelH2/

    c                 C   rä   rG   )r8   rH   rã   r5   rI   rJ   r3   r3   r4   rK   w  ræ   zhankel2._eval_conjugateNrç   r3   r3   r3   r4   rå   N  s
    %rå   c                    s   t ˆ ƒ‡ fdd„ƒ}|S )Nc                    s   |j r	ˆ | ||ƒS d S r9   )rO   rš   ©Úfnr3   r4   Úg~  s   ÿzassume_integer_order.<locals>.gr   )ré   rê   r3   rè   r4   Úassume_integer_order}  s   rë   c                   @   s*   e Zd ZdZdd„ Zdd„ Zd
dd„Zd	S )ÚSphericalBesselBasea-  
    Base class for spherical Bessel functions.

    These are thin wrappers around ordinary Bessel functions,
    since spherical Bessel functions differ from the ordinary
    ones just by a slight change in order.

    To use this class, define the ``_eval_evalf()`` and ``_expand()`` methods.

    c                 K   s   t dƒ‚)z@ Expand self into a polynomial. Nu is guaranteed to be Integer. Z	expansion©rŒ   ©r2   ra   r3   r3   r4   Ú_expand‘  s   zSphericalBesselBase._expandc                 K   s   | j jr| jdi |¤ŽS | S ©Nr3   )r5   Ú
is_Integerrï   rî   r3   r3   r4   r_   •  s   z%SphericalBesselBase._eval_expand_funcr?   c                 C   s:   |dkr	t | |ƒ‚|  | jd | j¡| | jd  | j  S r@   )r	   rB   r5   r8   rD   r3   r3   r4   rF   š  s
   
ÿzSphericalBesselBase.fdiffNrg   )rh   ri   rj   rk   rï   r_   rF   r3   r3   r3   r4   rì   …  s
    rì   c                 C   s8   t | |ƒt|ƒ tj| d  t |  d |ƒ t|ƒ  S ©Nr7   )r*   r   r   rw   r   ©r{   r=   r3   r3   r4   Ú_jn¡  s   $ÿrô   c                 C   s8   t j| d  t|  d |ƒ t|ƒ t| |ƒt|ƒ  S rò   )r   rw   r*   r   r   ró   r3   r3   r4   Ú_yn¦  s   $ÿrõ   c                   @   sD   e Zd ZdZedd„ ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dS )rU   aö  
    Spherical Bessel function of the first kind.

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

    This function is a solution to the spherical Bessel equation

    .. math ::
        z^2 \frac{\mathrm{d}^2 w}{\mathrm{d}z^2}
          + 2z \frac{\mathrm{d}w}{\mathrm{d}z} + (z^2 - \nu(\nu + 1)) w = 0.

    It can be defined as

    .. math ::
        j_\nu(z) = \sqrt{\frac{\pi}{2z}} J_{\nu + \frac{1}{2}}(z),

    where $J_\nu(z)$ is the Bessel function of the first kind.

    The spherical Bessel functions of integral order are
    calculated using the formula:

    .. math:: j_n(z) = f_n(z) \sin{z} + (-1)^{n+1} f_{-n-1}(z) \cos{z},

    where the coefficients $f_n(z)$ are available as
    :func:`sympy.polys.orthopolys.spherical_bessel_fn`.

    Examples
    ========

    >>> from sympy import Symbol, jn, sin, cos, expand_func, besselj, bessely
    >>> z = Symbol("z")
    >>> nu = Symbol("nu", integer=True)
    >>> print(expand_func(jn(0, z)))
    sin(z)/z
    >>> expand_func(jn(1, z)) == sin(z)/z**2 - cos(z)/z
    True
    >>> expand_func(jn(3, z))
    (-6/z**2 + 15/z**4)*sin(z) + (1/z - 15/z**3)*cos(z)
    >>> jn(nu, z).rewrite(besselj)
    sqrt(2)*sqrt(pi)*sqrt(1/z)*besselj(nu + 1/2, z)/2
    >>> jn(nu, z).rewrite(bessely)
    (-1)**nu*sqrt(2)*sqrt(pi)*sqrt(1/z)*bessely(-nu - 1/2, z)/2
    >>> jn(2, 5.2+0.3j).evalf(20)
    0.099419756723640344491 - 0.054525080242173562897*I

    See Also
    ========

    besselj, bessely, besselk, yn

    References
    ==========

    .. [1] https://dlmf.nist.gov/10.47

    c                 C   sD   |j r|j r	tjS |jr|jrtjS tjS |tjtjfv r tjS d S r9   )	rW   r   ro   rO   r^   rp   rq   ru   rt   r:   r3   r3   r4   r>   æ  s   ÿzjn.evalc                 K   ó    t td|  ƒt|tj |ƒ S r|   )r   r   rQ   r   r„   r}   r3   r3   r4   r²   ó  s    zjn._eval_rewrite_as_besseljc                 K   s,   t j| ttd|  ƒ t| t j |ƒ S r|   )r   rw   r   r   r€   r„   r}   r3   r3   r4   r�   ö  s   ,zjn._eval_rewrite_as_besselyc                 K   s   t j| t| d |ƒ S rò   )r   rw   rV   r}   r3   r3   r4   r¸   ù  s   zjn._eval_rewrite_as_ync                 K   ó   t | j| jƒS r9   )rô   r5   r8   rî   r3   r3   r4   rï   ü  ó   z
jn._expandc                 C   ó   | j jr|  t¡ |¡S d S r9   ©r5   rñ   r´   rQ   Ú_eval_evalf©r2   Úprecr3   r3   r4   rû   ÿ  ó   ÿzjn._eval_evalfN)rh   ri   rj   rk   rm   r>   r²   r�   r¸   rï   rû   r3   r3   r3   r4   rU   ¬  s    9
rU   c                   @   s@   e Zd ZdZedd„ ƒZedd„ ƒZdd„ Zdd	„ Zd
d„ Z	dS )rV   a¥  
    Spherical Bessel function of the second kind.

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

    This function is another solution to the spherical Bessel equation, and
    linearly independent from $j_n$. It can be defined as

    .. math ::
        y_\nu(z) = \sqrt{\frac{\pi}{2z}} Y_{\nu + \frac{1}{2}}(z),

    where $Y_\nu(z)$ is the Bessel function of the second kind.

    For integral orders $n$, $y_n$ is calculated using the formula:

    .. math:: y_n(z) = (-1)^{n+1} j_{-n-1}(z)

    Examples
    ========

    >>> from sympy import Symbol, yn, sin, cos, expand_func, besselj, bessely
    >>> z = Symbol("z")
    >>> nu = Symbol("nu", integer=True)
    >>> print(expand_func(yn(0, z)))
    -cos(z)/z
    >>> expand_func(yn(1, z)) == -cos(z)/z**2-sin(z)/z
    True
    >>> yn(nu, z).rewrite(besselj)
    (-1)**(nu + 1)*sqrt(2)*sqrt(pi)*sqrt(1/z)*besselj(-nu - 1/2, z)/2
    >>> yn(nu, z).rewrite(bessely)
    sqrt(2)*sqrt(pi)*sqrt(1/z)*bessely(nu + 1/2, z)/2
    >>> yn(2, 5.2+0.3j).evalf(20)
    0.18525034196069722536 + 0.014895573969924817587*I

    See Also
    ========

    besselj, bessely, besselk, jn

    References
    ==========

    .. [1] https://dlmf.nist.gov/10.47

    c                 K   s0   t j|d  ttd|  ƒ t| t j |ƒ S r\   )r   rw   r   r   rQ   r„   r}   r3   r3   r4   r²   3  s   0zyn._eval_rewrite_as_besseljc                 K   rö   r|   )r   r   r€   r   r„   r}   r3   r3   r4   r�   7  s    zyn._eval_rewrite_as_besselyc                 K   s   t j|d  t| d |ƒ S rò   )r   rw   rU   r}   r3   r3   r4   r…   ;  s   zyn._eval_rewrite_as_jnc                 K   r÷   r9   )rõ   r5   r8   rî   r3   r3   r4   rï   >  rø   z
yn._expandc                 C   rù   r9   )r5   rñ   r´   r€   rû   rü   r3   r3   r4   rû   A  rþ   zyn._eval_evalfN)
rh   ri   rj   rk   rë   r²   r�   r…   rï   rû   r3   r3   r3   r4   rV     s    .

rV   c                   @   sL   e Zd Zedd„ ƒZedd„ ƒZdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚSphericalHankelBasec                 K   sN   | j }ttd|  ƒt|tj |ƒ|t tj|d   t| tj |ƒ   S r@   )Ú_hankel_kind_signr   r   rQ   r   r„   r   rw   ©r2   r<   r=   re   Úhksr3   r3   r4   r²   H  s   &ÿz,SphericalHankelBase._eval_rewrite_as_besseljc                 K   sJ   | j }ttd|  ƒtj| t| tj |ƒ |t t|tj |ƒ   S r|   )r   r   r   r   rw   r€   r„   r   r  r3   r3   r4   r�   Q  s   (ÿz,SphericalHankelBase._eval_rewrite_as_besselyc                 K   s(   | j }t||ƒ t¡|t t||ƒ  S r9   )r   rU   r´   rV   r   r  r3   r3   r4   r¸   Z  ó   "z'SphericalHankelBase._eval_rewrite_as_ync                 K   s(   | j }t||ƒ|t t||ƒ t¡  S r9   )r   rU   r   rV   r´   r  r3   r3   r4   r…   ^  r  z'SphericalHankelBase._eval_rewrite_as_jnc                 K   sF   | j jr| jdi |¤ŽS | j }| j}| j}t||ƒ|t t||ƒ  S rð   )r5   rñ   rï   r8   r   rU   r   rV   )r2   ra   r<   r=   r  r3   r3   r4   r_   b  s   z%SphericalHankelBase._eval_expand_funcc                 K   s2   | j }| j}| j}t||ƒ|t t||ƒ   ¡ S r9   )r5   r8   r   rô   r   rõ   Úexpand)r2   ra   r{   r=   r  r3   r3   r4   rï   k  s    
zSphericalHankelBase._expandc                 C   rù   r9   rú   rü   r3   r3   r4   rû   z  rþ   zSphericalHankelBase._eval_evalfN)rh   ri   rj   rë   r²   r�   r¸   r…   r_   rï   rû   r3   r3   r3   r4   rÿ   F  s    

	rÿ   c                   @   s"   e Zd ZdZejZedd„ ƒZdS )rS   a”  
    Spherical Hankel function of the first kind.

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

    This function is defined as

    .. math:: h_\nu^(1)(z) = j_\nu(z) + i y_\nu(z),

    where $j_\nu(z)$ and $y_\nu(z)$ are the spherical
    Bessel function of the first and second kinds.

    For integral orders $n$, $h_n^(1)$ is calculated using the formula:

    .. math:: h_n^(1)(z) = j_{n}(z) + i (-1)^{n+1} j_{-n-1}(z)

    Examples
    ========

    >>> from sympy import Symbol, hn1, hankel1, expand_func, yn, jn
    >>> z = Symbol("z")
    >>> nu = Symbol("nu", integer=True)
    >>> print(expand_func(hn1(nu, z)))
    jn(nu, z) + I*yn(nu, z)
    >>> print(expand_func(hn1(0, z)))
    sin(z)/z - I*cos(z)/z
    >>> print(expand_func(hn1(1, z)))
    -I*sin(z)/z - cos(z)/z + sin(z)/z**2 - I*cos(z)/z**2
    >>> hn1(nu, z).rewrite(jn)
    (-1)**(nu + 1)*I*jn(-nu - 1, z) + jn(nu, z)
    >>> hn1(nu, z).rewrite(yn)
    (-1)**nu*yn(-nu - 1, z) + I*yn(nu, z)
    >>> hn1(nu, z).rewrite(hankel1)
    sqrt(2)*sqrt(pi)*sqrt(1/z)*hankel1(nu, z)/2

    See Also
    ========

    hn2, jn, yn, hankel1, hankel2

    References
    ==========

    .. [1] https://dlmf.nist.gov/10.47

    c                 K   ó   t td|  ƒt||ƒ S r|   )r   r   rã   r}   r3   r3   r4   Ú_eval_rewrite_as_hankel1²  ó   zhn1._eval_rewrite_as_hankel1N)	rh   ri   rj   rk   r   ro   r   rë   r  r3   r3   r3   r4   rS     s
    0rS   c                   @   s$   e Zd ZdZej Zedd„ ƒZdS )rT   a’  
    Spherical Hankel function of the second kind.

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

    This function is defined as

    .. math:: h_\nu^(2)(z) = j_\nu(z) - i y_\nu(z),

    where $j_\nu(z)$ and $y_\nu(z)$ are the spherical
    Bessel function of the first and second kinds.

    For integral orders $n$, $h_n^(2)$ is calculated using the formula:

    .. math:: h_n^(2)(z) = j_{n} - i (-1)^{n+1} j_{-n-1}(z)

    Examples
    ========

    >>> from sympy import Symbol, hn2, hankel2, expand_func, jn, yn
    >>> z = Symbol("z")
    >>> nu = Symbol("nu", integer=True)
    >>> print(expand_func(hn2(nu, z)))
    jn(nu, z) - I*yn(nu, z)
    >>> print(expand_func(hn2(0, z)))
    sin(z)/z + I*cos(z)/z
    >>> print(expand_func(hn2(1, z)))
    I*sin(z)/z - cos(z)/z + sin(z)/z**2 + I*cos(z)/z**2
    >>> hn2(nu, z).rewrite(hankel2)
    sqrt(2)*sqrt(pi)*sqrt(1/z)*hankel2(nu, z)/2
    >>> hn2(nu, z).rewrite(jn)
    -(-1)**(nu + 1)*I*jn(-nu - 1, z) + jn(nu, z)
    >>> hn2(nu, z).rewrite(yn)
    (-1)**nu*yn(-nu - 1, z) - I*yn(nu, z)

    See Also
    ========

    hn1, jn, yn, hankel1, hankel2

    References
    ==========

    .. [1] https://dlmf.nist.gov/10.47

    c                 K   r  r|   )r   r   rå   r}   r3   r3   r4   Ú_eval_rewrite_as_hankel2ê  r  zhn2._eval_rewrite_as_hankel2N)	rh   ri   rj   rk   r   ro   r   rë   r  r3   r3   r3   r4   rT   ·  s
    0rT   Úsympyé   c                    s  ddl m} ˆdkr*ddlm‰  ddlm} ||ƒ‰‡ ‡‡fdd„td|d ƒD ƒS ˆd	krZdd
lm‰ zddl	m
‰ ‡‡fdd„}W n tyY   ddl	m‰ ‡‡fdd„}Y nw tdƒ‚‡‡fdd„}ˆ| }|||ƒ}|g}	t|d ƒD ]}
|||| ƒ}|	 |¡ qw|	S )a­  
    Zeros of the spherical Bessel function of the first kind.

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

    This returns an array of zeros of $jn$ up to the $k$-th zero.

    * method = "sympy": uses `mpmath.besseljzero
      <https://mpmath.org/doc/current/functions/bessel.html#mpmath.besseljzero>`_
    * method = "scipy": uses the
      `SciPy's sph_jn <https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.jn_zeros.html>`_
      and
      `newton <https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.newton.html>`_
      to find all
      roots, which is faster than computing the zeros using a general
      numerical solver, but it requires SciPy and only works with low
      precision floating point numbers. (The function used with
      method="sympy" is a recent addition to mpmath; before that a general
      solver was used.)

    Examples
    ========

    >>> from sympy import jn_zeros
    >>> jn_zeros(2, 4, dps=5)
    [5.7635, 9.095, 12.323, 15.515]

    See Also
    ========

    jn, yn, besselj, besselk, bessely

    Parameters
    ==========

    n : integer
        order of Bessel function

    k : integer
        number of zeros to return


    r   )r   r	  )Úbesseljzero)Údps_to_precc                    s0   g | ]}t  ˆ tˆd  ƒ ˆ¡t|ƒƒˆ¡‘qS )g      à?)r   Ú_from_mpmathr   Ú
_to_mpmathÚint)rÎ   Úl)r  r{   rý   r3   r4   rÐ   "  s    þÿÿzjn_zeros.<locals>.<listcomp>r7   Úscipy)Únewton)Úspherical_jnc                    s
   ˆˆ | ƒS r9   r3   ©rY   )r{   r  r3   r4   Ú<lambda>)  s   
 zjn_zeros.<locals>.<lambda>)Úsph_jnc                    s   ˆˆ | ƒd d S )Nr   rÂ   r3   r  )r{   r  r3   r4   r  ,  s    úUnknown method.c                    s   ˆ dkrˆ| |ƒ}|S t dƒ‚)Nr  r  rí   )rb   rY   r    )Úmethodr  r3   r4   Úsolver0  s   
ÿzjn_zeros.<locals>.solver)Úmathr   Úmpmathr  Zmpmath.libmp.libmpfr  r¥   Zscipy.optimizer  Zscipy.specialr  ÚImportErrorr  rŒ   r¦   )r{   r¯   r  ÚdpsZmath_pir  rb   r  r    ÚrootsÚir3   )r  r  r{   r  rý   r  r  r4   Újn_zerosï  s4   -þþ
r   c                   @   s4   e Zd ZdZdd„ Zdd„ Zddd„Zdd	d
„ZdS )ÚAiryBasezg
    Abstract base class for Airy functions.

    This class is meant to reduce code duplication.

    c                 C   s   |   | jd  ¡ ¡S ©Nr   )rÝ   r0   rI   r1   r3   r3   r4   rK   K  ó   zAiryBase._eval_conjugatec                 C   s   | j d jS r"  )r0   r™   r1   r3   r3   r4   r›   N  s   zAiryBase._eval_is_extended_realTc                 K   sL   | j d }| ¡ }| j}||ƒ||ƒ d }t||ƒ||ƒ  d }||fS )Nr   r?   )r0   rI   rÝ   r   )r2   Údeepra   r=   Zzcrb   ÚuÚvr3   r3   r4   Úas_real_imagQ  s   
zAiryBase.as_real_imagc                 K   s$   | j dd|i|¤Ž\}}||t  S )Nr$  r3   )r'  r   )r2   r$  ra   Úre_partÚim_partr3   r3   r4   Ú_eval_expand_complexY  s   zAiryBase._eval_expand_complexN)T)rh   ri   rj   rk   rK   r›   r'  r*  r3   r3   r3   r4   r!  C  s    
r!  c                   @   ó^   e Zd ZdZdZdZedd„ ƒZddd„Ze	e
dd	„ ƒƒZd
d„ Zdd„ Zdd„ Zdd„ ZdS )ÚairyaiaŽ  
    The Airy function $\operatorname{Ai}$ of the first kind.

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

    The Airy function $\operatorname{Ai}(z)$ is defined to be the function
    satisfying Airy's differential equation

    .. math::
        \frac{\mathrm{d}^2 w(z)}{\mathrm{d}z^2} - z w(z) = 0.

    Equivalently, for real $z$

    .. math::
        \operatorname{Ai}(z) := \frac{1}{\pi}
        \int_0^\infty \cos\left(\frac{t^3}{3} + z t\right) \mathrm{d}t.

    Examples
    ========

    Create an Airy function object:

    >>> from sympy import airyai
    >>> from sympy.abc import z

    >>> airyai(z)
    airyai(z)

    Several special values are known:

    >>> airyai(0)
    3**(1/3)/(3*gamma(2/3))
    >>> from sympy import oo
    >>> airyai(oo)
    0
    >>> airyai(-oo)
    0

    The Airy function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(airyai(z))
    airyai(conjugate(z))

    Differentiation with respect to $z$ is supported:

    >>> from sympy import diff
    >>> diff(airyai(z), z)
    airyaiprime(z)
    >>> diff(airyai(z), z, 2)
    z*airyai(z)

    Series expansion is also supported:

    >>> from sympy import series
    >>> series(airyai(z), z, 0, 3)
    3**(5/6)*gamma(1/3)/(6*pi) - 3**(1/6)*z*gamma(2/3)/(2*pi) + O(z**3)

    We can numerically evaluate the Airy function to arbitrary precision
    on the whole complex plane:

    >>> airyai(-2).evalf(50)
    0.22740742820168557599192443603787379946077222541710

    Rewrite $\operatorname{Ai}(z)$ in terms of hypergeometric functions:

    >>> from sympy import hyper
    >>> airyai(z).rewrite(hyper)
    -3**(2/3)*z*hyper((), (4/3,), z**3/9)/(3*gamma(1/3)) + 3**(1/3)*hyper((), (2/3,), z**3/9)/(3*gamma(2/3))

    See Also
    ========

    airybi: Airy function of the second kind.
    airyaiprime: Derivative of the Airy function of the first kind.
    airybiprime: Derivative of the Airy function of the second kind.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Airy_function
    .. [2] https://dlmf.nist.gov/9
    .. [3] https://encyclopediaofmath.org/wiki/Airy_functions
    .. [4] https://mathworld.wolfram.com/AiryFunctions.html

    r7   Tc                 C   sŠ   |j r/|tju rtjS |tju rtjS |tju rtjS |jr/tjdtddƒ t	tddƒƒ  S |jrCtjdtddƒ t	tddƒƒ  S d S )Nrº   r?   )
Ú	is_Numberr   rs   rt   rp   ru   rW   ro   r   r&   ©r;   r‘   r3   r3   r4   r>   º  s   


""ÿzairyai.evalc                 C   ó    |dkrt | jd ƒS t| |ƒ‚©Nr7   r   )Úairyaiprimer0   r	   rD   r3   r3   r4   rF   È  ó   
zairyai.fdiffc                 G   s6  | dk rt jS t|ƒ}t|ƒdkrj|d }tdƒ| |   tdƒ| | d   tt| tddƒ tddƒ  ƒ t| ƒ t	| d tddƒ ƒ tt| tddƒ tddƒ  ƒt| d ƒ t	| d tddƒ ƒ  | S t j
dtddƒ t  t	| t j
 t dƒ ƒ ttddƒt | t j
  ƒ t| ƒ tdƒ| |   S )Nr   r7   rÂ   rº   r?   r‡   )r   rp   r   Úlenr   r   r   r   r   r&   ro   ©r{   rY   Úprevious_termsrÁ   r3   r3   r4   Útaylor_termÎ  s"   Lÿ@ÿÿHÿÿzairyai.taylor_termc                 K   s`   t ddƒ}t ddƒ}t| t ddƒƒ}t|ƒjr.|t| ƒ t| || ƒt||| ƒ  S d S ©Nr7   rº   r?   ©r   r   r"   r`   r   rQ   ©r2   r=   re   ÚotÚttrZ   r3   r3   r4   r²   Ý  ó   


,ÿzairyai._eval_rewrite_as_besseljc                 K   s”   t ddƒ}t ddƒ}t|t ddƒƒ}t|ƒjr,|t|ƒ t| || ƒt||| ƒ  S |t||ƒt| || ƒ |t|| ƒ t||| ƒ   S r7  ©r   r   r"   r^   r   rR   r9  r3   r3   r4   r~   ä  s   


*<zairyai._eval_rewrite_as_besselic                 K   s~   t jdtddƒ ttddƒƒ  }|tddƒttddƒƒ  }|tg tddƒg|d d ƒ |tg tddƒg|d d ƒ  S )Nrº   r?   r7   é	   r‡   )r   ro   r   r&   r    r)   ©r2   r=   re   Zpf1Zpf2r3   r3   r4   Ú_eval_rewrite_as_hyperí  s   "@zairyai._eval_rewrite_as_hyperc                 K   s"  | j d }|j}t|ƒdkr‹| ¡ }td|gd�}td|gd�}td|gd�}td|gd�}| ||||  |  ¡}	|	d ur�|	| }d| jr�|	| }|	| }|	| }|||  | || |||    }
|||  |||   }tj|
tj	 t
|ƒ |
tj	 tdƒ t|ƒ   S d S d S d S ©	Nr   r7   r’   )ÚexcludeÚdÚmr{   rº   )r0   Úfree_symbolsr3  Úpopr   ÚmatchrO   r   r„   ro   r,  r   Úairybi©r2   ra   r‘   Zsymbsr=   r’   rC  rD  r{   ÚMÚpfÚnewargr3   r3   r4   r_   ò  ó*   

$2ïzairyai._eval_expand_funcN©r7   ©rh   ri   rj   rk   ÚnargsÚ
unbranchedrm   r>   rF   Ústaticmethodr   r6  r²   r~   r@  r_   r3   r3   r3   r4   r,  ^  s    X

	r,  c                   @   r+  )rH  aâ  
    The Airy function $\operatorname{Bi}$ of the second kind.

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

    The Airy function $\operatorname{Bi}(z)$ is defined to be the function
    satisfying Airy's differential equation

    .. math::
        \frac{\mathrm{d}^2 w(z)}{\mathrm{d}z^2} - z w(z) = 0.

    Equivalently, for real $z$

    .. math::
        \operatorname{Bi}(z) := \frac{1}{\pi}
                 \int_0^\infty
                   \exp\left(-\frac{t^3}{3} + z t\right)
                   + \sin\left(\frac{t^3}{3} + z t\right) \mathrm{d}t.

    Examples
    ========

    Create an Airy function object:

    >>> from sympy import airybi
    >>> from sympy.abc import z

    >>> airybi(z)
    airybi(z)

    Several special values are known:

    >>> airybi(0)
    3**(5/6)/(3*gamma(2/3))
    >>> from sympy import oo
    >>> airybi(oo)
    oo
    >>> airybi(-oo)
    0

    The Airy function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(airybi(z))
    airybi(conjugate(z))

    Differentiation with respect to $z$ is supported:

    >>> from sympy import diff
    >>> diff(airybi(z), z)
    airybiprime(z)
    >>> diff(airybi(z), z, 2)
    z*airybi(z)

    Series expansion is also supported:

    >>> from sympy import series
    >>> series(airybi(z), z, 0, 3)
    3**(1/3)*gamma(1/3)/(2*pi) + 3**(2/3)*z*gamma(2/3)/(2*pi) + O(z**3)

    We can numerically evaluate the Airy function to arbitrary precision
    on the whole complex plane:

    >>> airybi(-2).evalf(50)
    -0.41230258795639848808323405461146104203453483447240

    Rewrite $\operatorname{Bi}(z)$ in terms of hypergeometric functions:

    >>> from sympy import hyper
    >>> airybi(z).rewrite(hyper)
    3**(1/6)*z*hyper((), (4/3,), z**3/9)/gamma(1/3) + 3**(5/6)*hyper((), (2/3,), z**3/9)/(3*gamma(2/3))

    See Also
    ========

    airyai: Airy function of the first kind.
    airyaiprime: Derivative of the Airy function of the first kind.
    airybiprime: Derivative of the Airy function of the second kind.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Airy_function
    .. [2] https://dlmf.nist.gov/9
    .. [3] https://encyclopediaofmath.org/wiki/Airy_functions
    .. [4] https://mathworld.wolfram.com/AiryFunctions.html

    r7   Tc                 C   sŠ   |j r/|tju rtjS |tju rtjS |tju rtjS |jr/tjdtddƒ t	tddƒƒ  S |jrCtjdtddƒ t	tddƒƒ  S d S )Nrº   r7   é   r?   )
r-  r   rs   rt   ru   rp   rW   ro   r   r&   r.  r3   r3   r4   r>   h  s   


""ÿzairybi.evalc                 C   r/  r0  )Úairybiprimer0   r	   rD   r3   r3   r4   rF   w  r2  zairybi.fdiffc                 G   s  | dk rt jS t|ƒ}t|ƒdkrW|d }tdƒ| tttddƒt | t j	  ƒƒ t
| t j	 t dƒ ƒ | t j	 tttddƒt | t j  ƒƒ t
| d t dƒ ƒ  | S t j	tddƒt  t| t j	 t dƒ ƒ tttddƒt | t j	  ƒƒ t
| ƒ tdƒ| |   S )Nr   r7   rÂ   rº   r?   rS  )r   rp   r   r3  r   r!   r   r   r   ro   r   r   r„   r    r&   r4  r3   r3   r4   r6  }  s   @<ÿÿHÿÿzairybi.taylor_termc                 K   s`   t ddƒ}t ddƒ}t| t ddƒƒ}t|ƒjr.t| d ƒt| || ƒt||| ƒ  S d S r7  r8  r9  r3   r3   r4   r²   Œ  r<  zairybi._eval_rewrite_as_besseljc                 K   s¤   t ddƒ}t ddƒ}t|t ddƒƒ}t|ƒjr.t|ƒtdƒ t| || ƒt||| ƒ  S t||ƒ}t|| ƒ}t|ƒ|t| || ƒ || t||| ƒ   S r7  r=  ©r2   r=   re   r:  r;  rZ   r¿   r’   r3   r3   r4   r~   “  s   


.
2zairybi._eval_rewrite_as_besselic                 K   sz   t jtddƒttddƒƒ  }|tddƒ ttddƒƒ }|tg tddƒg|d d ƒ |tg tddƒg|d d ƒ  S )Nrº   rS  r?   r7   r>  r‡   )r   ro   r    r&   r   r)   r?  r3   r3   r4   r@  ž  s   @zairybi._eval_rewrite_as_hyperc                 K   s"  | j d }|j}t|ƒdkr‹| ¡ }td|gd�}td|gd�}td|gd�}td|gd�}| ||||  |  ¡}	|	d ur�|	| }d| jr�|	| }|	| }|	| }|||  | || |||    }
|||  |||   }tjt	dƒtj
|
  t|ƒ tj
|
 t|ƒ   S d S d S d S rA  )r0   rE  r3  rF  r   rG  rO   r   r„   r   ro   r,  rH  rI  r3   r3   r4   r_   £  rM  zairybi._eval_expand_funcNrN  rO  r3   r3   r3   r4   rH  
  s    Z

rH  c                   @   óV   e Zd ZdZdZdZedd„ ƒZddd„Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ ZdS )r1  a%  
    The derivative $\operatorname{Ai}^\prime$ of the Airy function of the first
    kind.

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

    The Airy function $\operatorname{Ai}^\prime(z)$ is defined to be the
    function

    .. math::
        \operatorname{Ai}^\prime(z) := \frac{\mathrm{d} \operatorname{Ai}(z)}{\mathrm{d} z}.

    Examples
    ========

    Create an Airy function object:

    >>> from sympy import airyaiprime
    >>> from sympy.abc import z

    >>> airyaiprime(z)
    airyaiprime(z)

    Several special values are known:

    >>> airyaiprime(0)
    -3**(2/3)/(3*gamma(1/3))
    >>> from sympy import oo
    >>> airyaiprime(oo)
    0

    The Airy function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(airyaiprime(z))
    airyaiprime(conjugate(z))

    Differentiation with respect to $z$ is supported:

    >>> from sympy import diff
    >>> diff(airyaiprime(z), z)
    z*airyai(z)
    >>> diff(airyaiprime(z), z, 2)
    z*airyaiprime(z) + airyai(z)

    Series expansion is also supported:

    >>> from sympy import series
    >>> series(airyaiprime(z), z, 0, 3)
    -3**(2/3)/(3*gamma(1/3)) + 3**(1/3)*z**2/(6*gamma(2/3)) + O(z**3)

    We can numerically evaluate the Airy function to arbitrary precision
    on the whole complex plane:

    >>> airyaiprime(-2).evalf(50)
    0.61825902074169104140626429133247528291577794512415

    Rewrite $\operatorname{Ai}^\prime(z)$ in terms of hypergeometric functions:

    >>> from sympy import hyper
    >>> airyaiprime(z).rewrite(hyper)
    3**(1/3)*z**2*hyper((), (5/3,), z**3/9)/(6*gamma(2/3)) - 3**(2/3)*hyper((), (1/3,), z**3/9)/(3*gamma(1/3))

    See Also
    ========

    airyai: Airy function of the first kind.
    airybi: Airy function of the second kind.
    airybiprime: Derivative of the Airy function of the second kind.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Airy_function
    .. [2] https://dlmf.nist.gov/9
    .. [3] https://encyclopediaofmath.org/wiki/Airy_functions
    .. [4] https://mathworld.wolfram.com/AiryFunctions.html

    r7   Tc                 C   sR   |j r|tju rtjS |tju rtjS |jr'tjdtddƒ ttddƒƒ  S d S )Nrº   r7   )	r-  r   rs   rt   rp   rW   rw   r   r&   r.  r3   r3   r4   r>     s   

"ÿzairyaiprime.evalc                 C   ó*   |dkr| j d t| j d ƒ S t| |ƒ‚r0  )r0   r,  r	   rD   r3   r3   r4   rF     ó   
zairyaiprime.fdiffc                 C   óR   | j d  |¡}t|ƒ� tj|dd�}W d   ƒ n1 sw   Y  t ||¡S ©Nr   r7   )Ú
derivative)r0   r  r,   r+   r,  r   r  ©r2   rý   r=   Úresr3   r3   r4   rû   !  ó
   
ÿzairyaiprime._eval_evalfc                 K   sP   t ddƒ}t| t ddƒƒ}t|ƒjr&|d t| || ƒt||| ƒ  S d S ©Nr?   rº   )r   r   r"   r`   rQ   ©r2   r=   re   r;  rZ   r3   r3   r4   r²   '  s
   

&ÿz$airyaiprime._eval_rewrite_as_besseljc                 K   s¨   t ddƒ}t ddƒ}|t|t ddƒƒ }t|ƒjr(|d t||ƒt| |ƒ  S t|t ddƒƒ}t||ƒ}t|| ƒ}||d | t||| ƒ |t| || ƒ   S r7  )r   r   r"   r^   rR   rU  r3   r3   r4   r~   -  s   



2z$airyaiprime._eval_rewrite_as_besselic                 K   s„   |d ddt ddƒ  tt ddƒƒ  }dtddƒtt ddƒƒ  }|tg t ddƒg|d d ƒ |tg t ddƒg|d d ƒ  S )Nr?   rº   r7   é   r>  )r   r&   r    r)   r?  r3   r3   r4   r@  9  s   (@z"airyaiprime._eval_rewrite_as_hyperc                 K   s"  | j d }|j}t|ƒdkr‹| ¡ }td|gd�}td|gd�}td|gd�}td|gd�}| ||||  |  ¡}	|	d ur�|	| }d| jr�|	| }|	| }|	| }|| |||   |||  |  }
|||  |||   }tj|
tj	 t
|ƒ |
tj	 tdƒ t|ƒ   S d S d S d S rA  )r0   rE  r3  rF  r   rG  rO   r   r„   ro   r1  r   rT  rI  r3   r3   r4   r_   >  ó*   

$2ízairyaiprime._eval_expand_funcNrN  ©rh   ri   rj   rk   rP  rQ  rm   r>   rF   rû   r²   r~   r@  r_   r3   r3   r3   r4   r1  »  s    Q


r1  c                   @   rV  )rT  a6  
    The derivative $\operatorname{Bi}^\prime$ of the Airy function of the first
    kind.

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

    The Airy function $\operatorname{Bi}^\prime(z)$ is defined to be the
    function

    .. math::
        \operatorname{Bi}^\prime(z) := \frac{\mathrm{d} \operatorname{Bi}(z)}{\mathrm{d} z}.

    Examples
    ========

    Create an Airy function object:

    >>> from sympy import airybiprime
    >>> from sympy.abc import z

    >>> airybiprime(z)
    airybiprime(z)

    Several special values are known:

    >>> airybiprime(0)
    3**(1/6)/gamma(1/3)
    >>> from sympy import oo
    >>> airybiprime(oo)
    oo
    >>> airybiprime(-oo)
    0

    The Airy function obeys the mirror symmetry:

    >>> from sympy import conjugate
    >>> conjugate(airybiprime(z))
    airybiprime(conjugate(z))

    Differentiation with respect to $z$ is supported:

    >>> from sympy import diff
    >>> diff(airybiprime(z), z)
    z*airybi(z)
    >>> diff(airybiprime(z), z, 2)
    z*airybiprime(z) + airybi(z)

    Series expansion is also supported:

    >>> from sympy import series
    >>> series(airybiprime(z), z, 0, 3)
    3**(1/6)/gamma(1/3) + 3**(5/6)*z**2/(6*gamma(2/3)) + O(z**3)

    We can numerically evaluate the Airy function to arbitrary precision
    on the whole complex plane:

    >>> airybiprime(-2).evalf(50)
    0.27879516692116952268509756941098324140300059345163

    Rewrite $\operatorname{Bi}^\prime(z)$ in terms of hypergeometric functions:

    >>> from sympy import hyper
    >>> airybiprime(z).rewrite(hyper)
    3**(5/6)*z**2*hyper((), (5/3,), z**3/9)/(6*gamma(2/3)) + 3**(1/6)*hyper((), (1/3,), z**3/9)/gamma(1/3)

    See Also
    ========

    airyai: Airy function of the first kind.
    airybi: Airy function of the second kind.
    airyaiprime: Derivative of the Airy function of the first kind.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Airy_function
    .. [2] https://dlmf.nist.gov/9
    .. [3] https://encyclopediaofmath.org/wiki/Airy_functions
    .. [4] https://mathworld.wolfram.com/AiryFunctions.html

    r7   Tc                 C   s~   |j r,|tju rtjS |tju rtjS |tju rtjS |jr,dtddƒ ttddƒƒ S |jr=dtddƒ ttddƒƒ S d S )Nrº   r7   rS  )	r-  r   rs   rt   ru   rp   rW   r   r&   r.  r3   r3   r4   r>   ¯  s   


ÿzairybiprime.evalc                 C   rW  r0  )r0   rH  r	   rD   r3   r3   r4   rF   ¿  rX  zairybiprime.fdiffc                 C   rY  rZ  )r0   r  r,   r+   rH  r   r  r\  r3   r3   r4   rû   Å  r^  zairybiprime._eval_evalfc                 K   sR   t ddƒ}|t| t ddƒƒ }t|ƒjr'| tdƒ t| |ƒt||ƒ  S d S r_  r8  r`  r3   r3   r4   r²   Ë  s
   

$ÿz$airybiprime._eval_rewrite_as_besseljc                 K   s°   t ddƒ}t ddƒ}|t|t ddƒƒ }t|ƒjr*|tdƒ t| |ƒt||ƒ  S t|t ddƒƒ}t||ƒ}t|| ƒ}t|ƒ|t| || ƒ |d | t||| ƒ   S r7  r=  rU  r3   r3   r4   r~   Ñ  s   


"
6z$airybiprime._eval_rewrite_as_besselic                 K   s|   |d dt ddƒ ttddƒƒ  }t ddƒttddƒƒ }|tg tddƒg|d d ƒ |tg tddƒg|d d ƒ  S )Nr?   rº   rS  r7   ra  r>  )r    r&   r   r)   r?  r3   r3   r4   r@  Ý  s   $@z"airybiprime._eval_rewrite_as_hyperc                 K   s"  | j d }|j}t|ƒdkr‹| ¡ }td|gd�}td|gd�}td|gd�}td|gd�}| ||||  |  ¡}	|	d ur�|	| }d| jr�|	| }|	| }|	| }|| |||   |||  |  }
|||  |||   }tjt	dƒ|
tj
  t|ƒ |
tj
 t|ƒ   S d S d S d S rA  )r0   rE  r3  rF  r   rG  rO   r   r„   r   ro   r1  rT  rI  r3   r3   r4   r_   â  rb  zairybiprime._eval_expand_funcNrN  rc  r3   r3   r3   r4   rT  X  s    S

rT  c                   @   sF   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )Úmarcumqa—  
    The Marcum Q-function.

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

    The Marcum Q-function is defined by the meromorphic continuation of

    .. math::
        Q_m(a, b) = a^{- m + 1} \int_{b}^{\infty} x^{m} e^{- \frac{a^{2}}{2} - \frac{x^{2}}{2}} I_{m - 1}\left(a x\right)\, dx

    Examples
    ========

    >>> from sympy import marcumq
    >>> from sympy.abc import m, a, b
    >>> marcumq(m, a, b)
    marcumq(m, a, b)

    Special values:

    >>> marcumq(m, 0, b)
    uppergamma(m, b**2/2)/gamma(m)
    >>> marcumq(0, 0, 0)
    0
    >>> marcumq(0, a, 0)
    1 - exp(-a**2/2)
    >>> marcumq(1, a, a)
    1/2 + exp(-a**2)*besseli(0, a**2)/2
    >>> marcumq(2, a, a)
    1/2 + exp(-a**2)*besseli(0, a**2)/2 + exp(-a**2)*besseli(1, a**2)

    Differentiation with respect to $a$ and $b$ is supported:

    >>> from sympy import diff
    >>> diff(marcumq(m, a, b), a)
    a*(-marcumq(m, a, b) + marcumq(m + 1, a, b))
    >>> diff(marcumq(m, a, b), b)
    -a**(1 - m)*b**m*exp(-a**2/2 - b**2/2)*besseli(m - 1, a*b)

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Marcum_Q-function
    .. [2] https://mathworld.wolfram.com/MarcumQ-Function.html

    c                 C   sT  |t ju r |t ju r|t ju rt jS t||d t j ƒt|ƒ S |t ju r7|t ju r7ddt|d t j ƒ  S ||kry|t ju rSdt|d  ƒtd|d ƒ  t j S |dkryt jt jt|d  ƒ td|d ƒ  t|d  ƒtd|d ƒ  S |jr“|jr…|jr…t jS t||d t j ƒt|ƒ S |jr¦|jr¨ddt|d t j ƒ  S d S d S )Nr?   r7   r   )	r   rp   r(   r„   r&   r   ro   rR   rW   )r;   rD  rZ   r¿   r3   r3   r4   r>   -  s$   

&Dÿzmarcumq.evalr?   c                 C   sŠ   | j \}}}|dkr|t|||ƒ td| ||ƒ  S |dkr@||  ||d   t|d |d   d ƒ t|d || ƒ S t| |ƒ‚)Nr?   r7   rº   )r0   rd  r   rR   r	   )r2   rE   rD  rZ   r¿   r3   r3   r4   rF   E  s   "B
zmarcumq.fdiffc                 K   sp   ddl m} | dttdƒjƒ¡}|d|  ||| t|d |d   d ƒ t|d || ƒ ||tj	gƒ S )Nr   )ÚIntegralrY   r7   r?   )
Úsympy.integrals.integralsre  Úgetr   r   Únamer   rR   r   rt   )r2   rD  rZ   r¿   re   re  rY   r3   r3   r4   Ú_eval_rewrite_as_IntegralN  s
   
@ÿz!marcumq._eval_rewrite_as_Integralc                 K   sb   ddl m} | dtdƒ¡}t|d |d   d ƒ||| | t||| ƒ |d| tjgƒ S )Nr   )ÚSumr¯   r?   r7   )Úsympy.concrete.summationsrj  rg  r   r   rR   r   rt   )r2   rD  rZ   r¿   re   rj  r¯   r3   r3   r4   Ú_eval_rewrite_as_SumT  s   Fzmarcumq._eval_rewrite_as_Sumc                    s¢   ˆ |krK|dkrdt ˆ d  ƒtdˆ d ƒ  d S |jrM|dkrOt‡ fdd„td|ƒD ƒƒ}tjt ˆ d  ƒtdˆ d ƒ d  t ˆ d  ƒ|  S d S d S d S )Nr7   r?   r   c                 3   s   � | ]
}t |ˆ d  ƒV  qdS )r?   N)rR   )rÎ   r  ©rZ   r3   r4   Ú	<genexpr>^  s   € z3marcumq._eval_rewrite_as_besseli.<locals>.<genexpr>)r   rR   rñ   Úsumr¥   r   r„   )r2   rD  rZ   r¿   re   r®   r3   rm  r4   r~   Y  s   $8ûz marcumq._eval_rewrite_as_besselic                 C   s   t dd„ | jD ƒƒrdS d S )Nc                 s   s   � | ]}|j V  qd S r9   )rW   )rÎ   r‘   r3   r3   r4   rn  b  s   € z(marcumq._eval_is_zero.<locals>.<genexpr>T)Úallr0   r1   r3   r3   r4   Ú_eval_is_zeroa  s   ÿzmarcumq._eval_is_zeroNrg   )rh   ri   rj   rk   rm   r>   rF   ri  rl  r~   rq  r3   r3   r3   r4   rd  ü  s    0

	rd  c                       ó6   e Zd ZdZ‡ fdd„Zdd„ Zd	‡ fdd„	Z‡  ZS )
rÃ   zq
    Helper function to make the $\mathrm{besseli}(nu, z)$
    function tractable for the Gruntz algorithm.

    c                    óš   ddl m‰  ddlm} |d }|tjtjfv rD| j\‰‰‡ ‡‡fdd„t|ƒD ƒ}t	t
d ƒt|Ž  |dˆtd| d dƒ  |ƒ S tƒ  ||||¡S )Nr   rÉ   rž   r7   c                    rÊ   rË   rÌ   rÍ   rÏ   r3   r4   rÐ   s  ó    ÿÿ$ÿz*_besseli._eval_aseries.<locals>.<listcomp>r?   ©rÓ   r   r    rŸ   r   rt   ru   r0   r¥   r   r   r   r   rŽ   rÔ   ©r2   r{   rÖ   rY   r‰   rŸ   r×   r  r•   rÏ   r4   rÔ   l  ó   
ÿ4z_besseli._eval_aseriesc                 K   s   t | ƒt||ƒ S r9   )r   rR   r}   r3   r3   r4   Ú_eval_rewrite_as_intractabley  r#  z%_besseli._eval_rewrite_as_intractabler   c                    óB   | j d  |d¡}|jr| j| j Ž }| |||¡S tƒ  |||¡S r"  ©r0   ÚlimitrW   rx  r£   rŽ   ©r2   rY   r{   r‰   rŠ   Úx0rb   r•   r3   r4   r£   |  ó
   z_besseli._eval_nseriesr°   ©rh   ri   rj   rk   rÔ   rx  r£   r±   r3   r3   r•   r4   rÃ   e  ó
    rÃ   c                       rr  )
rÛ   zq
    Helper function to make the $\mathrm{besselk}(nu, z)$
    function tractable for the Gruntz algorithm.

    c                    rs  )Nr   rÉ   rž   r7   c                    rß   rà   rÌ   rÍ   rÏ   r3   r4   rÐ   ’  rt  z*_besselk._eval_aseries.<locals>.<listcomp>r?   ru  rv  r•   rÏ   r4   rÔ   ‹  rw  z_besselk._eval_aseriesc                 K   s   t |ƒt||ƒ S r9   )r   rØ   r}   r3   r3   r4   rx  ˜  rÈ   z%_besselk._eval_rewrite_as_intractabler   c                    ry  r"  rz  r|  r•   r3   r4   r£   ›  r~  z_besselk._eval_nseriesr°   r  r3   r3   r•   r4   rÛ   „  r€  rÛ   N)r	  r
  )XÚ	functoolsr   Ú
sympy.corer   Zsympy.core.addr   Úsympy.core.cacher   Úsympy.core.exprr   Úsympy.core.functionr   r	   r
   Úsympy.core.logicr   r   Úsympy.core.numbersr   r   r   Úsympy.core.powerr   Úsympy.core.symbolr   r   r   Úsympy.core.sympifyr   rÓ   r   r   Ú(sympy.functions.elementary.trigonometricr   r   r   r   Ú#sympy.functions.elementary.integersr   Ú&sympy.functions.elementary.exponentialr   r   Ú(sympy.functions.elementary.miscellaneousr   r   r    Ú$sympy.functions.elementary.complexesr!   r"   r#   r$   r%   Ú'sympy.functions.special.gamma_functionsr&   r'   r(   Úsympy.functions.special.hyperr)   Zsympy.polys.orthopolysr*   r  r+   r,   r-   rQ   r€   rR   rØ   rã   rå   rë   rì   rô   rõ   rU   rV   rÿ   rS   rT   r   r!  r,  rH  r1  rT  rd  rÃ   rÛ   r3   r3   r3   r4   Ú<module>   sl    F 1  * B./XB98
8T - 2  %i