+
    i-                         R t ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtHt R tR tRR ltR tR tR t R# )zAThis module implements tools for integrating rational functions. )Lambda)I)S)DummySymbolsymbols)log)atan)DomainError)roots)cancel)RootSum)Poly	resultantZZc                   \        V \        4      '       d   V w  r4MV P                  4       w  r4\        W1RRR7      \        WARRR7      rCVP	                  V4      w  rSpVP                  V4      w  rcVP                  V4      P                  4       pVP                  '       d	   WW,          # \        W4V4      w  rV	P                  4       w  r\        W4      p
\        W4      pV
P                  V4      w  rLWxVP                  V4      P                  4       ,           ,          pVP                  '       Eg   VP                  RR4      p\        V\        4      '       g   \        V4      pMVP                  4       p\        WW4      pVP                  R4      pVfz   \        V \        4      '       d+   V w  r4VP                  4       VP                  4       ,          pMV P                  4       pVV0,
           F  pVP                   '       d   K  Rp M	  Rp\"        P$                  pV'       g\   V FT  w  rV	P'                  4       w  pp	V\)        V\+        W\-        V	P                  4       4      ,          4      RR7      ,          pKV  	  MuV Fo  w  rV	P'                  4       w  pp	\/        WW4      pVe   VV,          pK3  V\)        V\+        W\-        V	P                  4       4      ,          4      RR7      ,          pKq  	  VV,          pWW,          # )a	  
Performs indefinite integration of rational functions.

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

Given a field :math:`K` and a rational function :math:`f = p/q`,
where :math:`p` and :math:`q` are polynomials in :math:`K[x]`,
returns a function :math:`g` such that :math:`f = g'`.

Examples
========

>>> from sympy.integrals.rationaltools import ratint
>>> from sympy.abc import x

>>> ratint(36/(x**5 - 2*x**4 - 2*x**3 + 4*x**2 + x - 2), x)
(12*x + 6)/(x**2 - 1) + 4*log(x - 2) - 4*log(x + 1)

References
==========

.. [1] M. Bronstein, Symbolic Integration I: Transcendental
   Functions, Second Edition, Springer-Verlag, 2005, pp. 35-70

See Also
========

sympy.integrals.integrals.Integral.doit
sympy.integrals.rationaltools.ratint_logpart
sympy.integrals.rationaltools.ratint_ratpart

FT)	compositefieldsymboltreal)	quadratic)
isinstancetupleas_numer_denomr   r   div	integrateas_expris_zeroratint_ratpartgetr   r   as_dummyratint_logpartatomsis_extended_realr   Zero	primitiver   r   r   log_to_real)fxflagspqcoeffpolyresultghPQrr   r   Lr   r#   elteps_Rs   &&,                   }/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/integrals/rationaltools.pyratintr;      su   D !U1!T2DVZ4[q((1+KEaeeAhGD^^A&&(Fyyy|!"DADAQ
AQ
A558DA
!++a.((***F9998S)&&))fA!A1&yy <!U##	AGGI-	s{{+++ D #
 ff{{}1wva3qyy{#3!34F F 
 {{}1a+=1HC76!s199;'7%78DJ JC  	#<    c           
        ^ RI Hp \        W4      p \        W4      pVP                  VP	                  4       4      w  rEpVP                  4       pVP                  4       p\        ^ V4       U	u. uF$  p	\        R\        Wy,
          4      ,           4      NK&  	  p
p	\        ^ V4       U	u. uF$  p	\        R\        W,
          4      ,           4      NK&  	  pp	W,           p\        W\        V,          R7      p\        W\        V,          R7      pWP	                  4       V,          ,
          WP	                  4       V,          P                  V4      ,          ,           W,          ,
          pV! VP                  4       V4      pVP                  4       P                  V4      pVP                  4       P                  V4      p\        WP                  4       ,          V4      p\        WP                  4       ,          V4      pVV3# u up	i u up	i )aK  
Horowitz-Ostrogradsky algorithm.

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

Given a field K and polynomials f and g in K[x], such that f and g
are coprime and deg(f) < deg(g), returns fractions A and B in K(x),
such that f/g = A' + B and B has square-free denominator.

Examples
========

    >>> from sympy.integrals.rationaltools import ratint_ratpart
    >>> from sympy.abc import x, y
    >>> from sympy import Poly
    >>> ratint_ratpart(Poly(1, x, domain='ZZ'),
    ... Poly(x + 1, x, domain='ZZ'), x)
    (0, 1/(x + 1))
    >>> ratint_ratpart(Poly(1, x, domain='EX'),
    ... Poly(x**2 + y**2, x, domain='EX'), x)
    (0, 1/(x**2 + y**2))
    >>> ratint_ratpart(Poly(36, x, domain='ZZ'),
    ... Poly(x**5 - 2*x**4 - 2*x**3 + 4*x**2 + x - 2, x, domain='ZZ'), x)
    ((12*x + 6)/(x**2 - 1), 12/(x**2 - x - 2))

See Also
========

ratint, ratint_logpart
)solveab)domain)sympy.solvers.solversr>   r   	cofactorsdiffdegreeranger   strr   quocoeffsr   subsr   )r(   r0   r)   r>   uvr8   nmiA_coeffsB_coeffsC_coeffsABHr/   rat_partlog_parts   &&&                r:   r   r   }   ss   @ ,Q
AQ
Akk!&&(#GA!	
A	
A271+?+QsSZ'(+H?271+?+QsSZ'(+H?"HXH.AXH.A	FFHQJFFHQJ++A...4A188:x(F			 A			 Aa		mQ'Ha		mQ'HX% @?s   -*G?'*HNc                   \        W4      \        W4      rT;'       g    \        R4      pYVP                  4       \        W24      ,          ,
          rT\        WERR7      w  rg\        WcRR7      pV'       g   Q RV: RV: R24       h/ . rV F  p
WV
P	                  4       &   K  	  R	 pVP                  4       w  rV! W4       V EF  w  rVP                  4       w  ppVP	                  4       V8X  d   V	P                  W34       KB  W,          p\        VP                  4       VRR
7      pVP                  RR7      w  ppV! VV4       V F7  w  ppVP                  \        VP                  V4      V,          V4      4      pK9  	  VP                  V4      \        P                  .ppVP                  4       R,           FU  pVP                  VP                   4      pVV,          P#                  V4      pVP                  VP%                  4       4       KW  	  \        \'        \)        \+        VP-                  4       V4      4      4      V4      pV	P                  VV34       EK  	  V	# )a  
Lazard-Rioboo-Trager algorithm.

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

Given a field K and polynomials f and g in K[x], such that f and g
are coprime, deg(f) < deg(g) and g is square-free, returns a list
of tuples (s_i, q_i) of polynomials, for i = 1..n, such that s_i
in K[t, x] and q_i in K[t], and::

                       ___    ___
             d  f   d  \  `   \  `
             -- - = --  )      )   a log(s_i(a, x))
             dx g   dx /__,   /__,
                      i=1..n a | q_i(a) = 0

