
    \hRh                       % 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  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Jr  S SKJr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#J$r$J%r%J&r&J'r'  S SK J(r(J)r)J*r*J+r+J,r,J-r-  S SK J.r.J/r/J0r0J1r1J2r2  S SK J3r3J4r4J5r5J6r6  S SK J7r7J8r8J9r9J:r:  S SK;J<r<J=r=J>r>J?r?J@r@  S SKAJBrB  S SKCJDrDJErE  S SKFJGrG  S SKHJIrIJJrJ  S SKKJLrL  S SKMJNrNJOrO  S SKPJQrQ  S SKRJSrSJTrTJUrUJVrVJWrWJXrX  S SKYJZrZ  S SK[J\r\  S SK]J^r^  S S K_J`r`  S S!KaJbrb  S S"KcJdrd  S# re0 rfS$\gS%'   S& rh   S.S( jri " S) S*5      rjS'qk " S+ S,5      rl   S.S- jrmg')/    )annotations)defaultdict)reduce)permutations)Add)Basic)Mul)WildDummySymbol)sympify)RationalpiI)EqNe)S)ordered)iterfreeargs)expsincostancotasinatan)logsinhcoshtanhcothasinh)sqrterferfiliEi)besseljbesselybesselibesselk)hankel1hankel2jnyn)Absreimsignarg)LambertW)floorceiling)	Piecewise)	Heaviside
