
    \h0                    >   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJrJr  S SKJrJr  S SKJrJrJr  S S	KJr  S S
KJrJrJr  S SKJr  S SKJrJr  S SK J!r!J"r"J#r#J$r$  S SK%J&r&  S SK'J(r(J)r)  S SK*J+r+J,r,J-r-  S SK.J/r/J0r0J1r1J2r2J3r3  S SK4J5r5J6r6J7r7  S SK8J9r9  S SK:J;r;  S SK<J=r=J>r>   " S S\5      r? " S S\?5      r@ " S S\?5      rA " S S\?5      rB " S S\?5      rC " S  S!\?5      rD " S" S#\?5      rES$ rF " S% S&\?5      rGS' rHS( rI " S) S*\G5      rJ " S+ S,\G5      rK " S- S.\G5      rL " S/ S0\L5      rM " S1 S2\L5      rNSES3 jrO " S4 S5\5      rP " S6 S7\P5      rQ " S8 S9\P5      rR " S: S;\P5      rS " S< S=\P5      rT " S> S?\5      rU " S@ SA\5      rV " SB SC\5      rWgD)F    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                   j    \ rS rSrSr\S 5       r\S 5       r\S 5       r	SS jr
S rS rS	 rS
 rSrg)
BesselBase$   a  
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                      U R                   S   $ )z'The order of the Bessel-type function. r   argsselfs    V/var/www/auris/envauris/lib/python3.13/site-packages/sympy/functions/special/bessel.pyorderBesselBase.order4        yy|    c                      U R                   S   $ )z*The argument of the Bessel-type function.    r2   r4   s    r6   argumentBesselBase.argument9   r9   r:   c                     g N clsnuzs      r6   evalBesselBase.eval>   s    r:   c                 
   US:w  a  [        X5      eU R                  S-  U R                  U R                  S-
  U R                  5      -  U R
                  S-  U R                  U R                  S-   U R                  5      -  -
  $ N   r<   )r
   _b	__class__r7   r=   _ar5   argindexs     r6   fdiffBesselBase.fdiffB   sn    q=$T44	DNN4::>4==II	DNN4::>4==IIJ 	Kr:   c                     U R                   nUR                  SL a8  U R                  U R                  R	                  5       UR	                  5       5      $ g NF)r=   is_extended_negativerL   r7   	conjugater5   rE   s     r6   _eval_conjugateBesselBase._eval_conjugateH   sB    MM!!U*>>$**"6"6"8!++-HH +r:   c           	         U R                   U R                  pCUR                  U5      (       a  gUR                  X5      (       d  g UR	                  X5      nUR
                  (       aU  [        U [        [        [        [        [        [        45      (       d  UR                  (       d  [        UR                  5      $ [        [!        UR                  UR                  /5      5      $ rS   )r7   r=   has_eval_is_meromorphicsubs
is_integer
isinstancebesseljbesselihn1hn2jnynis_zeror   is_infiniter   )r5   xarD   rE   z0s         r6   r[   BesselBase._eval_is_meromorphicM   s    

DMMA66!99%%a++VVA\==$'3R DEERZZ 002::r~~">?@@r:   c                 `   U R                   U R                  U R                  pCnUR                  (       a  US-
  R                  (       ai  U R
                  * U R                  -  U" US-
  U5      R                  5       -  SU R
                  -  US-
  -  U" US-
  U5      R                  5       -  U-  -   $ US-   R                  (       ah  SU R                  -  US-   -  U" US-   U5      R                  5       -  U-  U R
                  U R                  -  U" US-   U5      R                  5       -  -
  $ U $ Nr<   rJ   )	r7   r=   rL   is_realis_positiverM   rK   _eval_expand_funcis_negative)r5   hintsrD   rE   fs        r6   ro   BesselBase._eval_expand_funcZ   s
   ::t}}dnnq::Q##(261)G)G)II$''	26*1R!VQ<+I+I+KKAMN Oq&%%$''	26*1R!VQ<+I+I+KKAM"q&!(F(F(HHI Jr:   c                     SSK Jn  U" U 5      $ )Nr   )
besselsimp)sympy.simplify.simplifyru   )r5   kwargsru   s      r6   _eval_simplifyBesselBase._eval_simplifye   s    6$r:   rA   NrJ   )__name__
__module____qualname____firstlineno____doc__propertyr7   r=   classmethodrF   rP   rW   r[   ro   rx   __static_attributes__rA   r:   r6   r/   r/   $   s_          KI
A	 r:   r/   c                      ^  \ rS rSrSr\R                  r\R                  r\	S 5       r
S rS rS rU 4S jrS rSU 4S	 jjrS
rU =r$ )r_   j   a  
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                 |   UR                   (       a  UR                   (       a  [        R                  $ UR                  (       a  UR                   SL d  [	        U5      R
                  (       a  [        R                  $ [	        U5      R                  (       a  UR                  SLa  [        R                  $ UR                  (       a  [        R                  $ U[        R                  [        R                  4;   a  [        R                  $ UR                  5       (       a  X!-  U* U* -  -  [        X* 5      -  $ UR                  (       ah  UR                  5       (       a"  [        R                  U* -  [        U* U5      -  $ UR!                  ["        5      nU(       a  ["        U-  [%        X5      -  $ UR                  (       a  ['        U5      nX2:w  a  [        X5      $ OCUR)                  5       u  p4US:w  a+  [+        SU-  [,        -  U-  ["        -  5      [        X5      -  $ ['        U5      nX:w  a  [        XR5      $ g )NFTr   rJ   )re   r   Oner]   r#   rn   Zerorp   ComplexInfinityis_imaginaryNaNInfinityNegativeInfinitycould_extract_minus_signr_   NegativeOneextract_multiplicativelyr   r`   r&   extract_branch_factorr   r   rC   rD   rE   newznnnus         r6   rF   besselj.eval   s   99zzuu--BJJ%$7BrF<N<NvvB##R]]d-B(((uuQ//0066M%%''7QB2#;&wr266==**,,}}s+GRCO;;--a0D2wwr000 ==a=Dyr((  --/GDAv1Q3r6"9Q;'(999n93?" r:   c                 v    [        [        [        -  U-  S-  5      [        U[	        [        * 5      U-  5      -  $ NrJ   )r   r   r   r`   r%   r5   rD   rE   rw   s       r6   _eval_rewrite_as_besseli besselj._eval_rewrite_as_besseli   s/    1R4719~gb*aR.*:;;;r:   c                     UR                   SL a?  [        [        U-  5      [        U* U5      -  [	        [        U-  5      [        X5      -  -
  $ g rS   )r]   r   r   besselyr   r   s       r6   _eval_rewrite_as_bessely besselj._eval_rewrite_as_bessely   sD    ==E!r"u:grc1o-BrE
72>0III "r:   c                 |    [        SU-  [        -  5      [        U[        R                  -
  U R
                  5      -  $ r   )r    r   rc   r   Halfr=   r   s       r6   _eval_rewrite_as_jnbesselj._eval_rewrite_as_jn   s,    AaCF|BrAFF{DMM:::r:   c                   > U R                   u  pE UR                  U5      nUR                  U5      u  pxUR                  (       a  Xd-  SU-  [        US-   5      -  -  $ UR                  (       aa  US:X  a  SOUnXsU-  -  n	U	R                  (       d=  [        S5      [        U[        SU-  S-   -  S-  -
  5      -  [        [        U-  5      -  $ U $ [        [        U ]3  XUS9$ ! [         a    U s $ f = f)NrJ   r<   r      logxcdir)r3   as_leading_termNotImplementedErroras_coeff_exponentrn   r'   rp   r    r   r   superr_   _eval_as_leading_termr5   rg   r   r   rD   rE   argcesignrL   s             r6   r   besselj._eval_as_leading_term   s    			##A&C $$Q'==7ArE%Q-/00]]	1tD1W9D## Aws1r1R4!8}Q#677RT
BBKWd9!T9RR # 	K	s   C# #C21C2c                 h    U R                   u  pUR                  (       a  UR                  (       a  gg g NTr3   r]   is_extended_realr5   rD   rE   s      r6   _eval_is_extended_realbesselj._eval_is_extended_real   &    		==Q// 0=r:   c                   > SSK Jn  U R                  u  pg UR                  U5      u  pU	R                  (       a  [        X)-  5      n
U" X-  U5      nUS-  R                  XX45      R                  5       nU[        R                  L a  U$ [        US-  5      U-   R                  5       nX-  [        US-   5      -  nU/n[        SU
S-   S-  5       H>  nX* UUU-   -  -  -  n[        U5      U-   R                  5       nUR                  U5        M@     [!        U6 U-   $ ["        [$        U ]#  XX45      $ ! [        [
        4 a    U s $ f = fNr   OrderrJ   r<   )sympy.series.orderr   r3   leadterm
ValueErrorr   rn   r   _eval_nseriesremoveOr   r   r   r'   rangeappendr   r   r_   r5   rg   r   r   r   r   rD   rE   _r   newnorttermskrL   s                    r6   r   besselj._eval_nseries   s>    	-			ZZ]FA ??15>DadAA1##A$5==?AAFF{!Q$!#,,.A5rAv&DA1tax!m,ArAvJ' *335 - 7Q;Wd1!CC' /0 	K	s   D3 3EErA   r   )r{   r|   r}   r~   r   r   r   rM   rK   r   rF   r   r   r   r   r   r   r   __classcell__rL   s   @r6   r_   r_   j   sX    BH 
B	
B!# !#F<J;S*
D Dr:   r_   c                      ^  \ rS rSrSr\R                  r\R                  r\	S 5       r
S rS rS rU 4S jrS rSU 4S	 jjrS
rU =r$ )r   i  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                 4   UR                   (       as  UR                   (       a  [        R                  $ [        U5      R                   SL a  [        R                  $ [        U5      R                   (       a  [        R
                  $ U[        R                  [        R                  4;   a  [        R                  $ U[        [        R                  -  :X  a0  [        [        [        -  US-   -  S-  5      [        R                  -  $ U[        [        R                  -  :X  a1  [        [        * [        -  US-   -  S-  5      [        R                  -  $ UR                  (       a8  UR                  5       (       a"  [        R                  U* -  [        U* U5      -  $ g g )NFr<   rJ   )re   r   r   r#   r   r   r   r   r   r   r   r]   r   r   r   rB   s      r6   rF   bessely.evalF  s   99zz)))B5((((BuuQ//0066M!**qtR!V}Q'!**44!$$$$r"ub1f~a'(1::55==**,,}}s+GRCO;; - r:   c                     UR                   SL a?  [        [        U-  5      [        [        U-  5      [	        X5      -  [	        U* U5      -
  -  $ g rS   )r]   r   r   r   r_   r   s       r6   _eval_rewrite_as_besselj bessely._eval_rewrite_as_besseljZ  sD    ==E!r"u:s2b5z'".87B3?JKK "r:   c                 n    U R                   " U R                  6 nU(       a  UR                  [        5      $ g r@   )r   r3   rewriter`   r5   rD   rE   rw   ajs        r6   r    bessely._eval_rewrite_as_besseli^  -    **DII6::g&& r:   c                 |    [        SU-  [        -  5      [        U[        R                  -
  U R
                  5      -  $ r   )r    r   rd   r   r   r=   r   s       r6   _eval_rewrite_as_ynbessely._eval_rewrite_as_ync  s,    AaCF|baffdmm<<<r:   c                   > U R                   u  pE UR                  U5      nUR                  U5      u  pxUR                  (       a  S[
        -  [        US-  5      -  [        XE5      -  n	UR                  (       a   US-  U* -  * [        US-
  5      -  [
        -  O[        R                  n
US-  U-  * [
        [        U5      -  -  [        US-   5      [        R                  -
  -  n[        XU/6 R                  XS9nU$ UR                  (       a  US:X  a  SOUnXsU-  -  nUR                  (       dz  [        S5      [!        [
        U-  S-  U-
  [
        S-  -   5      * S[#        [
        U-  S-  U-
  [
        S-  -   5      -  SU-  -  -   -  [        SU-  5      -  [        [
        5      -  $ U $ [$        [&        U ]S  XUS9$ ! [         a    U s $ f = f)	NrJ   r<   r   r   r         r   )r3   r   r   r   rn   r   r   r_   r   r   r   r(   
EulerGammar   rp   r    r   r   r   r   r   )r5   rg   r   r   rD   rE   r   r   r   term_oneterm_two
term_threer   rL   s                r6   r   bessely._eval_as_leading_termf  s   			##A&C $$Q'==2s1Q3x6H>@=M=M1}YrAv%66r9STSYSYHQ3)R	"%56Q!,,8VWJJ78HHHVCJ]]	1tD1W9D## AwRU1Wq[2a4%7!8 81SBq1rRStAS=T;TVWXYVY;Z Z[\`abcdad\eefjkmfnnnKWd9!T9RR' # 	K	s   G GGc                 h    U R                   u  pUR                  (       a  UR                  (       a  gg g r   r3   r]   rn   r   s      r6   r   bessely._eval_is_extended_real  $    		==Q]] +=r:   c                 N  > SSK Jn  U R                  u  pg UR                  U5      u  pU	R                  (       Ga?  UR                  (       Ga-  [        X)-  5      n
[        Xg5      nS[        -  [        US-  5      -  U-  R                  XX45      n/ / pU" X-  U5      nUS-  R                  XX45      R                  5       nU[        R                  L a  U$ [!        US-  5      U-   R                  5       nU[        R                  :  a  UU* -  [#        US-
  5      -  [        -  nUR%                  U5        ['        SU5       H]  nUU-
  U-  nU[        R                  :X  a	  UUU-  -  nOUUU-  -  n[!        U5      U-   R                  5       nUR%                  U5        M_     UU-  [        [#        U5      -  -  nU[)        US-   5      [        R*                  -
  -  nUR%                  U5        ['        SU
S-   S-  5       Hb  nUU* UUU-   -  -  -  n[!        U5      U-   R                  5       nU[)        UU-   S-   5      [)        US-   5      -   -  nUR%                  U5        Md     U[-        U6 -
  [-        U6 -
  $ [.        [0        U ]3  XX45      $ ! [        [
        4 a    U s $ f = fr   )r   r   r3   r   r   r   rn   r]   r   r_   r   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   )r5   rg   r   r   r   r   rD   rE   r   r   r   bnrh   br   r   r   r   r   r   denomprL   s                         r6   r   bessely._eval_nseries  sj    	-			ZZ]FA ???r}}}15>DBB$AaC#221DArqadAA1##A$5==?AAFF{!Q$!#,,.AAFF{B3x	"q& 11"4q"A!VQJE!%$TNQ.779DHHTN & 2r)B-'(Agb1fo45DHHTN1tax!m,aRAF_$a[1_--/'!b&1*-A>?	 -
 sAw;a((Wd1!CCK /0 	K	s   J J$#J$rA   r   )r{   r|   r}   r~   r   r   r   rM   rK   r   rF   r   r   r   r   r   r   r   r   r   s   @r6   r   r     sV    &P 
B	
B< <&L'
=S2
/D /Dr:   r   c                      ^  \ rS rSrSr\R                  * r\R                  r\	S 5       r
SS jrS rS rS rS rU 4S	 jrSU 4S
 jjrU 4S jrSrU =r$ )r`   i  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                     UR                   (       a  UR                   (       a  [        R                  $ UR                  (       a  UR                   SL d  [	        U5      R
                  (       a  [        R                  $ [	        U5      R                  (       a  UR                  SLa  [        R                  $ UR                  (       a  [        R                  $ [        U5      [        R                  [        R                  4;   a  [        R                  $ U[        R                  L a  [        R                  $ U[        R                  L a  SU-  [        R                  -  $ UR                  5       (       a  X!-  U* U* -  -  [        X* 5      -  $ UR                  (       aU  UR                  5       (       a  [        U* U5      $ UR!                  ["        5      nU(       a  ["        U* -  [%        X* 5      -  $ UR                  (       a  ['        U5      nX2:w  a  [        X5      $ OCUR)                  5       u  p4US:w  a+  [+        SU-  [,        -  U-  ["        -  5      [        X5      -  $ ['        U5      nX:w  a  [        XR5      $ g )NFTr   rJ   )re   r   r   r]   r#   rn   r   rp   r   r   r   r$   r   r   r   r`   r   r   r_   r&   r   r   r   r   s         r6   rF   besseli.eval  s   99zzuu--BJJ%$7BrF<N<NvvB##R]]d-B(((uua5QZZ!3!34466M

?::"""8AJJ&&%%''7QB2#;&wr266==**,,sA&--a0DB3xE 222 ==a=Dyr((  --/GDAv1Q3r6"9Q;'(999n93?" r:   c                 T    UR                   (       a  [        U5      [        X5      -  $ g r@   )r   r   _besselir5   rD   rE   limitvarrw   s        r6   _eval_rewrite_as_tractable"besseli._eval_rewrite_as_tractable	  s#    q6(2/)) r:   c                 v    [        [        * [        -  U-  S-  5      [        U[	        [        5      U-  5      -  $ r   )r   r   r   r_   r%   r   s       r6   r    besseli._eval_rewrite_as_besselj  s.    A2b58A:wr:a=?;;;r:   c                 n    U R                   " U R                  6 nU(       a  UR                  [        5      $ g r@   r   r3   r   r   r   s        r6   r    besseli._eval_rewrite_as_bessely  r   r:   c                 Z    U R                   " U R                  6 R                  [        5      $ r@   )r   r3   r   rc   r   s       r6   r   besseli._eval_rewrite_as_jn  s"    ,,dii8@@DDr:   c                 h    U R                   u  pUR                  (       a  UR                  (       a  gg g r   r   r   s      r6   r   besseli._eval_is_extended_real  r   r:   c                   > U R                   u  pE UR                  U5      nUR                  U5      u  pxUR                  (       a  Xd-  SU-  [        US-   5      -  -  $ UR                  (       aE  US:X  a  SOUnXsU-  -  n	U	R                  (       d!  [        U5      [        S[        -  U-  5      -  $ U $ [        [        U ]3  XUS9$ ! [         a    U s $ f = f)NrJ   r<   r   r   )r3   r   r   r   rn   r'   rp   r   r    r   r   r`   r   r   s             r6   r   besseli._eval_as_leading_term  s    			##A&C $$Q'==7ArE%Q-/00]]	1tD1W9D## 1vd1R46l**KWd9!T9RR # 	K	s   C CCc                   > SSK Jn  U R                  u  pg UR                  U5      u  pU	R                  (       a  [        X)-  5      n
U" X-  U5      nUS-  R                  XX45      R                  5       nU[        R                  L a  U$ [        US-  5      U-   R                  5       nX-  [        US-   5      -  nU/n[        SU
S-   S-  5       H=  nXUUU-   -  -  -  n[        U5      U-   R                  5       nUR                  U5        M?     [!        U6 U-   $ ["        [$        U ]#  XX45      $ ! [        [
        4 a    U s $ f = fr   )r   r   r3   r   r   r   rn   r   r   r   r   r   r   r'   r   r   r   r   r`   r   s                    r6   r   besseli._eval_nseries2  s<    	-			ZZ]FA ??15>DadAA1##A$5==?AAFF{!Q$!#,,.A5rAv&DA1tax!m,1b1f:& *335 - 7Q;Wd1!CC' /0 	K	s   D2 2EEc           
      .  > SSK Jn  SSKJn  US   nU[        R
                  [        R                  4;   a  U R                  u  p[        U5       V
s/ s H^  n
U" [        SU-  S-
  S5      U
5      U" [        SU-  S-   S5      U
5      -  SU
-  U	[        SU
-  S-   S5      -  -  [        U
5      -  -  PM`     sn
U" SU	[        SU-  S-   S5      -  -  U5      /-   n[        U	5      [        S[        -  5      -  [        U6 -  $ [        TU ]A  XX45      $ s  sn
f Nr   r   r   r<   rJ   (sympy.functions.combinatorial.factorialsr   r   r   r   r   r   r3   r   r   r   r   r    r   r   r   _eval_aseriesr5   r   args0rg   r   r   r   pointrD   rE   r   r   rL   s               r6   r  besseli._eval_aseriesQ  s+   L,aQZZ!3!344IIEBGLQxQGO! "(1R4!8Q"7;OHUVWYUY\]U]_`Lacd<ee1Xa(1Q37A.//	!<>GOQTYZ[\]`hijklilopiprs`t\uZuwxTySz{Aq6$qt*$Q00w$Qq77	Qs   A%DrA   r@   r   )r{   r|   r}   r~   r   r   r   rM   rK   r   rF   r   r   r   r   r   r   r   r  r   r   r   s   @r6   r`   r`     sb    %N %%B	
B%# %#N*<'
E
S*D>8 8r:   r`   c                      ^  \ rS rSrSr\R                  r\R                  * r\	S 5       r
S rS rS rS rS rSS	 jrS
 rSU 4S jjrU 4S jrSrU =r$ )besselki_  a  
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                    UR                   (       as  UR                   (       a  [        R                  $ [        U5      R                   SL a  [        R                  $ [        U5      R                   (       a  [        R
                  $ U[        R                  [        [        R                  -  [        [        R                  -  4;   a  [        R                  $ UR                  (       a#  UR                  5       (       a  [        U* U5      $ g g rS   )re   r   r   r#   r   r   r   r   r   r]   r   r  rB   s      r6   rF   besselk.eval  s    99zzzz!B5((((BuuQqzz\1Q-?-?+?@@66M==**,,sA& - r:   c                     UR                   SL a6  [        [        [        U-  5      -  [        U* U5      [        X5      -
  -  S-  $ g )NFrJ   )r]   r   r   r`   r   s       r6   r    besselk._eval_rewrite_as_besseli  s@    ==E!c"R%j='2#q/GBN"BCAEE "r:   c                 n    U R                   " U R                  6 nU(       a  UR                  [        5      $ g r@   )r   r3   r   r_   )r5   rD   rE   rw   ais        r6   r    besselk._eval_rewrite_as_besselj  r   r:   c                 n    U R                   " U R                  6 nU(       a  UR                  [        5      $ g r@   r  r   s        r6   r    besselk._eval_rewrite_as_bessely  r   r:   c                 n    U R                   " U R                  6 nU(       a  UR                  [        5      $ g r@   )r   r3   r   rd   )r5   rD   rE   rw   ays        r6   r   besselk._eval_rewrite_as_yn  s,    **DII6::b>! r:   c                 h    U R                   u  pUR                  (       a  UR                  (       a  gg g r   r   r   s      r6   r   besselk._eval_is_extended_real  r   r:   c                 V    UR                   (       a  [        U* 5      [        X5      -  $ g r@   )r   r   _besselkr   s        r6   r   "besselk._eval_rewrite_as_tractable  s%    r78B?** r:   c                 r   U R                   u  pE UR                  U5      nUR                  U5      u  pxUR                  (       a  UR
                  (       a*  [        U5      * [        R                  -
  [        S5      -   n	OKUR                  (       a+  [        [        U5      5      US-  [        U5      * -  -  S-  n	O[        SU S35      eU	R                  XS9$ UR                  (       a+  [        [        5      [        U* 5      -  [        SU-  5      -  $ U R!                  XF5      $ ! [         a    U s $ f = f)NrJ   z"Cannot proceed without knowing if z is zero or not.r   )r3   r   r   r   rn   re   r   r   r   
is_nonzeror'   r"   rp   r    r   r   func)
r5   rg   r   r   rD   rE   r   r   r   r   s
             r6   r   besselk._eval_as_leading_term  s   			##A&C $$Q'==zzAw-A6SW~qss2wh&779),NrdRb*cdd'''55]]8CI%d1S5k1199R%%' # 	K	s   D' 'D65D6c                 R  > SSK Jn  U R                  u  pg UR                  U5      u  pU	R                  (       GaA  US-  R                  XX45      R                  5       n
U
[        R                  L a  U" Xv* -  Xv-  -   U5      $ U" X-  U5      nUR                  (       Ga  [        X)-  5      n[        Xg5      nSUS-
  -  [        US-  5      -  U-  R                  XX45      n/ / nn[        U
S-  5      nU[        R                  :  av  X* -  [!        US-
  5      -  S-  nUR#                  U5        [%        SU5       H>  nUUUU-
  U-  -  -  n[        U5      U-   R                  5       nUR#                  U5        M@     X-  SU-  -  S[!        U5      -  -  nU['        US-   5      [        R(                  -
  -  nUR#                  U5        [%        SUS-   S-  5       Ha  nUUUUU-   -  -  -  n[        U5      U-   R                  5       nU['        UU-   S-   5      ['        US-   5      -   -  nUR#                  U5        Mc     U[+        U6 -   [+        U6 -   U-   $ UR,                  (       Ga  [        X&-   U	-  5      n[        X&-
  U	-  5      n/ / p[%        US-   S-  5       HS  n[/        U5      U
SU-  U-
  -  -  S[1        SU-
  U5      -  [!        U5      -  -  nUR#                  [        U5      5        MU     [%        US-   S-  5       HT  n[/        U* 5      U
SU-  U-   -  -  S[1        US-   U5      -  [!        U5      -  -  nUR#                  [        U5      5        MV     [+        U6 [+        U6 -   U-   $ [        S5      e[2        [4        U ]  XX45      $ ! [        [
        4 a    U s $ f = f)Nr   r   rJ   r   r<   z4besselk expansion is only implemented for real order)r   r   r3   r   r   r   rn   r   r   r   r   r]   r   r`   r   r   r   r   r   r(   r   r   is_nonintegerr'   r   r   r  )r5   rg   r   r   r   r   rD   rE   r   r   r   r   r   r   rh   r   r   r   r   r   r   newn_anewn_brL   s                          r6   r   besselk._eval_nseries  s~   ,			ZZ]FA ???1##A$5==?AAFF{QX-q11adAA}}}qu~R^BF^C!H,R/>>qTP21QTN;s8Ib1f$55a7DHHTN"1b\AFA:. ( 2;;= *
 E2(NAimO4'"q&/ALL89q4!8a-0AAq2vJ'A!!q113Aga"fqj1GAENBCDHHTN	 1
 37{S!W,q00!!! !!$, !$,21q1}-A 9Q1R[0!OAbD!4L2LYWX\2YZDHHXd^, . q1}-A ":a!A#b&k11_RT15M3MiXYl3Z[DHHXd^, . Awa(1,,)*`aaWd1!CC{ /0 	K	s   N N&%N&c           
      0  > SSK Jn  SSKJn  US   nU[        R
                  [        R                  4;   a  U R                  u  p[        U5       V
s/ s H^  n
U" [        SU-  S-
  S5      U
5      U" [        SU-  S-   S5      U
5      -  SU
-  U	[        SU
-  S-   S5      -  -  [        U
5      -  -  PM`     sn
U" SU	[        SU-  S-   S5      -  -  U5      /-   n[        U	* 5      [        [        S-  5      -  [        U6 -  $ [        TU ]A  XX45      $ s  sn
f Nr   r  r   r<   rJ   r  r  s               r6   r  besselk._eval_aseries  s-   L,aQZZ!3!344IIEBHMaRHP1 "(1R4!8Q"7;OHUVWYUY\]U]_`Lacd<eeAYq8AaC!GQ/001=?HPRTYZ[\]`hijklilopiprs`t\uZuwxTySz{AGDAJ&Q//w$Qq77	Rs   A%DrA   r@   r   )r{   r|   r}   r~   r   r   r   rM   rK   r   rF   r   r   r   r   r   r   r   r   r  r   r   r   s   @r6   r  r  _  sg    #J 
B
%%B' 'F'
'
"

+&2CDJ8 8r:   r  c                   N    \ rS rSrSr\R                  r\R                  rS r	Sr
g)hankel1i   aL  
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                     U R                   nUR                  SL a2  [        U R                  R	                  5       UR	                  5       5      $ g rS   )r=   rT   hankel2r7   rU   rV   s     r6   rW   hankel1._eval_conjugateH  >    MM!!U*4:://11;;=AA +r:   rA   Nr{   r|   r}   r~   r   r   r   rM   rK   rW   r   rA   r:   r6   r7  r7     s"    "H 
B	
BBr:   r7  c                   N    \ rS rSrSr\R                  r\R                  rS r	Sr
g)r9  iN  az  
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                     U R                   nUR                  SL a2  [        U R                  R	                  5       UR	                  5       5      $ g rS   )r=   rT   r7  r7   rU   rV   s     r6   rW   hankel2._eval_conjugatew  r;  r:   rA   Nr<  rA   r:   r6   r9  r9  N  s"    #J 
B	
BBr:   r9  c                 0   ^  [        T 5      U 4S j5       nU$ )Nc                 :   > UR                   (       a	  T" XU5      $ g r@   )r]   )r5   rD   rE   fns      r6   gassume_integer_order.<locals>.g~  s    ==d?" r:   r   )rB  rC  s   ` r6   assume_integer_orderrE  }  s     
2Y# # Hr:   c                   .    \ rS rSrSrS rS rSS jrSrg)	SphericalBesselBasei  a  
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                     [        S5      e)z?Expand self into a polynomial. Nu is guaranteed to be Integer. 	expansionr   r5   rq   s     r6   _expandSphericalBesselBase._expand  s    !+..r:   c                 `    U R                   R                  (       a  U R                  " S0 UD6$ U $ NrA   )r7   
is_IntegerrL  rK  s     r6   ro   %SphericalBesselBase._eval_expand_func  s&    ::  <<(%((r:   c                     US:w  a  [        X5      eU R                  U R                  S-
  U R                  5      X R                  S-   -  U R                  -  -
  $ rI   )r
   rL   r7   r=   rN   s     r6   rP   SphericalBesselBase.fdiff  sO    q=$T44~~djj1ndmm<JJN#DMM12 	2r:   rA   Nrz   )	r{   r|   r}   r~   r   rL  ro   rP   r   rA   r:   r6   rG  rG    s    	/
2r:   rG  c                     [        X5      [        U5      -  [        R                  U S-   -  [        U * S-
  U5      -  [	        U5      -  -   $ Nr<   )r+   r   r   r   r   r   rE   s     r6   _jnrW    sK    %c!f,MMAE"#6rAvq#AA#a&HI Jr:   c                     [         R                  U S-   -  [        U * S-
  U5      -  [        U5      -  [        X5      [	        U5      -  -
  $ rU  )r   r   r+   r   r   rV  s     r6   _ynrY    sI    MMAE"%8!a%CCCFJ%c!f,- .r:   c                   F    \ rS rSrSr\S 5       rS rS rS r	S r
S rS	rg
)rc   i  aV  
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                 T   UR                   (       ac  UR                   (       a  [        R                  $ UR                  (       a1  UR                  (       a  [        R
                  $ [        R                  $ U[        R                  [        R                  4;   a  [        R
                  $ g r@   )	re   r   r   r]   rn   r   r   r   r   rB   s      r6   rF   jn.eval  sa    99zzuu>>66M,,,##QZZ0066M 1r:   c                 h    [        [        SU-  -  5      [        U[        R                  -   U5      -  $ r   )r    r   r_   r   r   r   s       r6   r   jn._eval_rewrite_as_besselj  s(    B!H~QVVQ 777r:   c                     [         R                  U-  [        [        SU-  -  5      -  [	        U* [         R
                  -
  U5      -  $ r   )r   r   r    r   r   r   r   s       r6   r   jn._eval_rewrite_as_bessely  s8    }}b 4AaC>1GRC!&&L!4LLLr:   c                 J    [         R                  U-  [        U* S-
  U5      -  $ rU  )r   r   rd   r   s       r6   r   jn._eval_rewrite_as_yn  s"    }}r"Ra^33r:   c                 B    [        U R                  U R                  5      $ r@   )rW  r7   r=   rK  s     r6   rL  
jn._expand      4::t}}--r:   c                     U R                   R                  (       a$  U R                  [        5      R	                  U5      $ g r@   r7   rP  r   r_   _eval_evalfr5   precs     r6   rh  jn._eval_evalf  .    ::  <<(44T:: !r:   rA   N)r{   r|   r}   r~   r   r   rF   r   r   r   rL  rh  r   rA   r:   r6   rc   rc     s6    8r 
 
8M4.;r:   rc   c                   J    \ rS rSrSr\S 5       r\S 5       rS rS r	S r
Srg	)
rd   i  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                     [         R                  US-   -  [        [        SU-  -  5      -  [	        U* [         R
                  -
  U5      -  $ rl   )r   r   r    r   r_   r   r   s       r6   r   yn._eval_rewrite_as_besselj3  s<    }}r!t$tB!H~5affa8PPPr:   c                 h    [        [        SU-  -  5      [        U[        R                  -   U5      -  $ r   )r    r   r   r   r   r   s       r6   r   yn._eval_rewrite_as_bessely7  s(    B!H~QVVQ 777r:   c                 P    [         R                  US-   -  [        U* S-
  U5      -  $ rU  )r   r   rc   r   s       r6   r   yn._eval_rewrite_as_jn;  s&    }}rAv&RC!GQ77r:   c                 B    [        U R                  U R                  5      $ r@   )rY  r7   r=   rK  s     r6   rL  
yn._expand>  re  r:   c                     U R                   R                  (       a$  U R                  [        5      R	                  U5      $ g r@   )r7   rP  r   r   rh  ri  s     r6   rh  yn._eval_evalfA  rl  r:   rA   N)r{   r|   r}   r~   r   rE  r   r   r   rL  rh  r   rA   r:   r6   rd   rd     sA    -\ Q Q 8 88.;r:   rd   c                   R    \ rS rSr\S 5       r\S 5       rS rS rS r	S r
S rS	rg
)SphericalHankelBaseiF  c                     U R                   n[        [        SU-  -  5      [        U[        R
                  -   U5      U[        -  [        R                  US-   -  -  [        U* [        R
                  -
  U5      -  -   -  $ rI   )_hankel_kind_signr    r   r_   r   r   r   r   r5   rD   rE   rw   hkss        r6   r   ,SphericalHankelBase._eval_rewrite_as_besseljH  sq    
 $$B!H~wrAFF{A6"1uQ]]RT%::7B3<QR;SS T U 	Ur:   c                     U R                   n[        [        SU-  -  5      [        R                  U-  [        U* [        R                  -
  U5      -  U[        -  [        U[        R                  -   U5      -  -   -  $ r   )r{  r    r   r   r   r   r   r   r|  s        r6   r   ,SphericalHankelBase._eval_rewrite_as_besselyQ  si    
 $$B!H~q}}b0"qvvq1II"1uWR!&&[!%<< = > 	>r:   c                     U R                   n[        X5      R                  [        5      U[        -  [        X5      -  -   $ r@   )r{  rc   r   rd   r   r|  s        r6   r   'SphericalHankelBase._eval_rewrite_as_ynZ  s3    $$"y  $s1uRY66r:   c                     U R                   n[        X5      U[        -  [        X5      R	                  [        5      -  -   $ r@   )r{  rc   r   rd   r   r|  s        r6   r   'SphericalHankelBase._eval_rewrite_as_jn^  s4    $$"y3q5B!2!22!6666r:   c                     U R                   R                  (       a  U R                  " S0 UD6$ U R                   nU R                  nU R                  n[        X#5      U[        -  [        X#5      -  -   $ rO  )r7   rP  rL  r=   r{  rc   r   rd   )r5   rq   rD   rE   r}  s        r6   ro   %SphericalHankelBase._eval_expand_funcb  sY    ::  <<(%((BA((Cb9s1uRY..r:   c                     U R                   nU R                  nU R                  n[        X#5      U[        -  [        X#5      -  -   R                  5       $ r@   )r7   r=   r{  rW  r   rY  expand)r5   rq   r   rE   r}  s        r6   rL  SphericalHankelBase._expandk  sE    JJMM$$ A	CE#a)O+3355r:   c                     U R                   R                  (       a$  U R                  [        5      R	                  U5      $ g r@   rg  ri  s     r6   rh  SphericalHankelBase._eval_evalfz  rl  r:   rA   N)r{   r|   r}   r~   rE  r   r   r   r   ro   rL  rh  r   rA   r:   r6   ry  ry  F  sC    U U > >77/6;r:   ry  c                   @    \ rS rSrSr\R                  r\S 5       r	Sr
g)ra   i  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                 D    [        [        SU-  -  5      [        X5      -  $ r   )r    r   r7  r   s       r6   _eval_rewrite_as_hankel1hn1._eval_rewrite_as_hankel1      B!H~gbn,,r:   rA   N)r{   r|   r}   r~   r   r   r   r{  rE  r  r   rA   r:   r6   ra   ra     s&    .` - -r:   ra   c                   B    \ rS rSrSr\R                  * r\S 5       r	Sr
g)rb   i  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                 D    [        [        SU-  -  5      [        X5      -  $ r   )r    r   r9  r   s       r6   _eval_rewrite_as_hankel2hn2._eval_rewrite_as_hankel2  r  r:   rA   N)r{   r|   r}   r~   r   r   r   r{  rE  r  r   rA   r:   r6   rb   rb     s(    .` - -r:   rb   c                 0  ^ ^^^^ SSK Jn  TS:X  at  SSKJn  SSKJn  U" U5      n[        SUS-   5       Vs/ s HE  n[        R                  " U" [        T S-   5      R                  U5      [        U5      5      U5      PMG     sn$ TS:X  a  SS	KJm   SS
KJm  U U4S jn	O[%        S5      eUU4S jn
T U-   nU
" X5      nU/n[        US-
  5       H  nU
" XU-   5      nUR'                  U5        M!     U$ s  snf ! [          a    SSKJm  U U4S jn	 Nhf = f)a1  
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   sympy)besseljzero)dps_to_precr<   g      ?scipy)newton)spherical_jnc                    > T" TU 5      $ r@   rA   )rg   r   r  s    r6   <lambda>jn_zeros.<locals>.<lambda>)  s    ,q!,r:   )sph_jnc                 "   > T" TU 5      S   S   $ )Nr   r   rA   )rg   r   r  s    r6   r  r  ,  s    &A,q/"-r:   Unknown method.c                 :   > TS:X  a
  T" X5      nU$ [        S5      e)Nr  r  rJ  )rr   rg   r!   methodr  s      r6   solverjn_zeros.<locals>.solver0  s)    W!<D  &&788r:   )mathr   mpmathr  mpmath.libmp.libmpfr  r   r   _from_mpmathr   
_to_mpmathintscipy.optimizer  scipy.specialr  ImportErrorr  r   r   )r   r   r  dpsmath_pir  r  rj  lrr   r  r!   rootsir  r  r  s   ` `           @@@r6   jn_zerosr    s   Z #&33 q!a%*(A !!+aCj.C.CD.I.1!f#67;=(* 	* 
7	)	.2,A
 ""344 w;D!?DFE1q5\a(T  L=*  	.,-A	.s   AC6C; ;DDc                   8    \ rS rSrSrS rS rS	S jrS	S jrSr	g)
AiryBaseiC  z[
Abstract base class for Airy functions.

This class is meant to reduce code duplication.

c                 Z    U R                  U R                  S   R                  5       5      $ Nr   )r+  r3   rU   r4   s    r6   rW   AiryBase._eval_conjugateK  s"    yy1//122r:   c                 4    U R                   S   R                  $ r  )r3   r   r4   s    r6   r   AiryBase._eval_is_extended_realN  s    yy|,,,r:   c                     U R                   S   nUR                  5       nU R                  nU" U5      U" U5      -   S-  n[        U" U5      U" U5      -
  -  S-  nXg4$ )Nr   rJ   )r3   rU   r+  r   )r5   deeprq   rE   zcrr   uvs           r6   as_real_imagAiryBase.as_real_imagQ  sY    IIaL[[]IIqT!B%ZNquQqTzN1tr:   c                 D    U R                   " SSU0UD6u  p4X4[        -  -   $ )Nr  rA   )r  r   )r5   r  rq   re_partim_parts        r6   _eval_expand_complexAiryBase._eval_expand_complexY  s*    ,,@$@%@""r:   rA   N)T)
r{   r|   r}   r~   r   rW   r   r  r  r   rA   r:   r6   r  r  C  s    3-#r:   r  c                   l    \ rS rSrSrSrSr\S 5       rSS jr	\
\S 5       5       rS rS	 rS
 rS rSrg)airyaii^  a  
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

r<   Tc                    UR                   (       a  U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ U[        R
                  L a  [        R                  $ UR                  (       a6  [        R                  S[        SS5      -  [        [        SS5      5      -  -  $ UR                  (       a6  [        R                  S[        SS5      -  [        [        SS5      5      -  -  $ g )Nr   rJ   )
	is_Numberr   r   r   r   r   re   r   r   r'   rC   r   s     r6   rF   airyai.eval  s    ==aee|uu

"vv***vvuu8Aq> 1E(1a.4I IJJ;;55Ax1~-hq!n0EEFF r:   c                 T    US:X  a  [        U R                  S   5      $ [        X5      eNr<   r   )airyaiprimer3   r
   rN   s     r6   rP   airyai.fdiff  '    q=tyy|,,$T44r:   c           	      X   U S:  a  [         R                  $ [        U5      n[        U5      S:  a  US   n[	        S5      U-  U * -  [	        S5      U-  U S-   -  -  [        [        U [        SS5      -  [        SS5      -   -  5      -  [        U 5      -  [        U S-  [        SS5      -   5      -  [        [        U [        SS5      -  [        SS5      -   -  5      [        U S-   5      -  [        U S-  [        SS5      -   5      -  -  U-  $ [         R                  S[        SS5      -  [        -  -  [        U [         R                  -   [        S5      -  5      -  [        [        SS5      [        -  U [         R                  -   -  5      -  [        U 5      -  [	        S5      U-  U -  -  $ )Nr   r<   r   r   rJ   r   )r   r   r   lenr   r   r   r   r   r'   r   r   rg   previous_termsr   s       r6   taylor_termairyai.taylor_term  s    q566M
A>"Q&"2&aqb)4719A*>>s2qRSUVGWZbcdfgZhGhCi?jjktuvkwwacHQN23458Qx1~=MPXYZ\]P^=^9_5`ajklopkpaq5qrwxyz{x{  G  HI  KL  M  yM  sN  6NO RSS T q(1a.034uagqt^7LLsS[\]_`SabdSdfghihmhmfmSnOoo!!%(,Q	A~6 7r:   c                     [        SS5      n[        SS5      n[        U* [        SS5      5      n[        U5      R                  (       a.  U[	        U* 5      -  [        U* XE-  5      [        X4U-  5      -   -  $ g Nr<   r   rJ   r   r   r#   rp   r    r_   r5   rE   rw   otttrh   s         r6   r   airyai._eval_rewrite_as_besselj  sl    a^a^HQN#a5dA2h;'2#rt"4wra47H"HII r:   c                 f   [        SS5      n[        SS5      n[        U[        SS5      5      n[        U5      R                  (       a-  U[	        U5      -  [        U* XE-  5      [        X4U-  5      -
  -  $ U[        XS5      [        U* XE-  5      -  U[        XS* 5      -  [        X4U-  5      -  -
  -  $ r  r   r   r#   rn   r    r`   r  s         r6   r   airyai._eval_rewrite_as_besseli  s    a^a^8Aq>"a5d1g:"bd!3gbQ$6G!GHHs1z'2#rt"44qQ}WRTUQUEV7VVWWr:   c           	      >   [         R                  S[        SS5      -  [        [        SS5      5      -  -  nU[	        SS5      [        [        SS5      5      -  -  nU[        / [        SS5      /US-  S-  5      -  U[        / [        SS5      /US-  S-  5      -  -
  $ )Nr   rJ   r<   	   r   )r   r   r   r'   r!   r*   r5   rE   rw   pf1pf2s        r6   _eval_rewrite_as_hyperairyai._eval_rewrite_as_hyper  s    eeq(1a.(x1~)>>?41:eHQN334U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr:   c                 ^   U R                   S   nUR                  n[        U5      S:X  Ga  UR                  5       n[	        SU/S9n[	        SU/S9n[	        SU/S9n[	        SU/S9nUR                  XVXH-  -  U-  -  5      n	U	b  X   nSU-  R                  (       a  X   nX   nX   nXdU-  -  U-  Xg-  XGU-  -  -  -  n
XVU-  -  XGU-  -  -  n[        R                  U
[        R                  -   [        U5      -  U
[        R                  -
  [        S5      -  [        U5      -  -
  -  $ g g g 	Nr   r<   r   )excludedmr   r   )r3   free_symbolsr  popr   matchr]   r   r   r   r  r    airybir5   rq   r   symbsrE   r   r  r  r   Mpfnewargs               r6   ro   airyai._eval_expand_func  s<   iil  u:?		AS1#&AS1#&AS1#&AS1#&A		!qtVaK-(A}D aC##AAAd(Q!$qS/:BAXaC0F66b155j&.%@BJPTUVPWCWX^_eXfCf%fgg $	  r:   rA   Nr<   r{   r|   r}   r~   r   nargs
unbranchedr   rF   rP   staticmethodr   r  r   r   r  ro   r   rA   r:   r6   r  r  ^  sb    Vp EJG G5 7  7JXe
hr:   r  c                   l    \ rS rSrSrSrSr\S 5       rSS jr	\
\S 5       5       rS rS	 rS
 rS rSrg)r  i
  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

r<   Tc                    UR                   (       a  U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ U[        R                  L a  [        R
                  $ UR                  (       a6  [        R                  S[        SS5      -  [        [        SS5      5      -  -  $ UR                  (       a6  [        R                  S[        SS5      -  [        [        SS5      5      -  -  $ g )Nr   r<      rJ   )
r  r   r   r   r   r   re   r   r   r'   r  s     r6   rF   airybi.evalh  s    ==aee|uu

"zz!***vvuu8Aq> 1E(1a.4I IJJ;;55Ax1~-hq!n0EEFF r:   c                 T    US:X  a  [        U R                  S   5      $ [        X5      er  )airybiprimer3   r
   rN   s     r6   rP   airybi.fdiffw  r  r:   c           
      p   U S:  a  [         R                  $ [        U5      n[        U5      S:  a  US   n[	        S5      U-  [        [        [        SS5      [        -  U [         R                  -   -  5      5      -  [        U [         R                  -
  [        S5      -  5      -  U [         R                  -   [        [        [        SS5      [        -  U [         R                  -   -  5      5      -  [        U S-
  [        S5      -  5      -  -  U-  $ [         R                  [        SS5      [        -  -  [        U [         R                  -   [        S5      -  5      -  [        [        [        SS5      [        -  U [         R                  -   -  5      5      -  [        U 5      -  [	        S5      U-  U -  -  $ )Nr   r<   r   r   rJ   r   )r   r   r   r  r   r"   r   r   r   r   r   r   r   r!   r'   r  s       r6   r  airybi.taylor_term}  sw    q566M
A>"Q&"2&Q	CHQN2,=q155y,I(J$KKiYZ]^]b]bYbdefgdhXhNiiaee)s3x1~b/@!aff*/M+N'OOR[]^ab]bdefgdh\hRiikmno p tAqz"}-q155y!A$6F0GG#cRZ[\^_R`acRcefijininenRoNpJqq!!%(,Q	A~6 7r:   c                     [        SS5      n[        SS5      n[        U* [        SS5      5      n[        U5      R                  (       a.  [	        U* S-  5      [        U* XE-  5      [        X4U-  5      -
  -  $ g r  r  r  s         r6   r   airybi._eval_rewrite_as_besselj  sl    a^a^HQN#a51:"bd!3gbQ$6G!GHH r:   c                    [        SS5      n[        SS5      n[        U[        SS5      5      n[        U5      R                  (       a6  [	        U5      [	        S5      -  [        U* XE-  5      [        X4U-  5      -   -  $ [        XS5      n[        XS* 5      n[	        U5      U[        U* XE-  5      -  X-  [        X4U-  5      -  -   -  $ r  r  r5   rE   rw   r  r  rh   r   r   s           r6   r   airybi._eval_rewrite_as_besseli  s    a^a^8Aq>"a5747?grc24&872!t;L&LMMA
AAsA8QwsBD11ACqD8I4IIJJr:   c           	      8   [         R                  [        SS5      [        [	        SS5      5      -  -  nU[        SS5      -  [        [	        SS5      5      -  nU[        / [	        SS5      /US-  S-  5      -  U[        / [	        SS5      /US-  S-  5      -  -   $ )Nr   r   rJ   r<   r  r   )r   r   r!   r'   r   r*   r  s        r6   r  airybi._eval_rewrite_as_hyper  s    eetAqz%A"778Q
lU8Aq>22U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr:   c                 ^   U R                   S   nUR                  n[        U5      S:X  Ga  UR                  5       n[	        SU/S9n[	        SU/S9n[	        SU/S9n[	        SU/S9nUR                  XVXH-  -  U-  -  5      n	U	b  X   nSU-  R                  (       a  X   nX   nX   nXdU-  -  U-  Xg-  XGU-  -  -  -  n
XVU-  -  XGU-  -  -  n[        R                  [        S5      [        R                  U
-
  -  [        U5      -  [        R                  U
-   [        U5      -  -   -  $ g g g r  )r3   r  r  r  r   r  r]   r   r   r    r   r  r  r  s               r6   ro   airybi._eval_expand_func  s:   iil  u:?		AS1#&AS1#&AS1#&AS1#&A		!qtVaK-(A}D aC##AAAd(Q!$qS/:BAXaC0F66T!Waeebj%9&.%HAEETVJX^_eXfKf%fgg $	  r:   rA   Nr  r  rA   r:   r6   r  r  
  sb    Xt EJG G5 7  7I	Ke
hr:   r  c                   X    \ rS rSrSrSrSr\S 5       rSS jr	S r
S rS	 rS
 rS rSrg)r  i  aI  
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

r<   Tc                 @   UR                   (       aF  U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ UR
                  (       a6  [        R                  S[        SS5      -  [        [        SS5      5      -  -  $ g )Nr   r<   )	r  r   r   r   r   re   r   r   r'   r  s     r6   rF   airyaiprime.eval  sh    ==aee|uu

"vv;;==Ax1~$5hq!n8M$MNN r:   c                 t    US:X  a(  U R                   S   [        U R                   S   5      -  $ [        X5      er  )r3   r  r
   rN   s     r6   rP   airyaiprime.fdiff  4    q=99Q<tyy| 444$T44r:   c                     U R                   S   R                  U5      n[        U5         [        R                  " USS9nS S S 5        [
        R                  " WU5      $ ! , (       d  f       N%= fNr   r<   )
derivative)r3   r  r-   r,   r  r   r  r5   rj  rE   ress       r6   rh  airyaiprime._eval_evalf!  Q    IIaL##D)d^))A!,C   d++ ^   A
A-c                     [        SS5      n[        U* [        SS5      5      n[        U5      R                  (       a$  US-  [	        U* X4-  5      [	        X3U-  5      -
  -  $ g NrJ   r   )r   r   r#   rp   r_   r5   rE   rw   r  rh   s        r6   r   $airyaiprime._eval_rewrite_as_besselj'  s[    a^HQN#a5Q3'2#rt,wra4/@@AA r:   c                    [        SS5      n[        SS5      nU[        U[        SS5      5      -  n[        U5      R                  (       a  US-  [	        XE5      [	        U* U5      -
  -  $ [        U[        SS5      5      n[        XT5      n[        XT* 5      nX1S-  U-  [	        XDU-  5      -  U[	        U* XE-  5      -  -
  -  $ r  )r   r   r#   rn   r`   r
  s           r6   r   $airyaiprime._eval_rewrite_as_besseli-  s    a^a^QA''a5Q3'".7B3?:;;Ax1~&AA
AAsAAaqD 11Agrc246H4HHIIr:   c           	      .   US-  SS[        SS5      -  -  [        [        SS5      5      -  -  nS[        SS5      [        [        SS5      5      -  -  nU[        / [        SS5      /US-  S-  5      -  U[        / [        SS5      /US-  S-  5      -  -
  $ )NrJ   r   r<      r  )r   r'   r!   r*   r  s        r6   r  "airyaiprime._eval_rewrite_as_hyper9  s    da8Aq>))%A*??@41:eHQN334U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr:   c                 ^   U R                   S   nUR                  n[        U5      S:X  Ga  UR                  5       n[	        SU/S9n[	        SU/S9n[	        SU/S9n[	        SU/S9nUR                  XVXH-  -  U-  -  5      n	U	b  X   nSU-  R                  (       a  X   nX   nX   nXg-  XHU-  -  -  XdU-  -  U-  -  n
XVU-  -  XHU-  -  -  n[        R                  U
[        R                  -   [        U5      -  U
[        R                  -
  [        S5      -  [        U5      -  -   -  $ g g g r  )r3   r  r  r  r   r  r]   r   r   r   r  r    r  r  s               r6   ro   airyaiprime._eval_expand_func>  s=   iil  u:?		AS1#&AS1#&AS1#&AS1#&A		!qtVaK-(A}D
 aC##AAA$qS/aQ$h]:BAXaC0F66b155j+f2E%EaeeUYZ[U\H\]hio]pHp%pqq $  r:   rA   Nr  r{   r|   r}   r~   r   r  r  r   rF   rP   rh  r   r   r  ro   r   rA   r:   r6   r  r    sK    Ob EJO O5,B
Je
rr:   r  c                   X    \ rS rSrSrSrSr\S 5       rSS jr	S r
S rS	 rS
 rS rSrg)r  iX  aR  
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

r<   Tc                    UR                   (       a  U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ U[        R                  L a  [        R
                  $ UR                  (       a%  S[        SS5      -  [        [        SS5      5      -  $ UR                  (       a%  S[        SS5      -  [        [        SS5      5      -  $ g )Nr   r<   r   )	r  r   r   r   r   r   re   r   r'   r  s     r6   rF   airybiprime.eval  s    ==aee|uu

"zz!***vv(1a.(5!Q+@@@;;hq!n$uXa^'<<< r:   c                 t    US:X  a(  U R                   S   [        U R                   S   5      -  $ [        X5      er  )r3   r  r
   rN   s     r6   rP   airybiprime.fdiff  r  r:   c                     U R                   S   R                  U5      n[        U5         [        R                  " USS9nS S S 5        [
        R                  " WU5      $ ! , (       d  f       N%= fr  )r3   r  r-   r,   r  r   r  r  s       r6   rh  airybiprime._eval_evalf  r  r  c                     [        SS5      nU[        U* [        SS5      5      -  n[        U5      R                  (       a)  U* [	        S5      -  [        U* U5      [        X45      -   -  $ g r  r  r   s        r6   r   $airybiprime._eval_rewrite_as_besselj  s^    a^aR!Q((a52d1g:"a72>!ABB r:   c                    [        SS5      n[        SS5      nU[        U[        SS5      5      -  n[        U5      R                  (       a(  U[	        S5      -  [        U* U5      [        XE5      -   -  $ [        U[        SS5      5      n[        XT5      n[        XT* 5      n[	        U5      U[        U* XE-  5      -  US-  U-  [        XDU-  5      -  -   -  $ r  r  r
  s           r6   r   $airybiprime._eval_rewrite_as_besseli  s    a^a^QA''a5T!W9Q'". @AAAx1~&AA
AAsA8q"bd!33ad1fWRA=N6NNOOr:   c           	      "   US-  S[        SS5      -  [        [        SS5      5      -  -  n[        SS5      [        [        SS5      5      -  nU[        / [        SS5      /US-  S-  5      -  U[        / [        SS5      /US-  S-  5      -  -   $ )NrJ   r   r   r<   r%  r  )r!   r'   r   r*   r  s        r6   r  "airybiprime._eval_rewrite_as_hyper  s    daQ
l5!Q#8891aj5!Q00U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr:   c                 ^   U R                   S   nUR                  n[        U5      S:X  Ga  UR                  5       n[	        SU/S9n[	        SU/S9n[	        SU/S9n[	        SU/S9nUR                  XVXH-  -  U-  -  5      n	U	b  X   nSU-  R                  (       a  X   nX   nX   nXg-  XHU-  -  -  XdU-  -  U-  -  n
XVU-  -  XHU-  -  -  n[        R                  [        S5      U
[        R                  -
  -  [        U5      -  U
[        R                  -   [        U5      -  -   -  $ g g g r  )r3   r  r  r  r   r  r]   r   r   r    r   r  r  r  s               r6   ro   airybiprime._eval_expand_func  s?   iil  u:?		AS1#&AS1#&AS1#&AS1#&A		!qtVaK-(A}D
 aC##AAA$qS/aQ$h]:BAXaC0F66T!Wb155j%9+f:M%MQSVWV[V[Q[]hio]pPp%pqq $  r:   rA   Nr  r)  rA   r:   r6   r  r  X  sI    Qf EJ= =5,C
Pe
rr:   r  c                   J    \ rS rSrSr\S 5       rSS jrS rS r	S r
S rS	rg
)marcumqi  a  
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                 R   U[         R                  L aa  U[         R                  L a#  U[         R                  L a  [         R                  $ [        XS-  [         R                  -  5      [	        U5      -  $ U[         R                  L a8  U[         R                  L a%  SS[        US-  [         R                  -  5      -  -
  $ X#:X  a  U[         R                  L a3  S[        US-  * 5      [        SUS-  5      -  -   [         R                  -  $ US:X  aa  [         R                  [         R                  [        US-  * 5      -  [        SUS-  5      -  -   [        US-  * 5      [        SUS-  5      -  -   $ UR                  (       a]  UR                  (       a!  UR                  (       a  [         R                  $ [        XS-  [         R                  -  5      [	        U5      -  $ UR                  (       a7  UR                  (       a%  SS[        US-  [         R                  -  5      -  -
  $ g g )NrJ   r<   r   )	r   r   r)   r   r'   r   r   r`   re   )rC   r  rh   r   s       r6   rF   marcumq.eval-  s   ;AFF{qAFF{vvaA/%(::;1;q3q!taff}----6AEEzCAJAqD)999166AAAvvvadU 3gaA6F FFaQRdUV]^_abdeaeVfIfff99yyQYYvvaAaff-a8899q3q!tAFF{++++ #9r:   c                     U R                   u  p#nUS:X  a   U[        X#U5      * [        SU-   X45      -   -  $ US:X  a8  XB-  * X2S-
  -  -  [        US-  US-  -   * S-  5      -  [        US-
  X4-  5      -  $ [	        X5      e)NrJ   r<   r   )r3   r:  r   r`   r
   )r5   rO   r  rh   r   s        r6   rP   marcumq.fdiffE  s    ))aq=q))GAaC,>>??]TEA!H$adQTkN1,<(==!QS@QQQ$T44r:   c           	         SSK Jn  UR                  S[        [	        S5      R
                  5      5      nUSU-
  -  U" Xa-  [        US-  US-  -   * S-  5      -  [        US-
  X&-  5      -  Xc[        R                  /5      -  $ )Nr   )Integralrg   r<   rJ   )
sympy.integrals.integralsr@  getr   r   namer   r`   r   r   )r5   r  rh   r   rw   r@  rg   s          r6   _eval_rewrite_as_Integral!marcumq._eval_rewrite_as_IntegralN  s    6JJsE"7"<"A"ABCQU|sQTAqD[>!#344wqsAC7HH1QRQ[Q[J\]^ 	^r:   c           	          SSK Jn  UR                  S[        S5      5      n[	        US-  US-  -   * S-  5      U" X#-  U-  [        XbU-  5      -  USU-
  [        R                  /5      -  $ )Nr   )Sumr   rJ   r<   )sympy.concrete.summationsrG  rB  r   r   r`   r   r   )r5   r  rh   r   rw   rG  r   s          r6   _eval_rewrite_as_Summarcumq._eval_rewrite_as_SumT  sh    1JJsE#J'QTAqD[>A%&acAXQ3-G!QqSRSR\R\I])^^^r:   c                 d  ^ TU:X  a  US:X  a%  S[        TS-  * 5      [        STS-  5      -  -   S-  $ UR                  (       al  US:  ae  [        U4S j[	        SU5       5       5      n[
        R                  [        TS-  * 5      [        STS-  5      -  S-  -   [        TS-  * 5      U-  -   $ g g g )Nr<   rJ   r   c              3   B   >#    U  H  n[        UTS -  5      v   M     g7f)rJ   N)r`   ).0r  rh   s     r6   	<genexpr>3marcumq._eval_rewrite_as_besseli.<locals>.<genexpr>^  s     >+Q1a4((+s   )r   r`   rP  sumr   r   r   )r5   r  rh   r   rw   r   s     `   r6   r    marcumq._eval_rewrite_as_besseliY  s    6AvCAJAqD)999Q>>||Q>%1+>>vvQTE
WQ1-= = AACAJQRNRR !'| r:   c                 H    [        S U R                   5       5      (       a  gg )Nc              3   8   #    U  H  oR                   v   M     g 7fr@   )re   )rM  r   s     r6   rN  (marcumq._eval_is_zero.<locals>.<genexpr>b  s     0is{{is   T)allr3   r4   s    r6   _eval_is_zeromarcumq._eval_is_zeroa  s    0dii000 1r:   rA   Nrz   )r{   r|   r}   r~   r   r   rF   rP   rD  rI  r   rV  r   rA   r:   r6   r:  r:    s8    .` , ,.5^_
Sr:   r:  c                   B   ^  \ rS rSrSrU 4S jrS rSU 4S jjrSrU =r	$ )r   ie  ze
Helper function to make the $\mathrm{besseli}(nu, z)$
function tractable for the Gruntz algorithm.

c           
        > SSK Jn  SSKJn  US   nU[        R
                  [        R                  4;   a  U R                  u  p[        U5       V
s/ s H^  n
U" [        SU-  S-
  S5      U
5      U" [        SU-  S-   S5      U
5      -  SU
-  U	[        SU
-  S-   S5      -  -  [        U
5      -  -  PM`     nn
[        [        S-  5      [        U6 -  U" SU	[        SU-  S-   S5      -  -  U5      -   $ [        TU ]=  XX45      $ s  sn
f r  r  r   r   r   r   r   r   r3   r   r   r   r    r   r   r   r  r5   r   r  rg   r   r   r   r  rD   rE   r   r  rL   s               r6   r  _besseli._eval_aseriesl  s   L,aQZZ!3!344IIEBkpqrksuksfg #8AbD1Ha#8!<_QrTAXq)1>. .12aXacAgq=Q9R0RS\]^S_0_aks  uA<a)E!A1q!8L4M2Mq,QQQw$Qq77	u   A%Dc                 2    [        U* 5      [        X5      -  $ r@   )r   r`   r   s       r6   _eval_rewrite_as_intractable%_besseli._eval_rewrite_as_intractabley  s    A2wwr~%%r:   c                    > U R                   S   R                  US5      nUR                  (       a+  U R                  " U R                   6 nUR	                  XU5      $ [
        TU ]  XU5      $ r  r3   limitre   r_  r   r   r5   rg   r   r   r   x0rr   rL   s          r6   r   _besseli._eval_nseries|  [    YYq\1%::11499=A??1..w$Q400r:   rA   r   
r{   r|   r}   r~   r   r  r_  r   r   r   r   s   @r6   r   r   e  s    8&1 1r:   r   c                   B   ^  \ rS rSrSrU 4S jrS rSU 4S jjrSrU =r	$ )r'  i  ze
Helper function to make the $\mathrm{besselk}(nu, z)$
function tractable for the Gruntz algorithm.

c           
        > SSK Jn  SSKJn  US   nU[        R
                  [        R                  4;   a  U R                  u  p[        U5       V
s/ s H^  n
U" [        SU-  S-
  S5      U
5      U" [        SU-  S-   S5      U
5      -  SU
-  U	[        SU
-  S-   S5      -  -  [        U
5      -  -  PM`     nn
[        [        S-  5      [        U6 -  U" SU	[        SU-  S-   S5      -  -  U5      -   $ [        TU ]=  XX45      $ s  sn
f r3  rZ  r[  s               r6   r  _besselk._eval_aseries  s   L,aQZZ!3!344IIEBlqrsltvltgh #8AbD1Ha#8!<_QrTAXq)1>. .13q	!hqsQwPQ>R:S0ST]^_T`0`blt  vA<a)E!A1q!8L4M2Mq,QQQw$Qq77	vr]  c                 0    [        U5      [        X5      -  $ r@   )r   r  r   s       r6   r_  %_besselk._eval_rewrite_as_intractable  s    1vgbn$$r:   c                    > U R                   S   R                  US5      nUR                  (       a+  U R                  " U R                   6 nUR	                  XU5      $ [
        TU ]  XU5      $ r  rb  rd  s          r6   r   _besselk._eval_nseries  rg  r:   rA   r   rh  r   s   @r6   r'  r'    s    8%1 1r:   r'  N)r     )X	functoolsr   
sympy.corer   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*   sympy.polys.orthopolysr+   r  r,   r-   r/   r_   r   r`   r  r7  r9  rE  rG  rW  rY  rc   rd   ry  ra   rb   r  r  r  r  r  r  r:  r   r'  rA   r:   r6   <module>r     s      $   M M 0 . .   @ @ & O G G 7 ; E E V V N N / 6 C  C LmDj mD`YDj YDxf8j f8R~8j ~8B+Bj +B\,Bj ,B^2* 28J
.U;	 U;p?;	 ?;D6;- 6;r5-
 5-p5-
 5-pQh# #6ihX ihXnhX nhbZr( Zrzar( arHgo gR1 1>1 1r:   