Examples
========

>>> from sympy.integrals.rationaltools import ratint_logpart
>>> from sympy.abc import x
>>> from sympy import Poly
>>> ratint_logpart(Poly(1, x, domain='ZZ'),
... Poly(x**2 + x + 1, x, domain='ZZ'), x)
[(Poly(x + 3*_t/2 + 1/2, x, domain='QQ[_t]'),
...Poly(3*_t**2 + 1, _t, domain='ZZ'))]
>>> ratint_logpart(Poly(12, x, domain='ZZ'),
... Poly(x**2 - x - 2, x, domain='ZZ'), x)
[(Poly(x - 3*_t/8 - 1/2, x, domain='QQ[_t]'),
...Poly(-_t**2 + 16, _t, domain='ZZ'))]

See Also
========

ratint, ratint_ratpart
r   T)
includePRSF)r   zBUG: resultant(z, z) cannot be zeroc                     V P                   '       dB   V ^ 8  R8X  d6   V^ ,          w  r#V P                  VP                  4      pW$,          V3V^ &   R# R# R# )    TN)r$   as_polygens)csqfr1   kc_polys   &&   r:   _include_sign%ratint_logpart.<locals>._include_sign   sL    1q5T/q6DAYYqvv&FXq[CF #2r<   )r   )all:   NN)r   r   rD   r   rE   sqf_listr&   appendLCrH   gcdinvertr   OnerI   r\   r]   remr   dictlistzipmonoms)r(   r0   r)   r   r?   r@   resr9   R_maprU   r4   rb   Cres_sqfr,   rO   r8   r1   h_lcr^   h_lc_sqfjinvrI   r-   Ts   &&&&                      r:   r"   r"      s   L :tAzq	U3ZA!&&(4:%%qq-FC
s
'C@1a@@321ahhj ! JA!{{}188:?HHaVA.D--D-1KAx!X& 1EE$quuQx{A./ ! ++a.155'CBchh/YOOA&aiik* (
 T$s188:v678!<AHHaV1 4 Hr<   c                   V P                  4       VP                  4       8  d   V) T rV P                  4       p VP                  4       pV P                  V4      w  r#VP                  '       d!   ^\	        VP                  4       4      ,          # VP                  V ) 4      w  rEpW,          W,          ,           P                  V4      p^\	        VP                  4       4      ,          pV\        WE4      ,           # )a  
Convert complex logarithms to real arctangents.

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

Given a real field K and polynomials f and g in K[x], with g != 0,
returns a sum h of arctangents of polynomials in K[x], such that:

               dh   d         f + I g
               -- = -- I log( ------- )
               dx   dx        f - I g

