+
    ik                         R 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Ht ^ RIHtHt ^ RIHt ^ RIHtHtHtHtHtHtHt R	 tR
 tRR ltR tRR ltRR lt R t!R t"R t#R t$R t%R t&RR lt'R t(R# )a  
Algorithms for solving the Risch differential equation.

Given a differential field K of characteristic 0 that is a simple
monomial extension of a base field k and f, g in K, the Risch
Differential Equation problem is to decide if there exist y in K such
that Dy + f*y == g and to find one if there are some.  If t is a
monomial over k and the coefficients of f and g are in k(t), then y is
in k(t), and the outline of the algorithm here is given as:

1. Compute the normal part n of the denominator of y.  The problem is
then reduced to finding y' in k<t>, where y == y'/n.
2. Compute the special part s of the denominator of y.   The problem is
then reduced to finding y'' in k[t], where y == y''/(n*s)
3. Bound the degree of y''.
4. Reduce the equation Dy + f*y == g to a similar equation with f, g in
k[t].
5. Find the solutions in k[t] of bounded degree of the reduced equation.

See Chapter 6 of "Symbolic Integration I: Transcendental Functions" by
Manuel Bronstein.  See also the docstring of risch.py.
)mul)reduce)oo)Dummy)PolygcdZZcancel)imre)sqrt)gcdex_diophantinefrac_in
derivationsplitfactorNonElementaryIntegralExceptionDecrementLevelrecognize_log_derivativec                X   V P                   '       d   \        # V\        W"4      8X  d.   V P                  V4      P	                  4       ^ ,          ^ ,          # . pTpV P                  V4      p^pVP                   '       d7   VP                  WF34       WD,          pV^,          pV P                  V4      pKH  ^ p\        ^V4      p\        V4      ^ 8w  dX   VP                  4       p	W^ ,          ,          p
V P                  V
4      pVP                   '       g   KT  Wy^,          ,          pT
pKg  V# )a9  
Computes the order of a at p, with respect to t.

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

For a, p in k[t], the order of a at p is defined as nu_p(a) = max({n
in Z+ such that p**n|a}), where a != 0.  If a == 0, nu_p(a) = +oo.

To compute the order at a rational function, a/b, use the fact that
nu_p(a/b) == nu_p(a) - nu_p(b).
)	is_zeror   r   as_polyETremappendlenpop)apt
power_listp1rtracks_powernproductfinalproductfs   &&&        s/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/integrals/rde.pyorder_atr(   )   s     	yyy	DJyy| #A&& J	
B	b	AL
)))2+,UEE"I	A1ajG
j/Q
 8#EE(O999qMAGH    c                    V P                   '       d   \        # VP                  V4      V P                  V4      ,
          # )z
Computes the order of a/d at oo (infinity), with respect to t.

For f in k(t), the order or f at oo is defined as deg(d) - deg(a), where
f == a/d.
)r   r   degree)r   dr   s   &&&r'   order_at_oor-   T   s-     	yyy	88A;!$$r)   Nc                   T;'       g    \        R4      p\        W4      w  rE\        WDP                  VP                  4      4      pVP                  V4      pVP                  \        Wv4      4      p\        VP                  V4      P                  VP                  4      VP                  VP                  4      V P                  VP                  4      4      w  rV \        W2P                  4      \        W4      ,          ,
          P                  VP                  4      P                  VP                  VP                  4      4      p\        W4      pVP                  P                  V4      '       g   \        ^VP                  4      W33# VP                  4        Uu. uF  q\        9   g   K  V^ 8  g   K  VNK  	  pp\        \         V Uu. uF9  p\        V \        WP                  4      \        W4      ,          ,
          V4      NK;  	  up\        ^VP                  4      4      p\        W4      pW,          VV,          ,
          pW,          pVP#                  VRR7      w  ppVVV33# u upi u upi )aP  
Weak normalization.

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

