K i&dZddlmZmZddlmZddlmZmZddl m Z ddl m Z m Z mZmZmZddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZmZdd lm Z m!Z!m"Z"ddl#m$Z$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.m/Z/m0Z0ddl1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9ddl:m;Z;ddlm?Z?ddl@mAZAmBZBddlCmDZDddlEmFZFmGZGmHZHmIZImJZJddlKmLZLddlMmNZNmOZOddlPmQZQddlRmSZSddlTmUZUGd d!eVZWGd"d#eZXd$ZYd%ZZeZd&Z[d'Z\e[e\d(fd)Z]Gd*d+eXZ^d,Z_d-Z`Gd.d/eaZbd0ZceZd(dWd1Zdd2aeGd3d4eXZfd5ZgeZd(dXd6ZhGd7d8eXZiGd9d:eiZjd;ZkGd<d=eiZld>ZmeZd(dXd?ZnGd@dAeXZoGdBdCeoZpdDZqGdEdFeoZrdGZsGdHdIeoZtdJZuGdKdLeoZvdMZweZd(dXdNZxGdOdPeXZyGdQdReyZzdSZ{GdTdUeyZ|dVZ}dd2l~mcmZejZejZejZej Zej ZejZy2)Yz Integral Transforms )reducewraps)repeat)Spi)Add) AppliedUndef count_opsexpand expand_mulFunction)Mul)igcdilcm)default_sort_key)Dummy)postorder_traversal) factorialrf)reargAbs)exp exp_polar)coshcothsinhtanh)ceiling)MaxMinsqrt)piecewise_fold)coscotsintan)besselj) Heaviside)gamma)meijerg) integrateIntegral)_dummy)to_cnf conjuncts disjunctsOrAnd)roots)factorPoly)CRootOf)iterable)debugc"eZdZdZfdZxZS)IntegralTransformErrora Exception raised in relation to problems computing transforms. Explanation =========== This class is mostly used internally; if integrals cannot be computed objects representing unevaluated transforms are usually returned. The hint ``needeval=True`` can be used to disable returning transform objects, and instead raise this exception if an integral cannot be computed. c>t||d|d||_y)Nz" Transform could not be computed: .)super__init__function)self transformr@msg __class__s `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/integrals/transforms.pyr?zIntegralTransformError.__init__6s  9BC H J  )__name__ __module__ __qualname____doc__r? __classcell__)rDs@rEr;r;(s !!rFr;ceZdZdZedZedZedZedZdZ dZ dZ d Z d Z ed Zd Zy )IntegralTransforma} Base class for integral transforms. Explanation =========== This class represents unevaluated transforms. To implement a concrete transform, derive from this class and implement the ``_compute_transform(f, x, s, **hints)`` and ``_as_integral(f, x, s)`` functions. If the transform cannot be computed, raise :obj:`IntegralTransformError`. Also set ``cls._name``. For instance, >>> from sympy import LaplaceTransform >>> LaplaceTransform._name 'Laplace' Implement ``self._collapse_extra`` if your function returns more than just a number and possibly a convergence condition. c |jdS)z! The function to be transformed. rargsrAs rEr@zIntegralTransform.functionSyy|rFc |jdS)z; The dependent variable of the function to be transformed. rOrQs rEfunction_variablez#IntegralTransform.function_variableXrRrFc |jdS)z% The independent transform variable. rOrQs rEtransform_variablez$IntegralTransform.transform_variable]rRrFc~|jjj|jh|jhz S)zj This method returns the symbols that will exist when the transform is evaluated. )r@ free_symbolsunionrXrUrQs rErZzIntegralTransform.free_symbolsbs; }}))//1H1H0IJ%%&' 'rFc tNNotImplementedErrorrAfxshintss rE_compute_transformz$IntegralTransform._compute_transformk!!rFctr]r^rArarbrcs rE _as_integralzIntegralTransform._as_integralnrfrFcbt|}|dk(r!t|jjdd|S)NF)r3r;rDname)rAextraconds rE_collapse_extraz!IntegralTransform._collapse_extraqs0E{ 5=()<)z2IntegralTransform._try_directly..ys*N#' $xx(>(>?Ns%(z6[IT _try ] Caught IntegralTransformError, returns None) anyr@atomsr rerUrXr;r9is_Addr )rArdT try_directlyfns` rE _try_directlyzIntegralTransform._try_directlyws N+/==+>+>|+LNNN  +D++DMM**D,C,CNGLN ]]yyBB1u * NO s3BB,+B,c |jdd}|jdd}||d<|jd i|\}}||S|jr||d<|jDcgc];}|j|gt |jddzj d i|=}}g}g} |D]d}t|ts|g}| j|dt|dk(r|j|dMt|dkDs\||ddgz }f|dk(rt| j}nt| }|s|S |j|}t|r|ft|zS||fS|r+t|jj |j"d|j%|j&\} } | |jt)| gt |jddzzScc}w#t$rYwxYw) a Try to evaluate the transform in closed form. Explanation =========== This general function handles linearity, but apart from that leaves pretty much everything to _compute_transform. Standard hints are the following: - ``simplify``: whether or not to simplify the result - ``noconds``: if True, do not return convergence conditions - ``needeval``: if True, raise IntegralTransformError instead of returning IntegralTransform objects The default values of these hints depend on the concrete transform, usually the default is ``(simplify, noconds, needeval) = (True, False, False)``. needevalFsimplifyTNrTrrW)popr|rxrPrDlistdoit isinstancetupleappendlenrrror8r;_namer@ as_coeff_mulrUr) rArdr~rr{ryrbresrmresscoeffrests rErzIntegralTransform.doits*99Z/99Z.$j"""+U+A =H 99 (E* GG%E>4>>QC$tyy}*=$=?DDMuM%C%ED %!!U+A AaD!q6Q;LL1&VaZaeW$E %~4j))+4j  ,,U3E?6E%L00<' ($$dmmZA A ood&<&<= t^T^^sDzlT$))AB-5H&HJJJK%4*  s#AG';*G,&G,, G87G8cd|j|j|j|jSr])rir@rUrXrQs rE as_integralzIntegralTransform.as_integrals,  0F0F!%!8!8: :rFc|jSr])r)rArPkwargss rE_eval_rewrite_as_Integralz+IntegralTransform._eval_rewrite_as_IntegralsrFN)rGrHrIrJpropertyr@rUrXrZreriror|rrrrrFrErMrM<s,''"" "EKN:: rFrMcT|r%ddlm}ddlm}||t |dS|S)Nr)r) powdenestT)polar)sympy.simplifyrsympy.simplify.powsimprr#)exprrrrs rE _simplifyrs' +4 ."6dCDD KrFcfd}|S)aV This is a decorator generator for dropping convergence conditions. Explanation =========== Suppose you define a function ``transform(*args)`` which returns a tuple of the form ``(result, cond1, cond2, ...)``. Decorating it ``@_noconds_(default)`` will add a new keyword argument ``noconds`` to it. If ``noconds=True``, the return value will be altered to be only ``result``, whereas if ``noconds=False`` the return value will not be altered. The default value of the ``noconds`` keyword will be ``default`` (i.e. the argument of this function). c6tdfd }|S)Nnocondsc&|i|}|r|dS|SNrr)rrPrrrts rEwrapperz0_noconds_..make_wrapper..wrappers#''C1v JrF)r)rtrdefaults` rE make_wrapperz_noconds_..make_wrappers# t#*    rFr)rrs` rE _noconds_rs$ rFFcXt||tjtjfSr])r,rZeroInfinity)rarbs rE_default_integratorrs QAFFAJJ/ 00rFTc tdd| || dz z|z|}|jtsKt|j ||t j t jft jfS|js td|d|jd\}}|jtr td|d fd}t|Dcgc] }|| } }| Dcgc] }|d d k7s |} }| jd | s td|d | d\} } } t|j ||| | f| fScc}wcc}w)z0 Backend function to compute Mellin transforms. rczmellin-transformrTMellincould not compute integralrintegral in unexpected formcddlm}tj}tj}tj }t t|}tdd}|D]j}tj}tj} g} t|D]} | jtdjt|} | jr0| jdvs"| js| j|s| | gz } v|| |} | jr| jdvr| | gz } | j |k(rt#| j$| } t'| j |}|tjur||k7rt#||}4| tjur| |k7rt'| |}Yt)|t+| }m|||fS)zN Turn ``cond`` into a strip (a, b), and auxiliary conditions. r)_solve_inequalitytT)realc(|jdSr) as_real_imagrbs rEz:_mellin_transform..process_conds..)s!.."21"5rF)z==z!=)sympy.solvers.inequalitiesrrNegativeInfinityrtruer0r/rr1replacersubs is_Relationalrel_oprrltsr gtsr!r3r2)rnrabauxcondsrca_b_aux_dd_solnrcs rE process_condsz(_mellin_transform..process_condss A   JJff&,' #D ! *AB##BDq\ +YY577;tBqE1~HH ,66!9BFF1IQCKD(Q/)) |3QCKD88q=TXXr*BTXXr*B! +"#aAJ1---"'AJ#r4y)5 *6!SyrFrWFc4|d|dz t|dfS)NrrTrW)r rs rErz#_mellin_transform..BsadQqTk9QqT?;rFkeyzno convergence found)r.rrr-rrrrrr is_Piecewiser;rPr1sort)rarbs_ integratorrFrnrrrrrrrcs @rE_mellin_transformrsO s&*A1q1u:>1%A 55?21A4F4F 3SUVU[U[[[ >>$Xq2NOOffQiGAtuuX$ a68 8%N(1 7!]1  7E 7 /11Q /E / JJ;J< $Xq2HIIaIAq# QVVAr]H -1vs :: 8 /s E5 EEc&eZdZdZdZdZdZdZy)MellinTransformz Class representing unevaluated Mellin transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute Mellin transforms, see the :func:`mellin_transform` docstring. rc t|||fi|Sr])rr`s rErez"MellinTransform._compute_transformWs Aq2E22rFcjt|||dz zz|tjtjfSNrT)r-rrrrhs rErizMellinTransform._as_integralZs*!a!e* q!&&!**&=>>rFcg}g}g}|D]\\}}}||gz }||gz }||gz }t|t|ft|f}|dd|ddk\dk(s|ddk(r tddd|S)NrrTTFrzno combined convergence.)r r!r3r;) rArmrrrnsasbrrs rErozMellinTransform._collapse_extra]s    KHRa "IA "IA QCKD AwQ #t*, F1IQ "t +s1v($ :< < rFN)rGrHrIrJrrerirorrFrErrKs E3? rFrc <t|||jdi|S)a Compute the Mellin transform `F(s)` of `f(x)`, .. math :: F(s) = \int_0^\infty x^{s-1} f(x) \mathrm{d}x. For all "sensible" functions, this converges absolutely in a strip `a < \operatorname{Re}(s) < b`. Explanation =========== The Mellin transform is related via change of variables to the Fourier transform, and also to the (bilateral) Laplace transform. This function returns ``(F, (a, b), cond)`` where ``F`` is the Mellin transform of ``f``, ``(a, b)`` is the fundamental strip (as above), and ``cond`` are auxiliary convergence conditions. If the integral cannot be computed in closed form, this function returns an unevaluated :class:`MellinTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. If ``noconds=False``, then only `F` will be returned (i.e. not ``cond``, and also not the strip ``(a, b)``). Examples ======== >>> from sympy import mellin_transform, exp >>> from sympy.abc import x, s >>> mellin_transform(exp(-x), x, s) (gamma(s), (0, oo), True) See Also ======== inverse_mellin_transform, laplace_transform, fourier_transform hankel_transform, inverse_hankel_transform r)rr)rarbrcrds rEmellin_transformrls$R )?1a # ( ( 15 11rFc|\}}t|tz }t|tz }t| |z|jdz }t ||z|z|zt d|z |z ||zz d|ztzfS)a Re-write the sine function ``sin(m*s + n)`` as gamma functions, compatible with the strip (a, b). Return ``(gamma1, gamma2, fac)`` so that ``f == fac/(gamma1 * gamma2)``. Examples ======== >>> from sympy.integrals.transforms import _rewrite_sin >>> from sympy import pi, S >>> from sympy.abc import s >>> _rewrite_sin((pi, 0), s, 0, 1) (gamma(s), gamma(1 - s), pi) >>> _rewrite_sin((pi, 0), s, 1, 0) (gamma(s - 1), gamma(2 - s), -pi) >>> _rewrite_sin((pi, 0), s, -1, 0) (gamma(s + 1), gamma(-s), -pi) >>> _rewrite_sin((pi, pi/2), s, S(1)/2, S(3)/2) (gamma(s - 1/2), gamma(3/2 - s), -pi) >>> _rewrite_sin((pi, pi), s, 0, 1) (gamma(s), gamma(1 - s), -pi) >>> _rewrite_sin((2*pi, 0), s, 0, S(1)/2) (gamma(2*s), gamma(1 - 2*s), pi) >>> _rewrite_sin((2*pi, 0), s, S(1)/2, 1) (gamma(2*s - 1), gamma(2 - 2*s), -pi) rrT)r rrrr*)m_nrcrrmnrs rE _rewrite_sinrsJ DAq1R4A1R4A1q~~'**+A 1q1 uQUQY1_5Qwrz AArFceZdZdZy)MellinTransformStripErrorzF Exception raised by _rewrite_gamma. Mainly for internal use. N)rGrHrIrJrrFrErrs  rFrc /012t||g\/0/0fd}g}jtD]_}|js|jd}|j r|j d}|j\}} ||gz }ajttttD]f}|js|jd}|j r|j d}|j\}} ||tz gz }h|D cgc]} | jr t| n| }} tj} |D]} | j r| } n|D cgc]} | | z  }} t#d|Dr | js t%ddd| t't(|D cgc]} t| j*c} tjz } | | k(rEt-|dk(r| } n4| t't.|D cgc]} t| j0c} z} j3| z tj| z } tj| z }//| z/00| z0j5\}}t7j8|}t7j8|}t;t=|t?dt;t=|t?d z}g}g}g}g}g}fd 1|r|jA\2}|r||}}|}n||}}|}12fd }2js|2gz }n2jBstE2tFr2jBr2jH}2jF}ntKd}2jF}|jLr|}|dkr| }|||fgt|zz }|js&||\}}|sd|z }|||zgz }|||zgz }n122jOr!tQ2}|jSdk7rp|jUd}tW|} t-| |jSk7rtYjZ|} ||gz }|| D!cgc] }!|!z |f c}!z }|j]\}}!||gz }|!| z}!||!|r3|tj|! dzfgz }|tj|! fgz }n|d gz }|tj^|!dzfgz }|tj^|!fgz }ntE2trY|2jd\}}|r5|dkDr|| |z |d k(s|dkr|| |z |dk(r tad |||fgz }nXtE2trk2jd}|r.t|tz td|tz z t}$}#}"ntc||/0\}"}#}$||"| f|#| fgz }||$gz }ntE2tr<2jd}|t|d |fttdz |z d | fgz }ntE2tr-2jd}|ttdz |z d |fgz }nTtE2tr<2jd}|ttdz |z d |ft|d | fgz }n12|r| t7|t7|z z} ggggf\}%}&}'}(||%|'df||(|&d ffD]\})}*}+}|)s |)jA\}}!|d k7r|dk7rtt|}||z },|!|z }-|jLs tedtg|D]}.|)|,|-|.|z zfgz })|r6| dtzd|z dz z||!tjhz zzz} |||zgz }n6| dtzd|z dz z||!tjhz zzz} ||| zgz }|dk(r|*jkd|!z n|+jk|!|)rt7|}|%jmtn|&jmtn|'jmtn|(jmtn|%|&f|'|(f||| fScc} wcc} wcc} wcc} wcc}!w)a Try to rewrite the product f(s) as a product of gamma functions, so that the inverse Mellin transform of f can be expressed as a meijer G function. Explanation =========== Return (an, ap), (bm, bq), arg, exp, fac such that G((an, ap), (bm, bq), arg/z**exp)*fac is the inverse Mellin transform of f(s). Raises IntegralTransformError or MellinTransformStripError on failure. It is asserted that f has no poles in the fundamental strip designated by (a, b). One of a and b is allowed to be None. The fundamental strip is important, because it determines the inversion contour. This function can handle exponentials, linear factors, trigonometric functions. This is a helper function for inverse_mellin_transform that will not attempt any transformations on f. Examples ======== >>> from sympy.integrals.transforms import _rewrite_gamma >>> from sympy.abc import s >>> from sympy import oo >>> _rewrite_gamma(s*(s+3)*(s-1), s, -oo, oo) (([], [-3, 0, 1]), ([-2, 1, 2], []), 1, 1, -1) >>> _rewrite_gamma((s-1)**2, s, -oo, oo) (([], [1, 1]), ([2, 2], []), 1, 1, 1) Importance of the fundamental strip: >>> _rewrite_gamma(1/s, s, 0, oo) (([1], []), ([], [0]), 1, 1, 1) >>> _rewrite_gamma(1/s, s, None, oo) (([1], []), ([], [0]), 1, 1, 1) >>> _rewrite_gamma(1/s, s, 0, None) (([1], []), ([], [0]), 1, 1, 1) >>> _rewrite_gamma(1/s, s, -oo, 0) (([], [1]), ([0], []), 1, 1, -1) >>> _rewrite_gamma(1/s, s, None, 0) (([], [1]), ([0], []), 1, 1, -1) >>> _rewrite_gamma(1/s, s, -oo, None) (([], [1]), ([0], []), 1, 1, -1) >>> _rewrite_gamma(2**(-s+3), s, -oo, oo) (([], []), ([], []), 1/2, 1, 8) ctt|}tjury|kS|kS|k\dk(ry|kdk(ry|ryjsjs |jryt d)zU Decide whether pole at c lies to the left of the fundamental strip. NTFzPole inside critical strip?)r rrrrZr)ris_numerrrs rEleftz_rewrite_gamma..left s 2a5M :" * :r6M :7N G  G   ??boo((EFFrFrrTc34K|]}|jywr]) is_Rational)rsrbs rEruz!_rewrite_gamma..?s5! 5sGammaNzNonrational multiplierTFc$tdd|zS)NInverse MellinzUnrecognised form '%s'.)r;)factras rE exceptionz!_rewrite_gamma..exceptionas%&6;TW[;[\\rFc|jst|}|jdk7r|jS)z7 Test if arg is of form a*s+b, raise exception if not. rT) is_polynomialr6degree all_coeffs)rprrrcs rE linear_argz"_rewrite_gamma..linear_arglsK$3$$Q'o%S! AxxzQo%<<> !rFrz Gammas partially over the strip.)evaluaterWza is not an integerr)8rrwr*rrrPrxas_independentrr&r$r'r%ris_extended_realrOnerallr;rrqrrrras_numer_denomr make_argsrziprris_Powrrbaser is_Integerrr6rLTr4r7 all_rootsr NegativeOner_r TypeErrorrangeHalfrrr)3rarcrrr s_multipliersgrr_rbcommon_coefficient s_multiplierfacexponentnumerdenomrPfacsdfacs numer_gammas denom_gammas exponentialsrugammaslgammasufacsrrexp_rnrrsrgamma1gamma2fac_anapbmbqgammasplusminusnewanewckrrrrs3`` @@@@rE_rewrite_gammar)s ~1vYFBG4M WWU^!uuQx ffQi ::$#$$Q'*C#3##A&q% !WWS#sC ($uuQx ffQi ::$#$$Q'*C#3##A&q%(# $CPPQq11SVq8PMP }}!"  4AAaQ))AMA 5}5 5  / /$Wd4LMM%fT6C4E1256accF4EFGee'MML)) }  "-L-}=!qv=>?L q!L.!A %% Cuu\!H ~ l ~ l##%LE5 MM% E MM% E E6$<( )DUF5M1J,K KD D ELLL] h +\WGE+\WGE "xx{ dVOE [[JtS1{{yyxx |xx!8#8D$s4y00XXa[!$'1T6Dq ) q !o%    "T1 AxxzQq 1a[r7ahhj( **1-B% B7q!a%*77<<>DAq aSLE !GAAx QUUQBFO,,QUUQBK=(" Q]]AE233Q]]A.// e $diil+DAqEtQBqD(3u<EtQBqD(3t;-:<< Ax G c "  ! A',QrT{E!ad(OR'3JqM1b"'M$ f(l+f(l-CD DD dVOE c " ! A c!e,h7"Q$(U3\BD DD c " ! A c"Q$(U3X>? ?D c " ! A c"Q$(U3X>!e,(l;= =DD/ !M P3:c5k !!CR^NBB+7R*F+7R*G*I %eX::b8s' b>4 c<c c cc tdd|d}|jt}t|t |t |fD]a}|j r|jDcgc]}t|||||d}}|D cgc]} | d } } |D cgc]} | d }} t|} |s t| | jt } | j||t| fcS t|||d|d\} } }}} t!| | |||zz }|r|}n dd lm}||}|j*rt-|jd k(rit|t/|z |jdjdztt/||z |jdjdzz}t/t1|j2|j4t6zkg}|tt9t-|j:t-|j<k7dt?|j@dzk\t/t1|j2|j4t6zk(gz }t9|}|dk(r td |d||zj|||fcStd |dcc}wcc} wcc} w#t$rYwxYw#t"$rYwxYw#t($rtd |d wxYw)zs A helper for the real inverse_mellin_transform function, this one here assumes x to be real and positive. rzinverse-mellin-transformT)positiveFrrTr)gens) hyperexpandrzCould not calculate integralzdoes not convergerk)!r.rewriter*r5r r rxrP_inverse_mellin_transformrrwr)rr3r)r;r+ ValueErrorrr-r_rrrrargumentdeltarr2r r"rnu)rrcx_strip as_meijergrbr GrrrrrrCerhr-rns rEr0r0s s.DAA %AQiAq 2/) 88VV%.aAuj6;=%D%$((aQqT(E("&'QAaD'D't*CSsyy';<88Ar?CK/ / ,Q58U1XFOAq!Q 1a1f%A A I6N ~~#aff+"2a#a&j)!&&)..*;;A +AFF1INN1,==> C O$qwwrz12 RADD SY.RX\0ABQZZ)QWWRZ79: :4y 5=( !%8: :#||Ar"D((_/)b !!11b 99]%)'&      ' I,$a)GII IsB#J7 J< K(KKK& KK K#"K#&K=NcVeZdZdZdZedZedZdZe dZ dZ dZ y ) InverseMellinTransformz Class representing unevaluated inverse Mellin transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute inverse Mellin transforms, see the :func:`inverse_mellin_transform` docstring. rNonerc |tj}|tj}tj||||||fi|Sr])r=_none_sentinelrM__new__)clsrrcrbrroptss rErAzInverseMellinTransform.__new__CsB 9&55A 9&55A ((aAq!DtDDrFc|jd|jd}}|tjurd}|tjurd}||fS)Nr.)rPr=r@)rArrs rEfundamental_stripz(InverseMellinTransform.fundamental_stripJsLyy|TYYq\1 &55 5A &55 5A!t rFc |jddt>tttt t ttttttth at|D]C}|js|j!|s"|j"tvs5t%d|d|z|j&}t)||||fi|S)NrTrzComponent %s not recognised.)r_allowedrr*r&r$r'r%rrrrrrr is_Functionrrrtr;rFr0)rArrcrbrdrar6s rErez)InverseMellinTransform._compute_transformSs  *d#  UCc3dD$2H%Q' IA}}qaffH.D,-=q%Ca%GII I&&(Aq%A5AArFc,|jj}t||| zz||tjtj zz |tjtj zzfdtj ztjzz SNrW)rD_cr-r ImaginaryUnitrPi)rArrcrbrs rEriz#InverseMellinTransform._as_integralcsz NN  !qb' Aq1??1::+E'Eq$%OOAJJ$>H?$@ABCADD&BXZ ZrFN) rGrHrIrJrrr@rLrArrFrerirrFrEr=r=5sF E6]N sBEB ZrFr=c Lt||||d|djdi|S)a" Compute the inverse Mellin transform of `F(s)` over the fundamental strip given by ``strip=(a, b)``. Explanation =========== This can be defined as .. math:: f(x) = \frac{1}{2\pi i} \int_{c - i\infty}^{c + i\infty} x^{-s} F(s) \mathrm{d}s, for any `c` in the fundamental strip. Under certain regularity conditions on `F` and/or `f`, this recovers `f` from its Mellin transform `F` (and vice versa), for positive real `x`. One of `a` or `b` may be passed as ``None``; a suitable `c` will be inferred. If the integral cannot be computed in closed form, this function returns an unevaluated :class:`InverseMellinTransform` object. Note that this function will assume x to be positive and real, regardless of the SymPy assumptions! For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Examples ======== >>> from sympy import inverse_mellin_transform, oo, gamma >>> from sympy.abc import x, s >>> inverse_mellin_transform(gamma(s), s, x, (0, oo)) exp(-x) The fundamental strip matters: >>> f = 1/(s**2 - 1) >>> inverse_mellin_transform(f, s, x, (-oo, -1)) x*(1 - 1/x**2)*Heaviside(x - 1)/2 >>> inverse_mellin_transform(f, s, x, (-1, 1)) -x*Heaviside(1 - x)/2 - Heaviside(x - 1)/(2*x) >>> inverse_mellin_transform(f, s, x, (1, oo)) (1/2 - x**2/2)*Heaviside(1 - x)/x See Also ======== mellin_transform hankel_transform, inverse_hankel_transform rrTr)r=r)rrcrbr6rds rEinverse_mellin_transformrPis2j D !!Q58U1X > C C Le LLrFct||zt|tjz|z|zz|tjtj f}|j tst||tjfSt||tjtj f}|tjtj tjfvs|j tr t||d|js t||d|jd\}} |j tr t||dt||| fS)z Compute a general Fourier-type transform .. math:: F(k) = a \int_{-\infty}^{\infty} e^{bixk} f(x)\, dx. For suitable choice of *a* and *b*, this reduces to the standard Fourier and inverse Fourier transforms. z$function not integrable on real axisrrr)r,rrrMrrrrr-rrNaNr;rrP) rarbr(rrrlrr integral_frns rE_fourier_transformrTs  !A#c!AOO+A-a/001a6H6H!**2UVA 55?H%qvv--1q!"4"4ajjABJa((!**aee<< x@X$T1.TUU >>$T1.JKKffQiGAtuuX$T1.KLL Q !4 ''rFc(eZdZdZdZdZdZdZy)FourierTypeTransformz# Base class for Fourier transforms.c2td|jzNz,Class %s must implement a(self) but does notr_rDrQs rErzFourierTypeTransform.a! :T^^ KM MrFc2td|jzNz,Class %s must implement b(self) but does notrYrQs rErzFourierTypeTransform.brZrFc t||||j|j|jjfi|Sr])rTrrrDrrArarbr(rds rErez'FourierTypeTransform._compute_transforms>!!Q"&&&(DFFH"&.."6"6A:?A ArFc|j}|j}t||zt|tj z|z|zz|tj tjfSr])rrr-rrrMrr)rArarbr(rrs rEriz!FourierTypeTransform._as_integralsZ FFH FFH!C!// 1! 3A 566A>> from sympy import fourier_transform, exp >>> from sympy.abc import x, k >>> fourier_transform(exp(-x**2), x, k) sqrt(pi)*exp(-pi**2*k**2) >>> fourier_transform(exp(-x**2), x, k, noconds=False) (sqrt(pi)*exp(-pi**2*k**2), True) See Also ======== inverse_fourier_transform sine_transform, inverse_sine_transform cosine_transform, inverse_cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rbrrarbr(rds rEfourier_transformrls%N * Aq! $ ) ) 2E 22rFc eZdZdZdZdZdZy)InverseFourierTransformz Class representing unevaluated inverse Fourier transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute inverse Fourier transforms, see the :func:`inverse_fourier_transform` docstring. zInverse FouriercyrrrQs rErzInverseFourierTransform.a#rerFc(dtjzSrKrhrQs rErzInverseFourierTransform.b&sv rFNrirrFrErnrns ErFrnc <t|||jdi|S)a Compute the unitary, ordinary-frequency inverse Fourier transform of `F`, defined as .. math:: f(x) = \int_{-\infty}^\infty F(k) e^{2\pi i x k} \mathrm{d} k. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`InverseFourierTransform` object. For other Fourier transform conventions, see the function :func:`sympy.integrals.transforms._fourier_transform`. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import inverse_fourier_transform, exp, sqrt, pi >>> from sympy.abc import x, k >>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x) exp(-x**2) >>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x, noconds=False) (exp(-x**2), True) See Also ======== fourier_transform sine_transform, inverse_sine_transform cosine_transform, inverse_cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rnrrr(rbrds rEinverse_fourier_transformrs*s%N 1 "1a + 0 0 95 99rFct||z|||z|zz|tjtjf}|j t st ||tjfS|js t||d|jd\}} |j t r t||dt ||| fS)a  Compute a general sine or cosine-type transform F(k) = a int_0^oo b*sin(x*k) f(x) dx. F(k) = a int_0^oo b*cos(x*k) f(x) dx. For suitable choice of a and b, this reduces to the standard sine/cosine and inverse sine/cosine transforms. rrr) r,rrrrrr-rrrr;rP) rarbr(rrKrlrrrns rE_sine_cosine_transformrvXs !A#a!Ah,AFFAJJ 78A 55?H%qvv-- >>$T1.JKKffQiGAtuuX$T1.KLL Q !4 ''rFc(eZdZdZdZdZdZdZy)SineCosineTypeTransformzK Base class for sine and cosine transforms. Specify cls._kern. c2td|jzrXrYrQs rErzSineCosineTypeTransform.awrZrFc2td|jzr\rYrQs rErzSineCosineTypeTransform.b{rZrFc t||||j|j|jj|jj fi|Sr])rvrrrD_kernrr^s rErez*SineCosineTypeTransform._compute_transformsN%aA&*ffh&*nn&:&:&*nn&:&:E?DE ErFc|j}|j}|jj}t ||z|||z|zz|t j t jfSr])rrrDr|r-rrr)rArarbr(rrrus rEriz$SineCosineTypeTransform._as_integralsW FFH FFH NN !Aac!eH q!&&!**&=>>rFNr`rrFrErxrxqs MM E ?rFrxc$eZdZdZdZeZdZdZy) SineTransformz Class representing unevaluated sine transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute sine transforms, see the :func:`sine_transform` docstring. Sinec8tdttz SrKr"rrQs rErzSineTransform.aAwtBxrFc"tjSr]rrrQs rErzSineTransform.b uu rFN rGrHrIrJrr&r|rrrrFrErrs E E rFrc <t|||jdi|S)a1 Compute the unitary, ordinary-frequency sine transform of `f`, defined as .. math:: F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \sin(2\pi x k) \mathrm{d} x. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`SineTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import sine_transform, exp >>> from sympy.abc import x, k, a >>> sine_transform(x*exp(-a*x**2), x, k) sqrt(2)*k*exp(-k**2/(4*a))/(4*a**(3/2)) >>> sine_transform(x**(-a), x, k) 2**(1/2 - a)*k**(a - 1)*gamma(1 - a/2)/gamma(a/2 + 1/2) See Also ======== fourier_transform, inverse_fourier_transform inverse_sine_transform cosine_transform, inverse_cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rrrks rEsine_transformrs$H '=Aq ! & & / //rFc$eZdZdZdZeZdZdZy)InverseSineTransformz Class representing unevaluated inverse sine transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute inverse sine transforms, see the :func:`inverse_sine_transform` docstring. z Inverse Sinec8tdttz SrKrrQs rErzInverseSineTransform.arrFc"tjSr]rrQs rErzInverseSineTransform.brrFNrrrFrErrs E E rFrc <t|||jdi|S)am Compute the unitary, ordinary-frequency inverse sine transform of `F`, defined as .. math:: f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \sin(2\pi x k) \mathrm{d} k. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`InverseSineTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import inverse_sine_transform, exp, sqrt, gamma >>> from sympy.abc import x, k, a >>> inverse_sine_transform(2**((1-2*a)/2)*k**(a - 1)* ... gamma(-a/2 + 1)/gamma((a+1)/2), k, x) x**(-a) >>> inverse_sine_transform(sqrt(2)*k*exp(-k**2/(4*a))/(4*sqrt(a)**3), k, x) x*exp(-a*x**2) See Also ======== fourier_transform, inverse_fourier_transform sine_transform cosine_transform, inverse_cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rrrrs rEinverse_sine_transformrs%J . 1a ( - - 6 66rFc$eZdZdZdZeZdZdZy)CosineTransformz Class representing unevaluated cosine transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute cosine transforms, see the :func:`cosine_transform` docstring. Cosinec8tdttz SrKrrQs rErzCosineTransform.arrFc"tjSr]rrQs rErzCosineTransform.brrFN rGrHrIrJrr$r|rrrrFrErrs E E rFrc <t|||jdi|S)a: Compute the unitary, ordinary-frequency cosine transform of `f`, defined as .. math:: F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \cos(2\pi x k) \mathrm{d} x. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`CosineTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import cosine_transform, exp, sqrt, cos >>> from sympy.abc import x, k, a >>> cosine_transform(exp(-a*x), x, k) sqrt(2)*a/(sqrt(pi)*(a**2 + k**2)) >>> cosine_transform(exp(-a*sqrt(x))*cos(a*sqrt(x)), x, k) a*exp(-a**2/(2*k))/(2*k**(3/2)) See Also ======== fourier_transform, inverse_fourier_transform, sine_transform, inverse_sine_transform inverse_cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rrrks rEcosine_transformrs$H )?1a # ( ( 15 11rFc$eZdZdZdZeZdZdZy)InverseCosineTransformz Class representing unevaluated inverse cosine transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute inverse cosine transforms, see the :func:`inverse_cosine_transform` docstring. zInverse Cosinec8tdttz SrKrrQs rErzInverseCosineTransform.aLrrFc"tjSr]rrQs rErzInverseCosineTransform.bOrrFNrrrFrErr?s E E rFrc <t|||jdi|S)a( Compute the unitary, ordinary-frequency inverse cosine transform of `F`, defined as .. math:: f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \cos(2\pi x k) \mathrm{d} k. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`InverseCosineTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import inverse_cosine_transform, sqrt, pi >>> from sympy.abc import x, k, a >>> inverse_cosine_transform(sqrt(2)*a/(sqrt(pi)*(a**2 + k**2)), k, x) exp(-a*x) >>> inverse_cosine_transform(1/sqrt(k), k, x) 1/sqrt(x) See Also ======== fourier_transform, inverse_fourier_transform, sine_transform, inverse_sine_transform cosine_transform hankel_transform, inverse_hankel_transform mellin_transform, laplace_transform r)rrrrs rEinverse_cosine_transformrSs%H 0 !!Q * / / 8% 88rFct|t|||zz|z|tjtjf}|j t st||tjfS|js t||d|jd\}}|j t r t||dt|||fS)zv Compute a general Hankel transform .. math:: F_\nu(k) = \int_{0}^\infty f(r) J_\nu(k r) r \mathrm{d} r. rrr) r,r(rrrrrr-rrrr;rP)rarr(r4rlrrrns rE_hankel_transformr~s !GB!$$Q&AFFAJJ(?@A 55?H%qvv-- >>$T1.JKKffQiGAtuuX$T1.KLL Q !4 ''rFc2eZdZdZdZdZdZedZy)HankelTypeTransformz+ Base class for Hankel transforms. c |j|j|j|j|jdfi|SNr.)rer@rUrXrP)rArds rErzHankelTypeTransform.doitsD&t&&t}}'+'='='+'>'>'+yy|0*/ 0 0rFc 6t|||||jfi|Sr])rr)rArarr(r4rds rErez&HankelTypeTransform._compute_transforms Aq"djjBEBBrFc~t|t|||zz|z|tjtjfSr])r-r(rrr)rArarr(r4s rEriz HankelTypeTransform._as_integrals3'"ac**1,q!&&!**.EFFrFc|j|j|j|j|jdSr)rir@rUrXrPrQs rErzHankelTypeTransform.as_integrals8  !%!7!7!%!8!8!%1/ /rFN) rGrHrIrJrrerirrrrFrErrs,0CG//rFrceZdZdZdZy)HankelTransformz Class representing unevaluated Hankel transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute Hankel transforms, see the :func:`hankel_transform` docstring. HankelNrGrHrIrJrrrFrErrs ErFrc >t||||jdi|S)a Compute the Hankel transform of `f`, defined as .. math:: F_\nu(k) = \int_{0}^\infty f(r) J_\nu(k r) r \mathrm{d} r. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`HankelTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import hankel_transform, inverse_hankel_transform >>> from sympy import exp >>> from sympy.abc import r, k, m, nu, a >>> ht = hankel_transform(1/r**m, r, k, nu) >>> ht 2*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/(2**m*gamma(m/2 + nu/2)) >>> inverse_hankel_transform(ht, k, r, nu) r**(-m) >>> ht = hankel_transform(exp(-a*r), r, k, 0) >>> ht a/(k**3*(a**2/k**2 + 1)**(3/2)) >>> inverse_hankel_transform(ht, k, r, 0) exp(-a*r) See Also ======== fourier_transform, inverse_fourier_transform sine_transform, inverse_sine_transform cosine_transform, inverse_cosine_transform inverse_hankel_transform mellin_transform, laplace_transform r)rr)rarr(r4rds rEhankel_transformrs&\ -?1aB ' , , 5u 55rFceZdZdZdZy)InverseHankelTransformz Class representing unevaluated inverse Hankel transforms. For usage of this class, see the :class:`IntegralTransform` docstring. For how to compute inverse Hankel transforms, see the :func:`inverse_hankel_transform` docstring. zInverse HankelNrrrFrErrs ErFrc >t||||jdi|S)a Compute the inverse Hankel transform of `F` defined as .. math:: f(r) = \int_{0}^\infty F_\nu(k) J_\nu(k r) k \mathrm{d} k. Explanation =========== If the transform cannot be computed in closed form, this function returns an unevaluated :class:`InverseHankelTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. Note that for this transform, by default ``noconds=True``. Examples ======== >>> from sympy import hankel_transform, inverse_hankel_transform >>> from sympy import exp >>> from sympy.abc import r, k, m, nu, a >>> ht = hankel_transform(1/r**m, r, k, nu) >>> ht 2*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/(2**m*gamma(m/2 + nu/2)) >>> inverse_hankel_transform(ht, k, r, nu) r**(-m) >>> ht = hankel_transform(exp(-a*r), r, k, 0) >>> ht a/(k**3*(a**2/k**2 + 1)**(3/2)) >>> inverse_hankel_transform(ht, k, r, 0) exp(-a*r) See Also ======== fourier_transform, inverse_fourier_transform sine_transform, inverse_sine_transform cosine_transform, inverse_cosine_transform hankel_transform mellin_transform, laplace_transform r)rr)rr(rr4rds rEinverse_hankel_transformrs'\ 4 !!Q2 . 3 3 rs#;;)/#4B==AHH7CC?GG2=91/,EE'.+.&!0!(Y Y x6 U 1 +>A; A;H'B)2X*BZ  h2V  48:8:t 1Z.1Zh5Mx 4((<],],+&'3T2&':\ 4((0?/?8+($0N2(%7P-($2N4($9V 4((*/+/4 ) .6b 0 .=l+*,,..!88 66"::$>>rF