Examples
========

    >>> from sympy.integrals.rationaltools import log_to_atan
    >>> from sympy.abc import x
    >>> from sympy import Poly, sqrt, S
    >>> log_to_atan(Poly(x, x, domain='ZZ'), Poly(1, x, domain='ZZ'))
    2*atan(x)
    >>> log_to_atan(Poly(x + S(1)/2, x, domain='QQ'),
    ... Poly(sqrt(3)/2, x, domain='EX'))
    2*atan(2*sqrt(3)*x/3 + sqrt(3)/3)

See Also
========

log_to_real
)	rE   to_fieldr   r   r	   r   gcdexrH   log_to_atan)	r(   r0   r+   r,   sr   r1   rK   rS   s	   &&       r:   r}   r}     s    > 	xxzAHHJr11	

A	

A558DAyyyaiik"""''1"+aS13YOOAd199;;q$$$r<   c                    \        V RR7      p V P                  4       p\        V4      V8X  d   V# R#   \         d    Tu # i ; i)zget real roots of f if possibler9   )filterN)r   count_rootslenr
   )r(   r)   rs	num_rootss   &&  r:   _get_real_rootsr   H  sJ    	q	BMMO	 r7iI  	s   3 AAc           
     t   ^ RI Hp \        R\        R7      w  rVV P	                  4       P                  W5\        V,          ,           /4      P                  4       pVP	                  4       P                  W5\        V,          ,           /4      P                  4       pV! V\        RR7      p	V! V\        RR7      p
V	P                  \        P                  \        P                  4      V	P                  \        \        P                  4      rV
P                  \        P                  \        P                  4      V
P                  \        \        P                  4      r\        \        WV4      V4      p\        W4      pVf   R# \        P                  pVP                  4        EF  p\        VP                  VV/4      V4      pV'       g.   \        VP                  VV/4      V4      p\        P                  p\        VV4      pVf    R# . pV Fw  pVV9  g   K  V) V9  g   K  VP                   '       g   VP#                  4       '       d   VP%                  V) 4       KR  VP&                  '       d   Kf  VP%                  V4       Ky  	  V F  pVP                  VVVV/4      pVP)                  RR7      ^ 8w  d   K1  \        VP                  VVVV/4      V4      p\        VP                  VVVV/4      V4      pV^,          V^,          ,           P	                  4       pVV\+        V4      ,          V\-        VV4      ,          ,           ,          pK  	  EK  	  \        W4      pVf   R# VP                  4        F:  pVV\+        V P	                  4       P/                  VV4      4      ,          ,          pK<  	  V# )	a  
Convert complex logarithms to real functions.

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

Given real field K and polynomials h in K[t,x] and q in K[t],
returns real function f such that:
                      ___
              df   d  \  `
              -- = --  )  a log(h(a, x))
              dx   dx /__,
                     a | q(a) = 0

Examples
========

    >>> from sympy.integrals.rationaltools import log_to_real
    >>> from sympy.abc import x, y
    >>> from sympy import Poly, S
    >>> log_to_real(Poly(x + 3*y/2 + S(1)/2, x, domain='QQ[y]'),
    ... Poly(3*y**2 + 1, y, domain='ZZ'), x, y)
    2*sqrt(3)*atan(2*sqrt(3)*x/3 + sqrt(3)/3)/3
    >>> log_to_real(Poly(x**2 - 1, x, domain='ZZ'),
    ... Poly(-2*y + 1, y, domain='ZZ'), x, y)
    log(x**2 - 1)/2

See Also
========

log_to_atan
)collectzu,v)clsF)evaluateNT)chop)sympy.simplify.radsimpr   r   r   r   xreplacer   expandr    r   rk   r%   r   r   r   keysis_negativecould_extract_minus_signrg   r   evalfr   r}   rJ   )r1   r,   r)   r   r   rK   rL   rU   r3   H_mapQ_mapr?   r@   r^   dr9   R_ur/   r_urs   R_v
R_v_pairedr_vDrS   rT   ABR_qr4   s   &&&&                         r:   r'   r'   W  s   B /5e$DA			aQqS\*113A			aQqS\*113AAq5)EAq5)E99QUUAFF#UYYq!&&%9q99QUUAFF#UYYq!&&%9qYqQ#A
!
C
{VVFxxzQH%q) QZZC)1-A
 Aa#;
C*$#Z)????c&B&B&D&D%%sd+%%c*  C

AsAs+,AwwDw!Q&QZZCC 0115AQZZCC 0115AQ$A+&&(Bc#b'kCAq(9$999F 5 P !
C
{XXZ!C		((A.///  Mr<   )N)!__doc__sympy.core.functionr   sympy.core.numbersr   sympy.core.singletonr   sympy.core.symbolr   r   r   &sympy.functions.elementary.exponentialr   (sympy.functions.elementary.trigonometricr	   sympy.polys.polyerrorsr
   sympy.polys.polyrootsr   sympy.polys.polytoolsr   sympy.polys.rootoftoolsr   sympy.polysr   r   r   r;   r   r"   r}   r   r'    r<   r:   <module>r      sT    G &   " 6 6 6 9 . ' ( + + +jZ<~Xv.%bfr<   