Given a derivation D on k[t] and f == a/d in k(t), return q in k[t]
such that f - Dq/q is weakly normalized with respect to t.

f in k(t) is said to be "weakly normalized" with respect to t if
residue_p(f) is not a positive integer for any normal irreducible p
in k[t] such that f is in R_p (Definition 6.1.1).  If f has an
elementary integral, this is equivalent to no logarithm of
integral(f) whose argument depends on t has a positive integer
coefficient, where the arguments of the logarithms not in k(t) are
in k[t].

Returns (q, f - Dq/q)
zTinclude)r   r   r   diffr   quor   r   r   r   	resultantexprhas
real_rootsr   r   r   r	   )r   r,   DEr/   dndsg
d_sqf_partd1a1br!   iNr#   qdqsnsds   &&&&               r'   weak_normalizerrF   `   s   ( 	
U3ZAFB 	BAJ	J*	+BaeeBi//5rzz"$$7G			"$$EB	
T!TT]:b--	-66rtt<FF


244	AQ
A66::a==Qv&&LLN8Nq2g!a%NA8sANAqST!TT]:b+===rBANQ	A 
A	B	
qtB	
BYYr4Y(FBBx= 	9Ns   I/0I/9I/?I4
c                D   \        W4      w  rV\        W44      w  rxVP                  V4      p	VP                  VP                  VP                  4      4      P	                  V	P                  V	P                  VP                  4      4      4      p
WZ,          pW,          pVP                  V4      ^,          '       d   \        hW,          pVP                  VRR7      w  rW,          V\        W4      ,          V,          ,
          pVP                  VRR7      w  ppWV3W3V
3# )a  
Normal part of the denominator.

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

Given a derivation D on k[t] and f, g in k(t) with f weakly
normalized with respect to t, either raise NonElementaryIntegralException,
in which case the equation Dy + f*y == g has no solution in k(t), or the
quadruplet (a, b, c, h) such that a, h in k[t], b, c in k<t>, and for any
solution y in k(t) of Dy + f*y == g, q = y*h in k<t> satisfies
a*Dq + b*q == c.

This constitutes step 1 in the outline given in the rde.py docstring.
Tr0   )	r   r   r2   r   r3   divr   r	   r   )fafdgagdr8   r9   r:   enesr   hr   ccacdbabds   &&&&&            r'   normal_denomrU      s       FB FB
r
A
rwwrtt}!!!%%rtt"56A
A	AuuRy||,,	
BYYr4Y(FB	
:a$$R'	'BYYr4Y(FB Bx"1%%r)   c                
   VR8X  d   VP                   pVR8X  d"   \        VP                  VP                  4      pMVR8X  d0   \        VP                  ^,          ^,           VP                  4      pMpVR9   dX   VP                  4       P	                  V4      pVP                  4       P	                  V4      p	WV	\        ^VP                  4      3# \        RV,          4      h\        WVP                  4      \        W'VP                  4      ,
          p
\        W7VP                  4      \        WGVP                  4      ,
          p\        ^ V\        ^ V
4      ,
          4      pV
'       Eg   ^RIH	p VR8X  d   VP                  P	                  \        VP                  VP                  4      4      p\        V4      ;_uu_ 4        \        VP                  ^ 4      ) VP                  ^ 4      ,          V P                  ^ 4      ,          VP                  4      w  pp\        WP                  4      w  ppV! VVVVV4      pVe   Vw  pppV^8X  d   \        VV4      pRRR4       EMVR8X  Ed   VP                  P	                  \        VP                  ^,          ^,           VP                  4      4      p\        V4      ;_uu_ 4        \        \        VP                  \        R4      4      ) VP                  \        R4      4      ,          V P                  \        R4      4      ,          4      VP                  4      w  pp\        \!        VP                  \        R4      4      ) VP                  \        R4      4      ,          V P                  \        R4      4      ,          4      VP                  4      w  pp\        WP                  4      w  pp\#        \        ^VP                  4      V,          VV4      '       dj   V! V\        \        R4      VP                  4      ,          V,          VV,          ,           VV,          VVV4      pVe   Vw  pppV^8X  d   \        VV4      pRRR4       \%        ^ V
) W,
          4      pVV,          pW|) ,          pV V,          pVVP	                  V4      ,          \        WP                  4      V ,          \'        Wu4      P	                  V4      ,          V,          ,           pVV,          V,          P	                  V4      p	TpVWV3#   + '       g   i     L; i  + '       g   i     L; i)	a  