DiracDelta)collect)AndOr)uniq)quogcdlcmfactor_listcancelPolynomialError)itermonomials)root_factors)PolyRing)solve_lin_sys)construct_domain)	integratec                   [        5       nU R                  U5      (       Gai  U R                  (       a$  U R                  (       a  UR	                  U 5        U$ U R
                  (       d  U R                  (       a4  U R                   H  nU[        X15      -  nM     UR	                  U 5        U$ U R                  (       a  U[        U R                  U5      -  nU R                  R                  (       dv  U R                  R                  (       a>  UR	                  U R                  [        SU R                  R                  5      -  5        U$ U[        U R                  U5      U 1-  -  nU$ U R                   H  nU[        X15      -  nM     U$ )a  
Returns a set of all functional components of the given expression
which includes symbols, function applications and compositions and
non-integer powers. Fractional powers are collected with
minimal, positive exponents.

Examples
========

>>> from sympy import cos, sin
>>> from sympy.abc import x
>>> from sympy.integrals.heurisch import components

>>> components(sin(x)*cos(x)**2, x)
{x, sin(x), cos(x)}

See Also
========

heurisch
   )sethas_free	is_symbolis_commutativeaddis_Functionis_Derivativeargs
componentsis_Powbaser   
is_Integeris_Rationalr   q)fxresultgs       P/var/www/auris/envauris/lib/python3.13/site-packages/sympy/integrals/heurisch.pyrU   rU   -   s'   , UFzz!}};;1++JJqM$ M# ]]aooVV*Q**  JJqM M XXj++F55##55$$JJqvvx15577';;< M j2aS88F
 M VV*Q**  M    zdict[str, list[Dummy]]_symbols_cachec           	          [         U    n[        U5      U:  a9  UR                  [	        SU [        U5      4-  5      5        [        U5      U:  a  M9  USU $ ! [         a    / nU[         U '    Ndf = f)z*get vector of symbols local to this modulez%s%iN)ra   KeyErrorlenappendr   )namenlsymss      r_   _symbolsri   `   sx    %t$
 e*q.eFdCJ%778: e*q. !9  %$t%s   	A A0/A0Nc	                $   SSK Jn	Jn
  [        U 5      n U R	                  U5      (       d  X-  $ [        XX#XEUXx5	      n[        U[        5      (       d  U$ / n[        U
" U5      5       H  n X" U/SU4S9-  nM     U(       d  U$ [        [        U5      5      n/ nU
" U 5       H  n X" U/SU4S9-  nM     U Vs/ s H  oU;  d  M
  UPM     nnU(       d  U$ [        U5      S:  aV  / nU HB  nUR                  UR                  5        VVs/ s H  u  nn[        UU5      PM     snn5        MD     U	" USU4S9U-   n/ nU H  n[        U R!                  U5      XX4UXgU5	      n[#        UR                  5        VVs/ s H  u  nn[        UU5      PM     snn6 n[%        UR                  5        VVs/ s H  u  nn['        UU5      PM     snn6 nUc  [)        U R!                  U5      U5      nUR+                  UU45        M     [        U5      S:X  a  [        XX#XEXgU5	      W4US   S   S4/nO UR+                  [        XX#XEXgU5	      S45        [-        U6 $ ! [         a     GM  f = f! [         a     GM  f = fs  snf s  snnf s  snnf s  snnf )aC  
A wrapper around the heurisch integration algorithm.

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

This method takes the result from heurisch and checks for poles in the
denominator. For each of these poles, the integral is reevaluated, and
the final integration result is given in terms of a Piecewise.

Examples
========

>>> from sympy import cos, symbols
>>> from sympy.integrals.heurisch import heurisch, heurisch_wrapper
>>> n, x = symbols('n x')
>>> heurisch(cos(n*x), x)
sin(n*x)/n
>>> heurisch_wrapper(cos(n*x), x)
Piecewise((sin(n*x)/n, Ne(n, 0)), (x, True))

See Also
========

heurisch
r   )solvedenomsT)dictexcluderL   )sympy.solvers.solversrk   rl   r   rN   heurisch
isinstancer   r   NotImplementedErrorlistr>   rd   extenditemsr   subsr<   r=   r   rJ   re   r8   )r[   r\   rewritehintsmappingsretriesdegree_offsetunnecessary_permutations_try_heurischrk   rl   resslnsdslns0seqssub_dictkeyvaluepairsexprcondgenerics                           r_   heurisch_wrapperr   n   s   : 4
A::a==s

1M+<Cc5!!
 DVC[!	E1#D1$77D "
 
T
DEAY	UA3TA488E 
 .t!~AtD.

4y1}HJJ9IJ9I:339IJK StaT2T9Ex(!ew%%' hnn6FG6F
URU^6FGH8HI8H*#ur#u~8HIJ<QVVH-a0DdD\"  5zQ1++- &' (1+t$	& 	hqWX++- #$ 	% eY # 		 # 		. K HIsB   +I&I):	I;I;J ;J1J
I&%I&)
I87I8c                  0    \ rS rSrSrS rS rS rS rSr	g)	BesselTable   zn
Derivatives of Bessel functions of orders n and n-1
in terms of each other.

See the docstring of DiffCache.
c                r    0 U l         [        S5      U l        [        S5      U l        U R	                  5         g )Nrg   z)tabler   rg   r   _create_table)selfs    r_   __init__BesselTable.__init__   s+    
ssr`   c                   U R                   U R                  U R                  p2n[        [        [
        [        4 H=  nU" US-
  U5      X$" X#5      -  U-  -
  US-
  U" US-
  U5      -  U-  U" X#5      -
  4X'   M?     [        nU" US-
  U5      X$" X#5      -  U-  -
  US-
  U" US-
  U5      -  U-  U" X#5      -   4X'   [        nU" US-
  U5      * X$" X#5      -  U-  -
  US-
  U" US-
  U5      -  U-  U" X#5      -
  4X'   [        [        4 HA  nU" US-
  U5      US-   U" X#5      -  U-  -
  US-
  U" US-
  U5      -  U-  U" X#5      -
  4X'   MC     g )NrL   )r   rg   r   r(   r)   r,   r-   r*   r+   r.   r/   )tr   rg   r   r[   s        r_   r   BesselTable._create_table   sv   ggqssACC!7GW5A!A#q	AagIaK/1a!Qi)AaG35EH 6 ac1I!A'	!+qS!AaC)OA%!/1qsAYJ1Q71,qS!AaC)OA%!/1 bA!A#q	QqS!A'M!O31a!Qi)AaG35EH r`   c                    XR                   ;   aO  U R                   U   u  pEU R                  U4U R                  U4/nUR                  U5      UR                  U5      4$ g N)r   rg   r   rv   )r   r[   rg   r   diff0diff1repls          r_   diffsBesselTable.diffs   sV    <771:LESS!HqssAh'DJJt$ejj&677 r`   c                    XR                   ;   $ r   )r   )r   r[   s     r_   hasBesselTable.has   s    GG|r`   )rg   r   r   N)
__name__
__module____qualname____firstlineno____doc__r   r   r   r   __static_attributes__ r`   r_   r   r      s    5"8r`   r   c                  $    \ rS rSrSrS rS rSrg)	DiffCache   a5  
Store for derivatives of expressions.

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

The standard form of the derivative of a Bessel function of order n
contains two Bessel functions of orders n-1 and n+1, respectively.
Such forms cannot be used in parallel Risch algorithm, because
there is a linear recurrence relation between the three functions
while the algorithm expects that functions and derivatives are
represented in terms of algebraically independent transcendentals.

The solution is to take two of the functions, e.g., those of orders
n and n-1, and to express the derivatives in terms of the pair.
To guarantee that the proper form is used the two derivatives are
cached as soon as one is encountered.

Derivatives of other functions are also cached at no extra cost.
All derivatives are with respect to the same variable `x`.
c                J    0 U l         Xl        [        (       d  [        5       qg g r   )cacher\   _bessel_tabler   )r   r\   s     r_   r   DiffCache.__init__  s!    
 }'MM r`   c                   U R                   nX;   a   X!   $ [        US5      (       a$  [        R                  UR                  5      (       d*  [        UR                  U R                  5      5      X!'   X!   $ UR                  u  p4[        R                  UR                  X45      u  pVU R                  U5      nXW-  X!'   Xg-  X!R	                  US-
  U5      '   X!   $ )NfuncrL   )r   hasattrr   r   r   rC   diffr\   rT   r   get_diff)r   r[   r   rg   r   d0d1dzs           r_   r   DiffCache.get_diff  s    

: x !V$$!!!&&))affTVVn-EH x 66DA"((6FBq!BuEH$&EE&&1a.!xr`   )r   r\   N)r   r   r   r   r   r   r   r   r   r`   r_   r   r      s    ,*r`   r   c	                (  ^7^8^9^:^;^<^=^>^?^@^A^B^C [        U 5      n USLaC  U R                  [        [        [        [
        [        [        [        [        [        5	      (       a  gU R                  U5      (       d  X-  $ U R                  (       d  U R                  U5      u  pO[        R                  n	[         ["        [$        4[&        [(        [*        [,        4[.        0n
U(       a+  U
R1                  5        H  u  pU R3                  X5      n M     O/U
R5                  5        H  nU R                  " U6 (       d  M    O   Sn[7        X5      n[9        U5      nUGbd  U(       GdN  [;        SU/S9n[;        SU/S9n[;        SU/S9n[=        U5       GH  nUR>                  (       Ga  [A        U[B        5      (       a  URD                  S   RG                  XU-  -  5      nUbs  URI                  U[C        UU   UUU   -  -  5      UU   UUU   -  -  SUU   -  -  [K        UU   S	-   [M        UU   UUU   -  -  5      -  UU   -  5      -  -
  -  5        M  M  [A        U[N        5      (       Ga  URD                  S   RG                  XS
-  -  5      nUbh  UU   RP                  (       a*  URI                  [S        [U        UU   5      U-  5      5        O*URI                  [W        [U        UU   * 5      U-  5      5        URD                  S   RG                  XS
-  -  UU-  -   U-   5      nUGb#  UU   RP                  (       a}  URI                  [U        [X        S-  UU   * -  5      [O        UU   UU   S
-  SUU   -  -  -
  5      -  [S        [U        UU   5      U-  UU   S
[U        UU   5      -  -  -   5      -  5        OUU   RZ                  (       a~  URI                  [U        [X        S-  UU   * -  5      [O        UU   UU   S
-  SUU   -  -  -
  5      -  [W        [U        UU   * 5      U-  UU   S
[U        UU   * 5      -  -  -
  5      -  5        URD                  S   RG                  U[M        U5      S
-  -  5      nUb  UU   RP                  (       aG  URI                  [S        [U        UU   5      [M        U5      -  S	S
[U        UU   5      -  -  -   5      5        UU   RZ                  (       aL  URI                  [W        [U        UU   * 5      [M        U5      -  S	S
[U        UU   * 5      -  -  -
  5      5        GM  GM  GM  GM  UR\                  (       d  GM  URN                  R^                  (       d  GM  URN                  R`                  S
:X  d  GM   URb                  RG                  XS
-  -  U-   5      nUb  UU   RP                  (       a  UU   RP                  (       a0  URI                  [e        [U        UU   UU   -  5      U-  5      5        ODUU   RZ                  (       a0  URI                  [g        [U        UU   * UU   -  5      U-  5      5        URb                  RG                  XS
-  -  U-
  5      nUc  GM  UU   RP                  (       d  GM  UU   RP                  (       a  S	[U        UU   US
-  -  UU   -
  5      -  n[M        S
[U        UU   5      -  [U        UU   US
-  -  UU   -
  5      -  S
UU   -  U-  -   5      [U        UU   5      -  m7UURh                  T7'   URI                  T75        GM  UU   RZ                  (       d  GM  URI                  UU   * S
-  [U        UU   * 5      -  [k        [U        UU   * 5      U-  [U        UU   US
-  -  UU   -
  5      -  5      -  5        GM     OU[=        U5      -  n[=        U5       H!  nU[7        URm                  U5      U5      -  nM#     [o        S[q        U5      5      m8[s        [u        [s        [w        [y        [w        UT85       Vs/ s H  oS   R                  U5      S	   U4PM     sn5      6 5      S	   5      5      m>T> VVs0 s H	  u  nnUU_M     nnnUc~  T>S   S   U:X  d   eT>R{                  S5      /n[}        [r        5      nT> H%  nUu  nnU[        U5         R                  U5        M'     U Vs/ s H  nUU   PM
     snm>U>4S jnU" 5       nOU=(       d    / nU>4S jnU H  m>[s        T>5      m>T>U-   m>U Vs/ s H  nU" URm                  U5      5      PM     nnU Vs/ s H  nUR                  5       S	   PM     nn[        U84S jU 5       5      (       d  My  U" U 5      R                  " T86 (       d  M  [        U84S jU5      m=  O   U(       d  [        XSUUS9n U b  U	U -  $ gU Vs/ s H  n[        T=U-  5      PM     snm?U8U?4S jm:U8U9U:4S jm9U8U:U<4S jm<0 n!U H  n"U"R>                  (       d  M  [A        U"[&        5      (       a  SU!S	U" U"5      S
-  -   '   M>  [A        U"[.        5      (       a  SU!S	U" U"5      -   '   SU!S	U" U"5      -
  '   Mq  [A        U"[        5      (       d  M  SU!U" U"5      '   M     U" U 5      m7T7R                  5       u  n#n$T<" T=5      n%T<" U$5      n&[=        [s        U&5      U%S   /-   [s        U!R5                  5       5      -   5      n'U%S   [        U!R1                  5        VVs/ s H  u  nnU(       d  M  UPM     snn6 -  n(U(U#U$4 V)s/ s H  n)U)R                  " T86 PM     n*n)SU*;   a  gU* V)s/ s H  n)U)R                  5       PM     sn)u  nnnU(U&S   -  T9" U&S	   5      -  R                  5       mAU;4S jm;T;" U 5      U[        UU5      -   n,n+U+S	:  a.  U,S	:  a(  [        [y        [        T8U+U,-   S	-
  U-   5      5      5      n-O$[        [y        [        T8U+U,-   U-   5      5      5      n-[o        S[q        U-5      5      m@[        [        U-5       VV.s/ s H  u  nn.T@U   U.-  PM     sn.n6 mB[=        5       mC[y        U'5       H;  n/[        U//T8Q76 u  n0n1TCRI                  U05        TCR                  S U1 5       5        M=     SU7U8U:U=U@UAUBUC4S jjn2[        S T8 5       5      (       a  T7R                  [=        T85      -
  n3ORT7R                  5       n4U4R                  [        [w        T8S T8 5       5      5      5      R                  U4R                  -  n3U3(       d  U2" S5      n5U5c  U2" 5       n5OU2" 5       n5U5bT  U5R                  U5      n6[        U65      R                  5       n6U6R                  (       a  U6R                  U5      S	   n6U	U6-  $ US:  a  [        XXBX5S	-
  US9n U b  U	U -  $ gs  snf s  snnf s  snf s  snf s  snf s  snf s  snnf s  sn)f s  sn)f s  sn.nf )aM	  
Compute indefinite integral using heuristic Risch algorithm.

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

This is a heuristic approach to indefinite integration in finite
terms using the extended heuristic (parallel) Risch algorithm, based
on Manuel Bronstein's "Poor Man's Integrator".

The algorithm supports various classes of functions including
transcendental elementary or special functions like Airy,
Bessel, Whittaker and Lambert.

Note that this algorithm is not a decision procedure. If it isn't
able to compute the antiderivative for a given function, then this is
not a proof that such a functions does not exist.  One should use
recursive Risch algorithm in such case.  It's an open question if
this algorithm can be made a full decision procedure.

This is an internal integrator procedure. You should use top level
'integrate' function in most cases, as this procedure needs some
preprocessing steps and otherwise may fail.

Specification
=============

 heurisch(f, x, rewrite=False, hints=None)

   where
     f : expression
     x : symbol

     rewrite -> force rewrite 'f' in terms of 'tan' and 'tanh'
     hints   -> a list of functions that may appear in anti-derivate

      - hints = None          --> no suggestions at all
      - hints = [ ]           --> try to figure out
      - hints = [f1, ..., fn] --> we know better

Examples
========

>>> from sympy import tan
>>> from sympy.integrals.heurisch import heurisch
>>> from sympy.abc import x, y

>>> heurisch(y*tan(x), x)
y*log(tan(x)**2 + 1)/2

See Manuel Bronstein's "Poor Man's Integrator":

References
==========

.. [1] https://www-sop.inria.fr/cafe/Manuel.Bronstein/pmint/index.html

For more information on the implemented algorithm refer to:

.. [2] K. Geddes, L. Stefanus, On the Risch-Norman Integration
   Method and its Implementation in Maple, Proceedings of
   ISSAC'89, ACM Press, 212-217.

.. [3] J. H. Davenport, On the Parallel Risch Algorithm (I),
   Proceedings of EUROCAM'82, LNCS 144, Springer, 144-157.

.. [4] J. H. Davenport, On the Parallel Risch Algorithm (III):
   Use of Tangents, SIGSAM Bulletin 16 (1982), 3-6.

.. [5] J. H. Davenport, B. M. Trager, On the Parallel Risch
   Algorithm (II), ACM Transactions on Mathematical
   Software 11 (1985), 356-362.

See Also
========

sympy.integrals.integrals.Integral.doit
sympy.integrals.integrals.Integral
sympy.integrals.heurisch.components
TNa)rn   bcr   rL         r\   c               3     >#    [        T5       H,  n U  V Vs/ s H  n [        U 5        H  oPM     M     snn v   M.     g s  snn f 7fr   )r   r   )ijmappings     r_   _iter_mappings heurisch.<locals>._iter_mappings  s9     !'*"#8!QWQZqZq!88 +8s   AA Ac                &   > U R                  T5      $ r   )rv   )r   r   s    r_   _substituteheurisch.<locals>._substitute	  s    yy!!r`   c              3  @   >#    U  H  oR                   " T6 v   M     g 7fr   )is_polynomial).0hVs     r_   	<genexpr>heurisch.<locals>.<genexpr>  s     3Fq"Fs   c                   > [        X/TQ76 $ r   )rA   )prZ   r   s     r_   <lambda>heurisch.<locals>.<lambda>  s    A1r`   )rw   rx   r|   c           
        > [        [        TT5       VVs/ s H  u  pXR                  U5      -  PM     snn6 $ s  snnf r   )r   zipr   )r   r   vr   numerss      r_   _derivationheurisch.<locals>._derivation  s2    FA@a&&)m@AA@s   :
c                $  > T H  nU R                  U5      (       d  M  T" U 5      [        R                  Ld  M6  U R                  U5      R	                  5       u  p#T" U5      [        X3R                  U5      5      R                  5       -  s  $    U $ r   )r   r   Zeroas_poly	primitiver@   r   as_expr)r   yr   rZ   r   
_deflationr   s       r_   r   heurisch.<locals>._deflation!  sq    A55881~QVV+yy|--/!!}SFF1I%6%>%>%@@@  r`   c           
     @  > T GH  nU R                  U5      (       d  M  T	" U5      [        R                  Ld  M7  U R                  U5      R	                  5       u  p#UR                  5       n[        UT	" U5      U5      n[        U[        X3R                  U5      U5      U5      nT
" U5      nUR                  U5      R                  5       S:X  a  US   X6S   -  4s  $ T
" [        X5-  5      5      nUS   US   -  U-  US   US   -  4s  $    [        R                  U 4$ )Nr   rL   )r   r   r   r   r   r   r@   r?   r   degreerC   One)r   r   r   rZ   r   r   c_splitq_splitr   r   	_splitters           r_   r   heurisch.<locals>._splitter,  s    A55881~QVV+yy|--/IIK;q>1-3q&&)Q/3#A,99Q<&&(A-#AJAJ77#F15M2
71:-a/GAJ1FGG' * qzr`   Fc                  > U R                   (       a  U R                  R                  (       a  U R                  R                  S:w  a  U R                  R                  S:  a0  U R                  R                  U R                  R                  -   S-
  $ [        U R                  R                  U R                  R                  -   5      $ gU R                  (       d0  U R                  (       a  [        U4S jU R                   5       5      $ g)NrL   r   c              3  4   >#    U  H  nT" U5      v   M     g 7fr   r   )r   r   	_exponents     r_   r   .heurisch.<locals>._exponent.<locals>.<genexpr>n  s     4Vy||Vs   )	rV   r   rY   rZ   r   absis_AtomrT   max)r^   r   s    r_   r   heurisch.<locals>._exponentd  s    88uu  QUUWW\5577Q;5577QUUWW,q00quuww011qvv4QVV444r`   Ac              3  *   #    U  H	  u  pUv   M     g 7fr   r   )r   factmuls      r_   r   r     s     894$s   c                  >^^^ [        5       n[        5       nU S:X  a  [        T%5      nOh[        T5      n[        5       n[        T%5       HD  nU[        [        U5      5      -  n[        U5       H  n[        [        XWU S95      nX8-  n  MB     MF     / / p[        U5       H  n[	        U[
        SS9nUR                  [
        [        R                  5      nU(       d  M?  UR                  [        R                  [        R                  5      nUR                  [
        5      (       d  UR                  [
        5      (       a  M  UR                  X45        UR                  U5        M     U(       a  UR                  5       u  pX* 4U;   a`  UR                  X* 45        UR                  5       (       a  U* nUR                  X-  X-  -   5        UR                  [        X-  5      5        OUR                  U[
        U-  -   5        U(       a  M  [!        S[#        U5      5      n[!        S[#        U5      5      n[%        ['        [)        [        U5      U5      5      5       HJ  u  nnUR                  " T6 (       d  M  T"R+                  U5        U	R+                  U[-        U5      -  5        ML     [%        ['        [)        [        U5      U5      5      5       HA  u  nnUR                  " T6 (       d  M  T"R+                  U5        U
R+                  UU-  5        MC     T$T#-  [/        U	6 -   [/        U
6 -   nTT " U5      T!-  -
  nUR1                  5       S   n[        T"5      [        T5      -  m[        5       mUUU4S jm T" U5        [3        TS	S
9u  nn[7        T"U5      n[7        TU5      n UR9                  U5      n[=        UR?                  5       USS9nUc  g URA                  U5      RA                  [C        [)        T"[        R                  /[#        T"5      -  5      5      5      $ ! [4         a     g f = f! [:         a    [4        ef = f)NQ)filterF)evaluateBCr   c                V  > U R                   (       d  U R                  (       a  g U T;   a  g U R                  " T6 (       d  TR                  U 5        g U R                  (       d"  U R
                  (       d  U R                  (       a   [        [        TU R                  5      5        g [        er   )rX   rY   rN   rQ   is_Addis_MulrV   rs   maprT   rD   )r   find_non_symsnon_symssymss    r_   r   3heurisch.<locals>._integrate.<locals>.find_non_syms  se    $"2"2]]D)T"t{{S		23 &%r`   T)field)_raw)"rM   r   r   rF   r;   r   getr   r   r   r   rQ   removepopcould_extract_minus_signr   ri   rd   reversedrs   r   re   r   r   as_numer_denomrI   rD   rG   	from_expr
ValueErrorrH   coeffsxreplacerm   )&r  atansr   irreduciblessetVpolyzVr   r   log_part	atan_partmr   r\   r   r   r   r   	candidater   	raw_numerground_
coeff_ringringnumersolutionr   r  r  Fr   r   denompoly_coeffs
poly_denom	poly_part
reducibless&                              @@@r_   
_integrateheurisch.<locals>._integrate  s   C<z?Lq6D5L
+CT 233 AL?@A %L % , !")L)Da%0Aa AqEE!%%(5588quuQxx		1&!##D) * 99;DA2w%aW%--//A  qs+		$qs)$  QqS) e S#l+,S#e*%  S)>%B CDGD!xx||""1%CI. E
  S%; <=GD!xx||""1%  T* > j(3>9COK	I&..$$&q)	 ;#a&(5	&	?)$ )>IFAk62
:&	"NN9-E !%H%%h/88Sqvvhs;/?&?@AC C!  		  	"!!	"s   =P' +P7 '
P43P47Qc              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )rq   r   r   r  s     r_   r   r     s     
,!Q:a  !s   c              3  6   #    U  H  n[        5       v   M     g 7fr   )r   r)  s     r_   r   r     s     ,@aUWWas   r   )ry   rw   rx   rz   r|   r   )Yr   r   r0   r1   r2   r3   r9   r:   r6   r7   r4   rN   r   as_independentr   r   r   r   r   r   r   r   r!   r    ru   rw   keysrU   r   r
   rM   rR   rq   r&   rT   matchrQ   r'   r   r   is_positiver%   r#   r$   r   is_negativerV   rY   rZ   rW   r"   r   r   r   r   ri   rd   rs   r
  r   r   r  r   typere   r  allis_rational_functionr   rp   rC   r5   r	   r   total_degreer   r   tuplerE   r   	enumeraterB   updatefree_symbolsas_dummyr  rm   rv   expand)Dr[   r\   rw   rx   ry   rz   r{   r|   r}   indeprewritables
candidatesruletermsdcacher   r   r   r^   MdFkr   rev_mappingtypesr   er  r   r   r   rl   r]   specialtermPr   u_splitv_splitpolysr   r   polifiedr   r   monomsmonomialr  coefffactorsr&  	more_freeFdr  	antiderivr   r   r   r   r   r   r!  r   r   r"  r#  r$  r%  sD                                                          @@@@@@@@@@@@@r_   rp   rp   (  s   f 	
A
 D 55b"dIz5'3OO::a==s
88##A&q 
c3	tTDK
  + 1 1 3J		*+A !4 &**,Juuj!! - GqEq\FS1#&AS1#&AS1#&AZ===!!R((FF1IOOAdF3=!IIq"QqT!QqT'\*:ad1ad7lbQRSTQUg=VWY[\]^[_`a[acfghijgklmopqroslsgsctZtuvwxuyZyWz=z*z'{} ) $As++FF1IOOAdF3= t// %		$tAaDz!|*< = %		#dAaD5k!m*< =FF1IOOAdFQqSL1,<== t// %		$r!tadU|*<S1!aQRSTUVSWQWHXAX=Y*Y*.tAaDz!|adAd1Q4jL>Q/Q*R+S !T!"1!1!1 %		$r!tadU|*<S1!aQRSTUVSWQWHXAX=Y*Y*-dAaD5k!madAdAaD5kM>R.R*S+T !U FF1IOOAc!faiK8= t// %		$tAaDz#a&/@1aQqT
lCS/S*T U t// %		#dAaD5k#a&.@1aaPQdUmCT.T*U V  0 )+ ,6 XXXuu(((QUUWW\FFLLa4!4=QqT-=-= t// %		%QqT!A$Y0A*B C!"1!1!1 %		$tQqTE!A$J/?/A*B CFFLLa4!4=QqT-=-=-= t//%&tAaDAI!,<'=%=$'$qt*T!A$q!t)ad:J5K(KaPQRSPTfUVh(V$WX\]^_`]aXb$b24Q %		!!"1!1!1!1 %		1Q4%'$!u+*=+/adUAd1Q419qQRtCS>T0T+U+V !Ws  z SZEZFOOA.22  	c%j!A 8Dg14UA?AA$

a
 
#Q	'?'A "B CCDF G HG$+,GDAq1a4GK,r{1~"""$+KKO#4 D!ADAq$q'N!!!$  &++U58U+	9 "##;#Ar " w-44;@B5a+fooa015B279%Q1##%a(%93F333A8[8[]^8_8_5v>E  aD)ACF !V|#(-/1veAg/FB	0 G$$$49K-q001D$''16K--.16K--.D(++-1D)*  	AADAqGlGW'!*.glln1EEFE
S'--/@/$!QQA/@AAA)*Aq	3	1A	H3x +34(Q (4GAq!gaj.:gaj#99BBDJ Q<SAYqA1uQw}QA	M0IJKLw}QA0EFGH3F,K$V,/,KAx #1~h.,/ 0I J$T.A.wu888 
hC hCT 
,!
,,,NNSV+	ZZ\KKS,@a,@%A B lR__-	c?!|H<MM+.	9%,,.	!003A6IYa<aXegh]h  D\  ]F!V|#q 	@, , C9 0x A3 56/sB   '"w%w$w*#!w/
w4w9w>0w>x*x	
x
)FNN   r   NN)n
__future__r   collectionsr   	functoolsr   	itertoolsr   sympy.core.addr   sympy.core.basicr   sympy.core.mulr	   sympy.core.symbolr
   r   r   r   sympy.core.numbersr   r   r   sympy.core.relationalr   r   sympy.core.singletonr   sympy.core.sortingr   sympy.core.traversalr   sympy.functionsr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   $sympy.functions.elementary.complexesr0   r1   r2   r3   r4   &sympy.functions.elementary.exponentialr5   #sympy.functions.elementary.integersr6   r7   $sympy.functions.elementary.piecewiser8   'sympy.functions.special.delta_functionsr9   r:   sympy.simplify.radsimpr;   sympy.logic.boolalgr<   r=   sympy.utilities.iterablesr>   sympy.polysr?   r@   rA   rB   rC   rD   sympy.polys.monomialsrE   sympy.polys.polyrootsrF   sympy.polys.ringsrG   sympy.polys.solversrH   sympy.polys.constructorrI   sympy.integrals.integralsrJ   rU   ra   __annotations__ri   r   r   r   r   rp   r   r`   r_   <module>rs     s    " #  "  "  1 1 $ . . ( " & - ? ? ? > > 3 3 > > 4 4 G G ; > : I * ' * K K / . & - 4 /,^ *,& + NO?C#'^@& &P . .` FG7;er`   