K i0 <ddlmZddlmZddlmZddlmZddlm Z ddl m Z m Z m Z ddlmZmZddlmZmZmZdd lmZdd lmZmZmZdd lmZdd lmZmZdd l m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6m7Z7ddl8m9Z9ddl:m;Z;ddlZ>Gdde Z?Gdde?Z@Gdde?ZAGdde?ZBGdde?ZCGd d!e?ZDGd"d#e?ZEd$ZFGd%d&e?ZGd'ZHd(ZIGd)d*eGZJGd+d,eGZKGd-d.eGZLGd/d0eLZMGd1d2eLZNdEd3ZOGd4d5e ZPGd6d7ePZQGd8d9ePZRGd:d;ePZSGd<d=ePZTGd>d?e ZUGd@dAe ZVGdBdCe ZWyD)Fwraps)S)Add)cacheit)Expr)DefinedFunctionArgumentIndexError_mexpand)fuzzy_or fuzzy_not)RationalpiI)Pow)Dummyuniquely_named_symbolWild)sympify) factorialRisingFactorial)sincoscsccot)ceiling)explog)cbrtsqrtroot)Absreim polar_lift unpolarify)gammadigamma uppergamma)hyper)spherical_bessel_fn)mpworkprecc`eZdZdZedZedZedZd dZ dZ dZ dZ d Z y ) 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 |jdS)z( The order of the Bessel-type function. rargsselfs d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/functions/special/bessel.pyorderzBesselBase.order4yy|c |jdS)z+ The argument of the Bessel-type function. r1r3s r5argumentzBesselBase.argument9r7r8cyNclsnuzs r5evalzBesselBase.eval>sr8c |dk7r t|||jdz |j|jdz |jz|j dz |j|jdz|jzz SNr:)r _b __class__r6r;_ar4argindexs r5fdiffzBesselBase.fdiffBsp q=$T84 4 DNN4::>4==II DNN4::>4==IIJ Kr8c|j}|jdur8|j|jj |j SyNF)r;is_extended_negativerHr6 conjugater4rBs r5_eval_conjugatezBesselBase._eval_conjugateHsB MM ! !U *>>$**"6"6"8!++-H H +r8c |j|j}}|j|ry|j||sy|j ||}|j rKt |ttttttfs |jst|jStt!|j|jgSrN)r6r;has_eval_is_meromorphicsubs is_integer isinstancebesseljbesselihn1hn2jnynis_zeror is_infiniter )r4xarArBz0s r5rUzBesselBase._eval_is_meromorphicMs DMMA 66!9%%a+ VVAq\ ==$'3R DERZZ 002::r~~">?@@r8c D|j|j|j}}}|jr|dz jri|j |j z||dz |jzd|j z|dz z||dz |jz|z zS|dzjrhd|j z|dzz||dz|jz|z |j |j z||dz|jzz S|SNr:rF) r6r;rHis_real is_positiverIrG_eval_expand_func is_negative)r4hintsrArBfs r5rhzBesselBase._eval_expand_funcZs ::t}}dnnqA ::Q##(261)G)G)II$'' 26*1R!VQ<+I+I+KKAMNOq&%%$'' 26*1R!VQ<+I+I+KKAM"q&! (F(F(HHIJ r8c ddlm}||S)Nr) besselsimp)sympy.simplify.simplifyrm)r4kwargsrms r5_eval_simplifyzBesselBase._eval_simplifyes6$r8NrF)__name__ __module__ __qualname____doc__propertyr6r; classmethodrCrLrRrUrhrpr>r8r5r/r/$s_ K I A  r8r/ceZdZdZej Zej ZedZ dZ dZ dZ fdZ dZd fd ZxZS) rYa4 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|jr|jrtjS|jr|jdust |j rtj St |jr|jdurtjS|jrtjS|tjtjfvrtj S|jr||z| | zzt|| zS|jr_|jr"tj| zt| |zS|j!t"}|rt"|zt%||zS|jrt'|}||k7rPt||S|j)\}}|dk7r,t+d|zt,z|zt"zt||zSt'|}||k7r t||Sy)NFTrrF)r_rOnerWr#rgZeroriComplexInfinity is_imaginaryNaNInfinityNegativeInfinitycould_extract_minus_signrY NegativeOneextract_multiplicativelyrrZr&extract_branch_factorrrr@rArBnewznnnus r5rCz besselj.evals 99zzuu --BJJ%$7BrF0II I "r8c |td|ztz t|tjz |j zSr)r rr]rHalfr;rs r5_eval_rewrite_as_jnzbesselj._eval_rewrite_as_jns,AaCF|BrAFF{DMM:::r8c|j\}} |j|}|j|\}}|jr||zd|zt |dzzz S|j r\|dk(rdn|}|||zz} | j s=tdt|td|zdzzdz z ztt|zz S|Stt|3|||S#t$r|cYSwxYw)NrFr:rlogxcdir) r2as_leading_termNotImplementedErroras_coeff_exponentrgr'rir rrsuperrY_eval_as_leading_term r4rarrrArBargcesignrHs r5rzbesselj._eval_as_leading_terms A ##A&C$$Q'1 ==7ArE%Q-/0 0 ]] 1tDT1W9D##Aws1r1R4!8}Q#677RT BBKWd9!$T9RR# K sC C)(C)cV|j\}}|jr|jryyyNTr2rWis_extended_realr4rArBs r5_eval_is_extended_realzbesselj._eval_is_extended_real( A ==Q//0=r8cddlm}|j\}} |j|\}} | j rt|| z } |||z|} |dz j||||j} | tjur| St| dz| zj} | |zt|dzz }|g}td| dzdzD]>}|| |||zzz z}t|| zj}|j|@t!|| zSt"t$|#||||S#tt f$r|cYSwxYwNrOrderrFr:)sympy.series.orderrr2leadterm ValueErrorrrgr _eval_nseriesremoveOrr{r r'rangeappendrrrYr4rarrrrrArB_rnewnorttermskrHs r5rzbesselj._eval_nseriessW - A ZZ]FAs ??1S5>DadAA1##Aq$5==?AAFF{!Q$!#,,.Ab5rAv&DA1tax!m, ArAvJ' *335 7Q; Wd1!QdCC'/0 K sD55E E r)rrrsrtrurrzrIrGrwrCrrrrrr __classcell__rHs@r5rYrYjsXBH B B!#!#F<J;S* DDr8rYceZdZdZej Zej ZedZ dZ dZ dZ fdZ dZd fd ZxZS) ra` 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|jrh|jrtjSt|jdurtjSt|jrtj S|tj tjfvrtjS|ttj zk(r0tttz|dzzdz tj zS|ttjzk(r1tt tz|dzzdz tj zS|jr3|jr"tj| zt| |zSyy)NFr:rF)r_rrr#r|r~rr{rrrrWrrrr?s r5rCz bessely.evalFs 99zz)))B5((((Buu Q//0 066M !** qtR!V}Q'!**4 4 !$$$ $r"ub1f~a'(1::5 5 ==**,}}s+GRCO;;- r8c |jdur@tt|ztt|zt ||zt | |z zSyrN)rWrrrrYrs r5_eval_rewrite_as_besseljz bessely._eval_rewrite_as_besseljZsF ==E !r"u:s2b5z'"a.87B3?JK K "r8c d|j|j}|r|jtSyr=)rr2rewriterZr4rArBroajs r5rz bessely._eval_rewrite_as_besseli^/ *T * *DII 6 ::g& & r8c |td|ztz t|tjz |j zSr)r rr^rrr;rs r5_eval_rewrite_as_ynzbessely._eval_rewrite_as_yncs,AaCF|baffdmm<<@=M=M1 }YrAv%66r9STSYSYHQ3)R " %56Q!,,8VWJ(J78HHQUHVCJ ]] 1tDT1W9D##AwRU1Wq[2a4%7!8 81SBq1rRStAS=T;TVWXYVY;Z Z[\`abcdad\eefjkmfnnnKWd9!$T9RR'# K sF99 GGcV|j\}}|jr|jryyyrr2rWrgrs r5rzbessely._eval_is_extended_real& A ==Q]]+=r8cBddlm}|j\}} |j|\}} | j r;|jr.t|| z } t||} dtz t|dz z| zj||||} gg}} |||z|}|dz j||||j}|tjur|St!|dz|zj}|tjkDr|| zt#|dz ztz }| j%|t'd|D][}||z |z}|tjk(r |||z z}n|||z z}t!||zj}| j%|]||ztt#|zz }|t)|dztj*z z}|j%|t'd| dzdzD]a}|| |||zzz z}t!||zj}|t)||zdzt)|dzzz}|j%|c| t-| z t-|z St.t0|3||||S#tt f$r|cYSwxYwr)rrr2rrrrgrWrrYrrrrrr{r rrrr(rrrr)r4rarrrrrArBrrrbnrbbrrrrrrdenomprHs r5rzbessely._eval_nseriess - A ZZ]FAs ??r}}1S5>DQBB$AaC#221atDArqAadAA1##Aq$5==?AAFF{!Q$!#,,.AAFF{B3x "q& 11"4q"#A!VQJE! %$TNQ.779DHHTN#2r)B-'(Agb1fo 45D HHTN1tax!m, aRAF_$a[1_--/'!b&1*-A>?   sAw;a( (Wd1!QdCCK/0 K sJ JJr)rrrsrtrurrzrIrGrwrCrrrrrrrrs@r5rrsV&P B B<<&L' =S2 /D/Dr8rceZdZdZej Zej ZedZ d dZ dZ dZ dZ dZfdZd fd Zfd ZxZS) rZa 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|jr|jrtjS|jr|jdust |j rtj St |jr|jdurtjS|jrtjSt|tjtjfvrtj S|tjurtjS|tjurd|ztjzS|jr||z| | zzt|| zS|jrL|jr t| |S|j!t"}|rt"| zt%|| zS|jrt'|}||k7rPt||S|j)\}}|dk7r,t+d|zt,z|zt"zt||zSt'|}||k7r t||Sy)NFTrrF)r_rrzrWr#rgr{rir|r}r~r$rrrrZrrrYr&rrrrs r5rCz besseli.evals 99zzuu --BJJ%$7BrFDadAA1##Aq$5==?AAFF{!Q$!#,,.Ab5rAv&DA1tax!m, 1b1f:& *335 7Q; Wd1!QdCC'/0 K sD44EEc *ddlm}ddlm}|d}|tj tj fvr|j\}} t|D cgc]]} |td|zdz d| |td|zdzd| zd| z| td| zdzdzzt| zz _c} |d| td|zdzdzz |gz} t| tdtzz t| zSt |A||||Scc} wNrrrr:rF(sympy.functions.combinatorial.factorialsrrrrrrr2rrrrr rrr _eval_aseries r4rargs0rarrrpointrArBrrrHs r5rzbesseli._eval_aseriesQs,L,a QZZ!3!34 4IIEBGLQxQBC"(1R4!8Q"7;OHUVWYUY\]U]_`LacdQTYZ[\]`hijklilopiprs`t\uZuwxTySz{Aq6$qt*$Q0 0w$Qq$77 QsA"Dr=r)rrrsrtrurrzrIrGrwrCrrrrrrrrrrs@r5rZrZsb%N %%B B%#%#N*<' E S*D> 8 8r8rZceZdZdZej Zej ZedZ dZ dZ dZ dZ dZd dZd Zd fd Zfd ZxZS)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|jrh|jrtjSt|jdurtjSt|jrtj S|tjt tjzt tjzfvrtjS|jr|jr t| |SyyrN) r_rrr#r|r~rrr{rWrrr?s r5rCz besselk.evals 99zzzz!B5((((Buu Qqzz\1Q-?-?+?@ @66M ==**,sA&- r8c |jdur7ttt|zzt| |t||z zdz Sy)NFrF)rWrrrZrs r5rz besselk._eval_rewrite_as_besselisB ==E !c"R%j='2#q/GBN"BCAE E "r8c d|j|j}|r|jtSyr=)rr2rrY)r4rArBroais r5rz besselk._eval_rewrite_as_besseljrr8c d|j|j}|r|jtSyr=rrs r5rz besselk._eval_rewrite_as_besselyrr8c d|j|j}|r|jtSyr=)rr2rr^)r4rArBroays r5rzbesselk._eval_rewrite_as_yns. *T * *DII 6 ::b> ! r8cV|j\}}|jr|jryyyrrrs r5rzbesselk._eval_is_extended_realrr8c N|jrt| t||zSyr=)rr_besselkrs r5rz"besselk._eval_rewrite_as_tractables'  r78B?* * r8cV|j\}} |j|}|j|\}}|jr|j r*t | tjz t dz} nF|jr+tt||dz t| zzdz } ntd|d| j||S|jr+ttt| ztd|zz S|j!||S#t$r|cYSwxYw)NrFz"Cannot proceed without knowing if z is zero or not.r)r2rrrrgr_rrr is_nonzeror'r"rir rrfunc) r4rarrrArBrrrrs r5rzbesselk._eval_as_leading_terms A ##A&C$$Q'1 ==zzAw-A6SW~qss2wh&779),NrdRb*cdd'''5 5 ]]8CI%d1S5k1 199R% %'# K sD D('D(cBddlm}|j\}} |j|\}} | j r;|dz j||||j} | tjur||| z||zz|S|||z|} |jrt|| z } t||} d|dz zt|dz z| zj||||}gg}}t| dz}|tjkDru| | zt!|dz zdz }|j#|t%d|D]=}||||z |zz z}t|| zj}|j#|?| |zd|zzdt!|zz }|t'|dztj(z z}|j#|t%d| dzdzD]`}|||||zzz z}t|| zj}|t'||zdzt'|dzzz}|j#|b|t+|zt+|z| zS|j,rt||z| z }t||z | z }gg}}t%|dzdzD]R}t/|| d|z|z zzdt1d|z |zt!|zz }|j#t|Tt%|dzdzD]S}t/| | d|z|zzzdt1|dz|zt!|zz }|j#t|Ut+|t+|z| zSt dt2t4|||||S#tt f$r|cYSwxYw)NrrrFrr:z4besselk expansion is only implemented for real order)rrr2rrrrgrrrr{rWrrZrr rrrr(rr is_nonintegerr'rrr)r4rarrrrrArBrrrrrrrbrrrrrrnewn_anewn_brHs r5rzbesselk._eval_nseriess, A ZZ]FAs ??1##Aq$5==?AAFF{Q"X2-q11adAA}}qu~R^BF^C!H,R/>>q!T4P21QTN;s8Ib1f$55a7DHHTN"1b\'AFA:. ( 2;;=' rE2(NAimO4'"q&/ALL89q4!8a-0#AAq2vJ'A!!q113Aga"fqj1GAENBCDHHTN # 37{S!W,q00!!!!B$, !B$,21q1}--A 9Q1R[0!OAbD!4L2LYWX\2YZDHHXd^,-q1}--A ":a!A#b&k11_RT15M3MiXYl3ZHHXd^,-Awa(1,,)*`aaWd1!QdCC{/0 K sN NNc ,ddlm}ddlm}|d}|tj tj fvr|j\}} t|D cgc]]} |td|zdz d| |td|zdzd| zd| z| td| zdzdzzt| zz _c} |d| td|zdzdzz |gz} t| ttdz zt| zSt |A||||Scc} wNrrrr:rFrrs r5rzbesselk._eval_aseriess.L,a QZZ!3!34 4IIEBHMaRCD"(1R4!8Q"7;OHUVWYUY\]U]_`Lacd>> 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|j}|jdur2t|jj |j SyrN)r;rOhankel2r6rPrQs r5rRzhankel1._eval_conjugateH> MM ! !U *4:://11;;=A A +r8N rrrsrtrurrzrIrGrRr>r8r5r r  s""H B BBr8r cFeZdZdZej Zej ZdZy)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|j}|jdur2t|jj |j SyrN)r;rOr r6rPrQs r5rRzhankel2._eval_conjugatewr r8Nrr>r8r5r r Ns"#J B BBr8r c.tfd}|S)Nc2|jr |||Syr=)rW)r4rArBfns r5gzassume_integer_order..g~s ==dB? " r8r)rrs` r5assume_integer_orderr}s  2Y## Hr8c$eZdZdZdZdZddZy)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 td)z@ Expand self into a polynomial. Nu is guaranteed to be Integer. expansionrr4rjs r5_expandzSphericalBesselBase._expands !+..r8c V|jjr|jdi|S|SNr>)r6 is_Integerrrs r5rhz%SphericalBesselBase._eval_expand_funcs( :: 4<<(%( ( r8c|dk7r t|||j|jdz |j||jdzz|jz z SrE)r rHr6r;rJs r5rLzSphericalBesselBase.fdiffsS q=$T84 4~~djj1ndmm< DJJN #DMM 12 2r8Nrq)rrrsrtrurrhrLr>r8r5rrs / 2r8rct||t|ztj|dzzt| dz |zt |zzSNr:)r+rrrrrrBs r5_jnr$sM 1 %c!f , MMAE "#6rAvq#A A#a& H IJr8ctj|dzzt| dz |zt|zt||t |zz Sr")rrr+rrr#s r5_ynr&sK MMAE "%8!a%C CCF J 1 %c!f , -.r8c>eZdZdZedZdZdZdZdZ dZ y) r]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(|jrT|jrtjS|jr,|jrtj Stj S|tjtjfvrtj Syr=) r_rrzrWrgr{r|rrr?s r5rCzjn.evalsa 99zzuu >>66M,,, ##QZZ0 066M 1r8c httd|zz t|tjz|zSr)r rrYrrrs r5rzjn._eval_rewrite_as_besseljs(B!H~QVV Q 777r8c tj|zttd|zz zt | tj z |zSr)rrr rrrrs r5rzjn._eval_rewrite_as_besselys8}}b 4AaC>1GRC!&&L!4LLLr8c Jtj|zt| dz |zSr")rrr^rs r5rzjn._eval_rewrite_as_yns"}}r"Ra^33r8c Bt|j|jSr=)r$r6r;rs r5rz jn._expand4::t}}--r8cx|jjr$|jtj |Syr=r6rrrY _eval_evalfr4precs r5r0zjn._eval_evalf. :: <<(44T: : !r8N) rrrsrtrurwrCrrrrr0r>r8r5r]r]s68r  8M4.;r8r]cBeZdZdZedZedZdZdZdZ y)r^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 tj|dzzttd|zz zt | tj z |zSre)rrr rrYrrs r5rzyn._eval_rewrite_as_besselj3s<}}r!t$tB!H~5aff a8PPPr8c httd|zz t|tjz|zSr)r rrrrrs r5rzyn._eval_rewrite_as_bessely7s(B!H~QVV Q 777r8c Ptj|dzzt| dz |zSr")rrr]rs r5rzyn._eval_rewrite_as_jn;s&}}rAv&RC!GQ77r8c Bt|j|jSr=)r&r6r;rs r5rz yn._expand>r-r8cx|jjr$|jtj |Syr=)r6rrrr0r1s r5r0zyn._eval_evalfAr3r8N) rrrsrtrurrrrrr0r>r8r5r^r^sA-\QQ888.;r8r^cJeZdZedZedZdZdZdZdZ dZ y) SphericalHankelBasec |j}ttd|zz t|tj z||t ztj|dzzzt| tj z |zzzSrE)_hankel_kind_signr rrYrrrrr4rArBrohkss r5rz,SphericalHankelBase._eval_rewrite_as_besseljHsq $$B!H~wrAFF{A6"1uQ]]RT%::7B3s r5rz,SphericalHankelBase._eval_rewrite_as_besselyQsi $$B!H~q}}b0"qvvq1II"1uWR!&&[!%<< => >r8c |j}t||jt|tzt||zzSr=)r=r]rr^rr>s r5rz'SphericalHankelBase._eval_rewrite_as_ynZs7$$"ay  $s1uRAY66r8c |j}t|||tzt||j tzzSr=)r=r]rr^rr>s r5rz'SphericalHankelBase._eval_rewrite_as_jn^s8$$"ay3q5B!2!22!6666r8c |jjr|jdi|S|j}|j}|j}t |||t zt||zzSr)r6rrr;r=r]rr^)r4rjrArBr?s r5rhz%SphericalHankelBase._eval_expand_funcbs_ :: 4<<(%( (B A((Cb!9s1uRAY. .r8c |j}|j}|j}t|||tzt ||zzj Sr=)r6r;r=r$rr&expand)r4rjrrBr?s r5rzSphericalHankelBase._expandksI JJ MM$$Aq CE#a)O+3355r8cx|jjr$|jtj |Syr=r/r1s r5r0zSphericalHankelBase._eval_evalfzr3r8N) rrrsrtrrrrrrhrr0r>r8r5r;r;FsCUU>>77/ 6;r8r;c8eZdZdZej ZedZy)r[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 Fttd|zz t||zSr)r rr rs r5_eval_rewrite_as_hankel1zhn1._eval_rewrite_as_hankel1B!H~gb!n,,r8N) rrrsrtrurrzr=rrIr>r8r5r[r[s&.`--r8r[c:eZdZdZej ZedZy)r\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 Fttd|zz t||zSr)r rr rs r5_eval_rewrite_as_hankel2zhn2._eval_rewrite_as_hankel2rJr8N) rrrsrtrurrzr=rrMr>r8r5r\r\s(.`--r8r\c ddlm}dk(rpddlm}ddlm}||}t d|dzDcgc]C}tj|tdzj|t||Ec}Sdk(rdd l m  dd lmfd } n t%dfd} |z} | | | } | g} t |dz D]} | | | |z} | j'| !| Scc}w#t $rdd lmfd } YewxYw)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 `_ * method = "scipy": uses the `SciPy's sph_jn `_ and `newton `_ 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)rsympy) besseljzero) dps_to_precr:g?scipy)newton) spherical_jnc|Sr=r>)rarrTs r5zjn_zeros..)s,q!,r8)sph_jnc"|ddS)Nrrr>)rarrWs r5rVzjn_zeros..,s&A,q/"-r8Unknown method.c:dk(r ||}|Std)NrRrYr)rkrar!methodrSs r5solverzjn_zeros..solver0s+ W !Q)rvr)r4rrrjre_partim_parts r5_eval_expand_complexzAiryBase._eval_expand_complexYs0,4,,@$@%@""r8N)T)rrrsrtrurRrrvrzr>r8r5rmrmCs3-#r8rmcbeZdZdZdZdZedZd dZe e dZ dZ dZ d Zd Zy ) 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 r:Tc|jr|tjurtjS|tjurtjS|tj urtjS|j r6tjdtddzttddzz S|j r6tjdtddzttddzz Sy)NrrF) is_Numberrr~rr{rr_rzrr'r@rs r5rCz airyai.evals ==aee|uu  "vv ***vv uu8Aq> 1E(1a.4I IJJ ;;55Ax1~-hq!n0EEF F r8cT|dk(rt|jdSt||Nr:r) airyaiprimer2r rJs r5rLz airyai.fdiff) q=tyy|, ,$T84 4r8c T|dkrtjSt|}t|dkDr|d}t d|z| zt d|z|dzzzt t |tddztddzzzt|zt|dz tddzzt t |tddztddzzt|dzzt|dz tddzzz |zStjdtddzt zz t|tjztdz zt tddt z|tjzzzt|z t d|z|zzS)Nrr:rrrFr) rr{rlenrrrrrr'rzrraprevious_termsrs r5 taylor_termzairyai.taylor_terms q566M A>"Q&"2&aqb)4719A*>>s2qRSUVGWZbcdfgZhGhCi?jjktuvkwwacHQN23458Qx1~=MPXYZ\]P^=^9_5`ajklopkpaq5qrwxyz{x{GHIKLMyMsN6NORSSTq(1a.034uagqt^7LLsS[\]_`SabdSdfghihmhmfmSnOoo!! %(,Q A~67r8c tdd}tdd}t| tdd}t|jr0|t | zt | ||zt |||zzzSyNr:rrFrrr#rir rYr4rBrootttrbs r5rzairyai._eval_rewrite_as_besseljsp a^ a^ HQN # a5  dA2h;'2#r!t"4wr2a47H"HI I r8c htdd}tdd}t|tdd}t|jr/|t |zt | ||zt |||zz zS|t||t | ||zz|t|| zt |||zzz zSrrrr#rgr rZrs r5rzairyai._eval_rewrite_as_besselis a^ a^ 8Aq> " a5  d1g:"bd!3gb"Q$6G!GH Hs1bz'2#r!t"44qQ}WRQSTUQUEV7VVW Wr8c >tjdtddzttddzz }|t ddttddzz }|t gtddg|dzdz z|t gtddg|dzdz zz S)NrrFr: r)rrzrr'r!r*r4rBropf1pf2s r5_eval_rewrite_as_hyperzairyai._eval_rewrite_as_hyperseeq(1a.(x1~)>>?41:eHQN334U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr8c ~|jd}|j}t|dk(r|j}t d|g}t d|g}t d|g}t d|g}|j ||||zz|zz} | | |}d|zj r| |}| |}| |}|||zz|z||z|||zzzz } |||zz|||zzz} tj| tjzt| z| tjz tdz t| zz zSyyy Nrr:r)excludedmrr) r2 free_symbolsrpoprmatchrWrrrzr|r airybi r4rjrsymbsrBrrrrMpfnewargs r5rhzairyai._eval_expand_funcsRiil   u:? AS1#&AS1#&AS1#&AS1#&A !Qq!tVaK-(A}aDaC##!A!A!Aad(Q!Q$QqS/:BAXAaC0F66b155j&.%@BJPTUVPWCWX^_eXfCf%fgg $  r8Nr:rrrsrtrunargs unbranchedrwrCrL staticmethodrrrrrrhr>r8r5r|r|^sbVp EJ G G5   7  7JXe hr8r|cbeZdZdZdZdZedZd dZe e dZ dZ dZ d Zd Zy ) ra 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|jr|tjurtjS|tjurtjS|tjurtj S|j r6tjdtddzttddzz S|j r6tjdtddzttddzz Sy)Nrr:rF) r~rr~rrr{r_rzrr'rs r5rCz airybi.evalhs ==aee|uu  "zz!***vv uu8Aq> 1E(1a.4I IJJ ;;55Ax1~-hq!n0EEF F r8cT|dk(rt|jdSt||r) airybiprimer2r rJs r5rLz airybi.fdiffwrr8c l|dkrtjSt|}t|dkDr|d}t d|zt t tddtz|tjzzzt|tjz tdz z|tjzt ttddtz|tjzzzt|dz tdz zz |zStjtddtzz t|tjztdz zt t tddtz|tjzzzt|z t d|z|zzS)Nrr:rrrFr)rr{rrrr"rrrrzrrrr!r'rs r5rzairybi.taylor_term}sw q566M A>"Q&"2&Q CHQN2,=q155y,I(J$KKiYZ]^]b]bYbdefgdhXhNiiaee)s3x1~b/@!aff*/M+N'OOR[]^ab]bdefgdh\hRiikmnoptAqz"}-q155y!A$6F0GG#cRZ[\^_R`acRcefijininenRoNpJqq!! %(,Q A~67r8c tdd}tdd}t| tdd}t|jr0t | dz t | ||zt |||zz zSyrrrs r5rzairybi._eval_rewrite_as_besseljsp a^ a^ HQN # a5  1:"bd!3gb"Q$6G!GH H r8c tdd}tdd}t|tdd}t|jr8t |t dz t | ||zt |||zzzSt||}t|| }t ||t | ||zz||zt |||zzzzSrrr4rBrorrrbrrs r5rzairybi._eval_rewrite_as_besselis a^ a^ 8Aq> " a5  747?grc2a4&872r!t;L&LM MAr AAs A8QwsBqD11AaCBqD8I4IIJ Jr8c 8tjtddtt ddzz }|tddztt ddz }|t gt ddg|dzdz z|t gt ddg|dzdz zzS)NrrrFr:rr)rrzr!r'rr*rs r5rzairybi._eval_rewrite_as_hyperseetAqz%A"778Q lU8Aq>22U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr8c ~|jd}|j}t|dk(r|j}t d|g}t d|g}t d|g}t d|g}|j ||||zz|zz} | | |}d|zj r| |}| |}| |}|||zz|z||z|||zzzz } |||zz|||zzz} tjtdtj| z zt| ztj| zt| zzzSyyyr) r2rrrrrrWrrr rzr|rrs r5rhzairybi._eval_expand_funcsPiil   u:? AS1#&AS1#&AS1#&AS1#&A !Qq!tVaK-(A}aDaC##!A!A!Aad(Q!Q$QqS/:BAXAaC0F66T!Waeebj%9&.%HAEETVJX^_eXfKf%fgg $  r8Nrrr>r8r5rr sbXt EJ G G5   7  7I Ke hr8rcNeZdZdZdZdZedZd dZdZ dZ dZ d Z d Z y ) ra% 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(|jrD|tjurtjS|tjurtjS|j r6tj dtddzttddzz Sy)Nrr:) r~rr~rr{r_rrr'rs r5rCzairyaiprime.evalsh ==aee|uu  "vv ;;==Ax1~$5hq!n8M$MN N r8ct|dk(r(|jdt|jdzSt||r)r2r|r rJs r5rLzairyaiprime.fdiff6 q=99Q<tyy| 44 4$T84 4r8c|jdj|}t|5tj|d}dddt j |S#1swYxYwNrr:) derivative)r2rar-r,r|rr`r4r2rBress r5r0zairyaiprime._eval_evalf!Y IIaL # #D ) d^ -))A!,C -  d++ - - A  A)c tdd}t| tdd}t|jr&|dz t | ||zt |||zz zSyNrFr)rrr#rirYr4rBrorrbs r5rz$airyaiprime._eval_rewrite_as_besselj's_ a^ HQN # a5  Q3'2#r!t,wr2a4/@@A A r8c tdd}tdd}|t|tddz}t|jr |dz t ||t | |z zSt|tdd}t||}t|| }||dz|zt |||zz|t | ||zzz zSr)rrr#rgrZrs r5rz$airyaiprime._eval_rewrite_as_besseli-s a^ a^ QA' ' a5  Q3'"a.7B3?:; ;Ax1~&AAr AAs AAaBqD 11Agrc2a46H4HHI Ir8c .|dzddtddzzttddzz }dtddttddzz }|tgtddg|dzdz z|tgtddg|dzdz zz S)NrFrr:r)rr'r!r*rs r5rz"airyaiprime._eval_rewrite_as_hyper9sda8Aq>))%A*??@41:eHQN334U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr8c ~|jd}|j}t|dk(r|j}t d|g}t d|g}t d|g}t d|g}|j ||||zz|zz} | | |}d|zj r| |}| |}| |}||z|||zzz|||zz|zz } |||zz|||zzz} tj| tjzt| z| tjz tdz t| zzzSyyyr) r2rrrrrrWrrrzrr rrs r5rhzairyaiprime._eval_expand_func>sSiil   u:? AS1#&AS1#&AS1#&AS1#&A !Qq!tVaK-(A}aD aC##!A!A!AQ$QqS/a!Q$h]:BAXAaC0F66b155j+f2E%EaeeUYZ[U\H\]hio]pHp%pqq $  r8NrrrrsrtrurrrwrCrLr0rrrrhr>r8r5rrsKOb EJOO5 , B Je rr8rcNeZdZdZdZdZedZd dZdZ dZ dZ d Z d Z y ) ra6 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|jr|tjurtjS|tjurtjS|tjurtj S|j r%dtddzttddz S|j r%dtddzttddz Sy)Nrr:r) r~rr~rrr{r_rr'rs r5rCzairybiprime.evals ==aee|uu  "zz!***vv (1a.(5!Q+@@@ ;;hq!n$uXa^'<< < r8ct|dk(r(|jdt|jdzSt||r)r2rr rJs r5rLzairybiprime.fdiffrr8c|jdj|}t|5tj|d}dddt j |S#1swYxYwr)r2rar-r,rrr`rs r5r0zairybiprime._eval_evalfrrc tdd}|t| tddz}t|jr*| t dz t | |t ||zzSyrrrs r5rz$airybiprime._eval_rewrite_as_besseljs` a^ aR!Q( ( a5  2d1g:"a72q>!AB B r8c tdd}tdd}|t|tddz}t|jr)|t dz t | |t ||zzSt|tdd}t||}t|| }t ||t | ||zz|dz|zt |||zzzzSrrrs r5rz$airybiprime._eval_rewrite_as_besselis a^ a^ QA' ' a5  T!W9Q'"a. @A AAx1~&AAr AAs A8q"bd!33ad1fWRA=N6NNO Or8c "|dzdtddzttddzz }tddttddz }|tgtddg|dzdz z|tgtddg|dzdz zzS)NrFrrr:rr)r!r'rr*rs r5rz"airybiprime._eval_rewrite_as_hypersdaQ l5!Q#8891aj5!Q00U2A/Aa883rHUVXYNK[]^`a]abc]cAd;dddr8c ~|jd}|j}t|dk(r|j}t d|g}t d|g}t d|g}t d|g}|j ||||zz|zz} | | |}d|zj r| |}| |}| |}||z|||zzz|||zz|zz } |||zz|||zzz} tjtd| tjz zt| z| tjzt| zzzSyyyr) r2rrrrrrWrrr rzrrrs r5rhzairybiprime._eval_expand_funcsUiil   u:? AS1#&AS1#&AS1#&AS1#&A !Qq!tVaK-(A}aD aC##!A!A!AQ$QqS/a!Q$h]:BAXAaC0F66T!Wb155j%9+f:M%MQSVWV[V[Q[]hio]pPp%pqq $  r8Nrrr>r8r5rrXsIQf EJ = =5 , C Pe rr8rc@eZdZdZedZd dZdZdZdZ dZ y) 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|tjur`|tjur"|tjurtjSt||dztjzt |z S|tjur7|tjur%ddt |dztjzz z S||k(r|tj ur3dt |dz td|dzzztjzS|dk(ratjtjt |dz ztd|dzzzt |dz td|dzzzS|jrT|jr|jrtjSt||dztjzt |z S|jr2|jr%ddt |dztjzz z Syy)NrFr:r) rr{r)rr'rrzrZr_)r@rrbrs r5rCz marcumq.eval-s ;AFF{qAFF{vv aA/%(: : ;1;q3q!taff}--- - 6AEEzCAJAqD)999166AAAvvvadU 3gaA6F FFaQRdUV]^_abdeaeVfIfff 99yyQYYvv aAaff-a8 8 99q3q!tAFF{+++ +#9r8c|j\}}}|dk(r"|t||| td|z||zzS|dk(r;||z ||dz zz t|dz|dzz dz zt|dz ||zzSt ||)NrFr:r)r2rrrZr )r4rKrrbrs r5rLz marcumq.fdiffEs))1a q=Aq))GAaCA,>>? ? ]TEA!H$adQTkN1,<(==!QqS@QQ Q$T84 4r8c ddlm}|jdtt dj }|d|z z|||zt |dz|dzz dz zt|dz ||zz||tjgzS)Nr)Integralrar:rF) sympy.integrals.integralsrgetrrnamerrZrr)r4rrbrrorras r5_eval_rewrite_as_Integralz!marcumq._eval_rewrite_as_IntegralNs6 JJsE"7"<"A"AB CQU|1sQTAqD[>!#344wqsAaC7HH1aQRQ[Q[J\]^ ^r8c ddlm}|jdtd}t |dz|dzz dz |||z |zt |||zz|d|z t jgzS)Nr)SumrrFr:)sympy.concrete.summationsrrrrrZrr)r4rrbrrorrs r5_eval_rewrite_as_Sumzmarcumq._eval_rewrite_as_SumTsl1 JJsE#J 'QTAqD[>A%&acAX1Q3-G!QqSRSR\R\I])^^^r8c R|k(r|dk(r%dtdz tddzzzdz S|jrj|dk\rdtfdt d|D}t j tdz tddzzdz ztdz |zzSyyy)Nr:rFrc3<K|]}t|dzyw)rFN)rZ).0rjrbs r5 z3marcumq._eval_rewrite_as_besseli..^s>Q1a4(>s)rrZrsumrrr)r4rrbrrors ` r5rz marcumq._eval_rewrite_as_besseliYs 6AvCAJAqD)999Q>>||Q>%1+>>vvQTE WQ1-= = AACAJQRNRR!'| r8c>td|jDryy)Nc34K|]}|jywr=)r_)rrs r5rz(marcumq._eval_is_zero..bs0ss{{0sT)allr2r3s r5 _eval_is_zerozmarcumq._eval_is_zeroas 0dii0 0 1r8Nrq) rrrsrtrurwrCrLrrrrr>r8r5rrs8.`,,.5^ _ Sr8rc4eZdZdZfdZdZdfd ZxZS)rzq Helper function to make the $\mathrm{besseli}(nu, z)$ function tractable for the Gruntz algorithm. c ddlm}ddlm}|d}|tj tj fvr|j\}} t|D cgc]]} |td|zdz d| |td|zdzd| zd| z| td| zdzdzzt| zz _} } ttdz t| z|d| td|zdzdzz |zSt |=||||Scc} wrrrrrrrrr2rrrr rrrr r4rrrarrrrrArBrrhrHs r5rz_besseli._eval_aserieslsL,a QZZ!3!34 4IIEBkpqrksufg#8AbD1Ha#8!<_QrTAXq)1>..12aXacAgq=Q9R0RS\]^S_0_auAuA<a)E!A1q!8L4M2Mq,QQ Qw$Qq$77 uA"Dc 4t| t||zSr=)rrZrs r5_eval_rewrite_as_intractablez%_besseli._eval_rewrite_as_intractableysA2wwr1~%%r8c|jdj|d}|jr,|j|j}|j |||St ||||Sror2limitr_rrrr4rarrrx0rkrHs r5rz_besseli._eval_nseries|a YYq\  1 % ::111499=A??1a. .w$Q400r8rrrrsrtrurrrrrs@r5rres 8&11r8rc4eZdZdZfdZdZdfd ZxZS)rzq Helper function to make the $\mathrm{besselk}(nu, z)$ function tractable for the Gruntz algorithm. c ddlm}ddlm}|d}|tj tj fvr|j\}} t|D cgc]]} |td|zdz d| |td|zdzd| zd| z| td| zdzdzzt| zz _} } ttdz t| z|d| td|zdzdzz |zSt |=||||Scc} wrrrs r5rz_besselk._eval_aseriessL,a QZZ!3!34 4IIEBlqrsltvgh#8AbD1Ha#8!<_QrTAXq)1>..13q !hqsQwPQ>R:S0ST]^_T`0`bvAvA<a)E!A1q!8L4M2Mq,QQ Qw$Qq$77 vrc 2t|t||zSr=)rrrs r5rz%_besselk._eval_rewrite_as_intractables1vgb!n$$r8c|jdj|d}|jr,|j|j}|j |||St ||||Srorrs r5rz_besselk._eval_nseriesrr8rrrs@r5rrs 8%11r8rN)rO)X functoolsr sympy.corersympy.core.addrsympy.core.cachersympy.core.exprrsympy.core.functionr r r sympy.core.logicr r sympy.core.numbersrrrsympy.core.powerrsympy.core.symbolrrrsympy.core.sympifyrrrr(sympy.functions.elementary.trigonometricrrrr#sympy.functions.elementary.integersr&sympy.functions.elementary.exponentialrr(sympy.functions.elementary.miscellaneousrr 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/rYrrZrr r rrr$r&r]r^r;r[r\rkrmr|rrrrrrr>r8r5r s$ MM0.. @@&OGG7;EEVVNN/6C C LmDjmD`YDjYDxf8jf8R~8j~8B+Bj+B\,Bj,B^ 2*28J . U; U;p?; ?;D6;-6;r5- 5-p5- 5-pQh##6ihXihXnhXnhbZr(Zrzar(arHgogR11>11r8