Special part of the denominator.

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

case is one of {'exp', 'tan', 'primitive'} for the hyperexponential,
hypertangent, and primitive cases, respectively.  For the
hyperexponential (resp. hypertangent) case, given a derivation D on
k[t] and a in k[t], b, c, in k<t> with Dt/t in k (resp. Dt/(t**2 + 1) in
k, sqrt(-1) not in k), a != 0, and gcd(a, t) == 1 (resp.
gcd(a, t**2 + 1) == 1), return the quadruplet (A, B, C, 1/h) such that
A, B, C, h in k[t] and for any solution q in k<t> of a*Dq + b*q == c,
r = qh in k[t] satisfies A*Dr + B*r == C.

For ``case == 'primitive'``, k<t> == k[t], so it returns (a, b, c, 1) in
this case.

This constitutes step 2 of the outline given in the rde.py docstring.
autoexptanz@case must be one of {'exp', 'tan', 'primitive', 'base'}, not %s.parametric_log_derivN)	primitivebase)caser   r   to_fieldr3   
ValueErrorr(   minprder[   r,   r   r   evalr
   r   r   r   maxr   )r   rS   rT   rQ   rR   r8   r_   r   BCnbncr#   r[   dcoeffalphaaalphadetaaetadAQmr/   betaabetadrA   pNpnrO   s   &&&&&&&                      r'   special_denomrv      s   . v~wwu}rtt	q1bdd#	&	&KKMb!KKMb!aa'' !%& ' 	' 
"	"!6	6B	"	"!6	6BArC2JA2.5=TTXXd244./F##!("''!*RWWQZ)?q	)I244!P$VTT2
d(tRH=GAq!Av1I $# U]TTXXd244719bdd34F##!(RWWT"X->,>rwwtBx?P,PQRQWQWX\]_X`Qa,a)bdfdhdh!i&r27748+<*<RWWT"X=N*NqvvVZ[]V^O_*_'`bdbfbfgu$VTT2
d+DBDDM%,?KK,VDb2444H-H-NvV[|-[]cdi]ikoquwyzA}"#1a6 #Aq	A $ 	AsAFA	
AB	
BB	"A
266":Qa
1(9(=(=a(@@CCA	BrrA
A qQ<E $# $#s   BT$F"T7$T4	7U	c           	       a VR8X  d   SP                   pV P                  SP                  4      pVP                  SP                  4      pV'       d   \        V3R lV 4       4      pMVP                  SP                  4      p\	        VP                  SP                  4      P                  4       P                  4       ) V P                  SP                  4      P                  4       P                  4       ,          4      p	VR8X  dX   \        ^ V\        Wv^,
          4      ,
          4      p
Wv^,
          8X  d&   V	P                  '       d   \        ^ WV,
          4      p
V
# VR8X  Ed   Wv8  d   \        ^ W,
          4      p
M\        ^ W,
          ^,           4      p
\        SP                  SP                  SP                  ^,
          ,          4      w  rSP                  p\        S4      ;_uu_ 4        \        V	SP                  4      w  rWv^,
          8X  dJ   ^RIHp  V! WW3.S4      w  w  ppp\!        V4      ^8w  d   \#        R4      h\        V
V^ ,          4      p
EMWv8X  Ed   ^RIHp V! WS4      pVe   Vw  ppV^8X  d   T \)        VS4      P                  V4      ,          VVP                  V4      ,          ,           P                  4       ) VP                  4       V P                  4       ,          ,          p\        VSP                  4      w  pp^RIHp  V! VVW3.S4      w  w  ppp\!        V4      ^8w  d   \#        R4      h\        V
V^ ,          P                  4       4      p
RRR4       V
# VR	8X  d   ^R
IHp \        ^ V\        Wv4      ,
          4      p
Wg8X  d   \        SP                  P-                  \/        SP                  SP                  4      4      SP                  SP                  ^,
          ,          4      w  r\        S4      ;_uu_ 4        \        V	SP                  4      w  rV! WWS4      pVe   Vw  p ppV ^8X  d   \        V
V4      p
RRR4       V
#  V
# VR9   d   SP                  P                  SP                  4      pSP                  P                  4       p\	        V	V,          4      p	\        ^ V\        VV,           ^,
          V4      ,
          4      p
WvV,           ^,
          8X  d&   V	P                  '       d   \        ^ WV,
          4      p
V
# \#        RV,          4      h  \$         d     ELi ; i  \$         d     ELi ; i  + '       g   i     T
# ; i  + '       g   i     T
# ; i)a=  
Bound on polynomial solutions.

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

Given a derivation D on k[t] and ``a``, ``b``, ``c`` in k[t] with ``a != 0``, return
n in ZZ such that deg(q) <= n for any solution q in k[t] of
a*Dq + b*q == c, when parametric=False, or deg(q) <= n for any solution
c1, ..., cm in Const(k) and q in k[t] of a*Dq + b*q == Sum(ci*gi, (i, 1, m))
when parametric=True.

For ``parametric=False``, ``cQ`` is ``c``, a ``Poly``; for ``parametric=True``, ``cQ`` is Q ==
[q1, ..., qm], a list of Polys.

This constitutes step 3 of the outline given in the rde.py docstring.
rW   c              3   X   <"   T F  qP                  SP                  4      x  K!  	  R # 5iN)r+   r   ).0r@   r8   s   & r'   	<genexpr>bound_degree.<locals>.<genexpr>(  s     ,A"$$s   '*r]   r\   )limited_integratezLength of m should be 1!is_log_deriv_k_t_radical_in_fieldNrX   rZ   zScase must be one of {'exp', 'tan', 'primitive', 'other_nonlinear', 'base'}, not %s.)rY   other_nonlinear)r_   r+   r   re   r	   r   LCas_expr
is_Integerr   r,   Tlevelr   rc   r}   r   ra   r   r   r   r[   r3   r   )r   r?   cQr8   r_   
parametricdadbdcalphar#   rm   rn   t1rk   rl   r}   zazdrq   r   ro   aar/   betarr   rs   r[   deltalams   &&&f&&                        r'   bound_degreer     s   ( v~ww	
"$$B	
"$$B ,,,YYrtt_AIIbddO&&(0022			"$$$$&' (E v~2BQ'(a<E,,,Au2g&A\ HY 
	7ArwAArw{#ARTT2441#56
TTB$UBDD1NF!V|3%"3Fd\N#KHRa
 1v{()BCCAqtA
 D5fbI=EBQw!":a#4#<#<R#@!@aiimO",-/RT 23499;qttv3E G'.tRTT':u;7*;E5"&+4KHRa
  #1v{&01J&K K #Aqt||~ 6AK  F H9 
.2B#$8 $rttRTT*:!;RTT"((Q,=OPJD##!(!5(RH=  GAq!Av1I $, H1 0 H 
+	+BDD!ddggiuSy!2BJNB//0eaE$4$4$4Au2g&A H  2489 : 	:q 6 0  > ! !A  F H- $#, Hsb   2,U"T>1C-U"U2<U"!A U6>U	U"UU"UU"UU""U3	6V	c                H   \        ^ VP                  4      p\        ^VP                  4      p\        ^ VP                  4      p VP                  '       d   WU^ WW3# V^ 8  RJ d   \        hV P	                  V4      pVP                  V4      P                  '       g   \        hV P                  V4      VP                  V4      VP                  V4      r!p V P                  VP                  4      ^ 8X  dD   VP                  4       P                  V 4      pVP                  4       P                  V 4      pWW6V3# \        WV4      w  rV\        W4      ,          pV
\        W4      ,
          pW0P                  VP                  4      ,          pWvV	,          ,          pW`,          pEKa  )az  
Rothstein's Special Polynomial Differential Equation algorithm.

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

Given a derivation D on k[t], an integer n and ``a``,``b``,``c`` in k[t] with
``a != 0``, either raise NonElementaryIntegralException, in which case the
equation a*Dq + b*q == c has no solution of degree at most ``n`` in
k[t], or return the tuple (B, C, m, alpha, beta) such that B, C,
alpha, beta in k[t], m in ZZ, and any solution q in k[t] of degree
at most n of a*Dq + b*q == c must be of the form
q == alpha*h + beta, where h in k[t], deg(h) <= m, and Dh + B*h == C.

This constitutes step 4 of the outline given in the rde.py docstring.
T)r   r   r   r   r   r   r3   r+   r`   r   r   )r   r?   rP   r#   r8   zeror   r   r;   r!   r/   s   &&&&&      r'   spder     sE   " 244=DBDDME244=D
9994..Ed?00EE!HuuQx00%%(AEE!HaeeAha88BDD>Q

  #A

  #A!D)) q)	Z
1!!	XXbdd^	
r)   c                x   \        ^ VP                  4      pVP                  '       Eg   VP                  VP                  4      V P                  VP                  4      ,
          p^ Tu;8:  d   V8:  g    \        h \        h\        VP                  VP                  4      P                  4       V P                  VP                  4      P                  4       ,          VP                  V,          ,          VP                  RR7      pWF,           pV^,
          pV\        Wc4      ,
          W,          ,
          pEK#  V# )a  
Poly Risch Differential Equation - No cancellation: deg(b) large enough.

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

Given a derivation D on k[t], ``n`` either an integer or +oo, and ``b``,``c``
in k[t] with ``b != 0`` and either D == d/dt or
deg(b) > max(0, deg(D) - 1), either raise NonElementaryIntegralException, in
which case the equation ``Dq + b*q == c`` has no solution of degree at
most n in k[t], or a solution q in k[t] of this equation with
``deg(q) < n``.
Fexpand)r   r   r   r+   r   r   r   r   r?   rP   r#   r8   rB   rq   r   s   &&&&   r'   no_cancel_b_larger     s     	QAiiiHHRTTNQXXbdd^+A{{00 00244##%aiio&8&8&::2447BBDDEE
1!!AC'Hr)   c                D   \        ^ VP                  4      pVP                  '       Egw   V^ 8X  d   ^ pMLVP                  VP                  4      VP                  P                  VP                  4      ,
          ^,           p^ Tu;8:  d   V8:  g    \
        h \
        hV^ 8  d   \        VP                  VP                  4      P                  4       WSP                  P                  VP                  4      P                  4       ,          ,          VP                  V,          ,          VP                  RR7      pEM2V P                  VP                  4      VP                  VP                  4      8w  d   \
        hV P                  VP                  4      ^ 8X  dg   W@P                  VP                  VP                  ^,
          ,          4      VP                  VP                  VP                  ^,
          ,          4      3# \        VP                  VP                  4      P                  4       V P                  VP                  4      P                  4       ,          VP                  RR7      pWF,           pV^,
          pV\        Wc4      ,
          W,          ,
          pEK  V# )ah  
Poly Risch Differential Equation - No cancellation: deg(b) small enough.

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

Given a derivation D on k[t], ``n`` either an integer or +oo, and ``b``,``c``
in k[t] with deg(b) < deg(D) - 1 and either D == d/dt or
deg(D) >= 2, either raise NonElementaryIntegralException, in which case the
equation Dq + b*q == c has no solution of degree at most n in k[t],
or a solution q in k[t] of this equation with deg(q) <= n, or the
tuple (h, b0, c0) such that h in k[t], b0, c0, in k, and for any
solution q in k[t] of degree at most n of Dq + bq == c, y == q - h
is a solution in k of Dy + b0*y == c0.
Fr   )r   r   r   r+   r,   r   r   r   r   r   r   r   s   &&&&   r'   no_cancel_b_smallr     s     	QAiii6ARTT!22Q6AA{{00 00q5QYYrtt_'')1TT\\"$$-?-B-B-D+DEbddAgMU$A xx~"$$/44xx~"99RTT"((Q,%78IIbdd288a<013 3QYYrtt_'')!))BDD/*<*<*>>A EE
1!!AC'Hr)   c                   \        ^ VP                  4      p\        V P                  VP                  4      P	                  4       ) VP
                  P                  VP                  4      P	                  4       ,          4      pVP                  '       d   VP                  '       d   TpMRpVP                  '       Eg9   \        WaP                  VP                  4      VP
                  P                  VP                  4      ,
          ^,           4      p^ Tu;8:  d   V8:  g    \        h \        h\        WsP
                  P                  VP                  4      P	                  4       ,          V P                  VP                  4      P	                  4       ,           4      pVP                  '       d   WGV3# V^ 8  d`   \        VP                  VP                  4      P	                  4       V,          VP                  V,          ,          VP                  RR7      p	MVP                  VP                  4      VP
                  P                  VP                  4      ^,
          8w  d   \        hVP                  VP                  4      P	                  4       V P                  VP                  4      P	                  4       ,          p	WI,           pV^,
          pV\        W4      ,
          W	,          ,
          pEKK  V# )ai  
Poly Risch Differential Equation - No cancellation: deg(b) == deg(D) - 1

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

Given a derivation D on k[t] with deg(D) >= 2, n either an integer
or +oo, and b, c in k[t] with deg(b) == deg(D) - 1, either raise
NonElementaryIntegralException, in which case the equation Dq + b*q == c has
no solution of degree at most n in k[t], or a solution q in k[t] of
this equation with deg(q) <= n, or the tuple (h, m, C) such that h
in k[t], m in ZZ, and C in k[t], and for any solution q in k[t] of
degree at most n of Dq + b*q == c, y == q - h is a solution in k[t]
of degree at most m of Dy + b*y == C.
Fr   r^   )r   r   r	   r   r   r,   r   is_positiver   re   r+   r   r   )
r?   rP   r#   r8   rB   lcMrq   ur   s
   &&&&      r'   no_cancel_equalr     s     	QA	244##%%bddll244&8&;&;&==	>B	}}}iii88BDD>BDDKK$559:A{{00 001TT\\"$$'**,,qyy/A/A/CCD999!9q5QYYrtt_'')!+BDD!G3RTT%HAxx~RTT!2Q!6644IIbddO&&(244););)==EE
1!!AC'Hr)   c           	        ^RI Hp \        V4      ;_uu_ 4        \        WP                  4      w  rVV! WVV4      pVe   Vw  r(V^8X  d   \        R4      hRRR4       VP                  '       d   V# W!P                  VP                  4      8  d   \        h\        ^ VP                  4      p	VP                  '       Eg    VP                  VP                  4      p
W*8  d   \        h\        V4      ;_uu_ 4        \        VP                  4       VP                  4      w  r\        XXWV4      w  rRRR4       \        XP                  4       XP                  4       ,          VP                  V
,          ,          VP                  RR7      pW,          p	V
^,
          pWV,          \        W4      ,           ,          pEK  V	#   + '       g   i     ELt; i  + '       g   i     L; i)a  
Poly Risch Differential Equation - Cancellation: Primitive case.

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

Given a derivation D on k[t], n either an integer or +oo, ``b`` in k, and
``c`` in k[t] with Dt in k and ``b != 0``, either raise
NonElementaryIntegralException, in which case the equation Dq + b*q == c
has no solution of degree at most n in k[t], or a solution q in k[t] of
this equation with deg(q) <= n.
r~   Nz7is_deriv_in_field() is required to  solve this problem.Fr   )rc   r   r   r   r   NotImplementedErrorr   r+   r   r   r   rischDEr   r   )r?   rP   r#   r8   r   rS   rT   ro   r/   rB   rq   a2aa2dsarE   stms   &&&&            r'   cancel_primitiver   .  sa    8			DD!-bb9=DAAv) ++ , , 
 	yyy88BDD>,,QAiiiHHRTTN500Bqttvrtt,HCRSr2FB   2::<

,RTT1W4bdd5I	E	sUZ(((HA 
		0  s   ;G 97G G	G$	c           	     \   ^RI Hp VP                  P                  \	        VP
                  VP
                  4      4      P                  4       p\        V4      ;_uu_ 4        \        WSP
                  4      w  rg\        WP
                  4      w  rV! WWgV4      p
V
e   V
w  rpV^8X  d   \        R4      hRRR4       VP                  '       d   V# W!P                  VP
                  4      8  d   \        h\	        ^ VP
                  4      pVP                  '       Egg   VP                  VP
                  4      pW,8  d   \        hV P                  4       p\        V4      ;_uu_ 4        \        WP
                  4      w  ppVX,          XV,          \	        WP
                  4      ,          ,           pVV,          p\        VP                  4       VP
                  4      w  pp\        VVVVV4      w  ppRRR4       \	        XP                  4       XP                  4       ,          VP
                  V,          ,          VP
                  RR7      pVV,          pV^,
          pWV,          \        VV4      ,           ,          pEKy  V#   + '       g   i     EL; i  + '       g   i     L; i)a  
Poly Risch Differential Equation - Cancellation: Hyperexponential case.

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

Given a derivation D on k[t], n either an integer or +oo, ``b`` in k, and
``c`` in k[t] with Dt/t in k and ``b != 0``, either raise
NonElementaryIntegralException, in which case the equation Dq + b*q == c
has no solution of degree at most n in k[t], or a solution q in k[t] of
this equation with deg(q) <= n.
rZ   Nz6is_deriv_in_field() is required to solve this problem.Fr   )rc   r[   r,   r3   r   r   r   r   r   r   r   r+   r   r   r   r   )r?   rP   r#   r8   r[   etarm   rn   rS   rT   ro   r   rq   r/   rB   r>   a1aa1dr   r   r   rE   r   s   &&&&                   r'   
cancel_expr   `  s    +
$$((4bdd#
$
,
,
.C			S$$'
DD! R8=GA!Av) +* + + 
 	yyy88BDD>,,QAiiiHHRTTN500YY[Br44(HCd(T#Xd1ddm33Cd(Cqttvrtt,HCS#sC4FB   2::<

,RTT1W4bdd5I	SE	sUZR(((HS 
		8  s   !AJ)BJJ	J+	c                d   V P                   '       g   VP                  R8X  gU   V P                  VP                  4      \	        ^ VP
                  P                  VP                  4      ^,
          4      8  d$   V'       d   ^RIHp V! WW#4      # \        WW#4      # V P                   '       gL   V P                  VP                  4      VP
                  P                  VP                  4      ^,
          8  Ed   VP                  R8X  g+   VP
                  P                  VP                  4      ^8  d   V'       d   ^RIH	p V! WW#4      # \        WW#4      p\        V\        4      '       d   V# Vw  rp
\        V4      ;_uu_ 4        V	P                  VP                  4      V
P                  VP                  4      rV	f   \        R4      hV
f   \        R4      h\!        WW#4      P                  VP                  4      pRRR4       W,           # VP
                  P                  VP                  4      ^8  EdE   V P                  VP                  4      VP
                  P                  VP                  4      ^,
          8X  d   W P                  VP                  4      P#                  4       ) VP
                  P                  VP                  4      P#                  4       ,          8  d   V P                  VP                  4      P#                  4       P$                  '       g   \'        R4      hV'       d   \)        R4      h\+        WW#4      p\        V\        4      '       d   V# Vw  rp\!        WW4      pW,           # V P                   '       d   \)        R	4      hVP                  R
8X  d    V'       d   \)        R4      h\-        WW#4      # VP                  R8X  d    V'       d   \)        R4      h\/        WW#4      # \)        RVP                  ,          4      h  + '       g   i     TX,           # ; i)z
Solve a Polynomial Risch Differential Equation with degree bound ``n``.

This constitutes step 4 of the outline given in the rde.py docstring.

For parametric=False, cQ is c, a Poly; for parametric=True, cQ is Q ==
[q1, ..., qm], a list of Polys.
r]   )prde_no_cancel_b_large)prde_no_cancel_b_smallNzb0 should be a non-Null valuezc0 should be a non-Null valuezResult should be a numberz0prde_no_cancel_b_equal() is not yet implemented.zWRemaining cases for Poly (P)RDE are not yet implemented (is_deriv_in_field() required).rX   zIParametric RDE cancellation hyperexponential case is not yet implemented.r\   zBParametric RDE cancellation primitive case is not yet implemented.zBOther Poly (P)RDE cancellation cases are not yet implemented (%s).)r   r_   r+   r   re   r,   rc   r   r   r   r   
isinstancer   r   r   ra   solve_poly_rder   	is_number	TypeErrorr   r   r   r   )r?   r   r#   r8   r   r   r   RrO   b0c0yrq   rg   s   &&&&&         r'   r   r     s-    999"''V+HHRTTNSBDDKK$5$9::4)!77 ..
)))qxx~BDD(9A(==WW"$$++bdd"3q"84)!77aQ+aH IA2##BDD)2::bdd+;B:$%DEE;$%DEE"21199"$$? $ 5L	RTT	a	AHHRTTNbddkk"$$6G!6K$K244##%%bddll244&8&;&;&=== yy!!#---788% '     A1)aHGA!qQ+A5L 999% 'B C C ww%- /H I I!!//K'- /A B B'q55 * +:<>GG+D E Ee $# q5Ls   A9PP/	c                R   \        WV4      w  pw  r\        WW#V4      w  pw  rxw  rp\        WgWW4      w  rr \        WW4      p\        WVVV4      w  rpppVP                  '       d   TpM\        WVV4      pVV,          V,           W,          3#   \         d
    \
        p L`i ; i)a  
Solve a Risch Differential Equation: Dy + f*y == g.

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

See the outline in the docstring of rde.py for more information
about the procedure used.  Either raise NonElementaryIntegralException, in
which case there is no solution y in the given differential field,
or return y in k(t) satisfying Dy + f*y == g, or raise
NotImplementedError, in which case, the algorithms necessary to
solve the given Risch Differential Equation have not yet been
implemented.
)	rF   rU   rv   r   r   r   r   r   r   )rI   rJ   rK   rL   r8   _r   rS   rT   rQ   rR   hnro   rf   rg   hsr#   rq   r   r   r   s   &&&&&                r'   r   r     s     """-KAx ,RRR @Ax"2rr6KA! q%  aB/A!UDyyy1B'!GdNBE""  
 s   B B&%B&ry   )rW   )rW   F)F))__doc__operatorr   	functoolsr   
sympy.corer   sympy.core.symbolr   sympy.polysr   r   r   r	   $sympy.functions.elementary.complexesr
   r   (sympy.functions.elementary.miscellaneousr   sympy.integrals.rischr   r   r   r   r   r   r   r(   r-   rF   rU   rv   r   r   r   r   r   r   r   r   r    r)   r'   <module>r      s   .    # - - 9 9[ [ [(V	%0f"&JQhtn-^<+^,^/d9xZz'#r)   