#NEWLINE# def limited_integrate_reduce( fa , fd , G , DE ) : #NEWLINE# #INDENT# '\n    Simpler version of step 1 & 2 for the limited integration problem.\n\n    Given a derivation D on k(t) and f, g1, ..., gn in k(t), return\n    (a, b, h, N, g, V) such that a, b, h in k[t], N is a non-negative integer,\n    g in k(t), V == [v1, ..., vm] in k(t)^m, and for any solution v in k(t),\n    c1, ..., cm in C of f == Dv + Sum(ci*wi, (i, 1, m)), p = v*h is in k<t>, and\n    p and the ci satisfy a*Dp + b*p == g + Sum(ci*vi, (i, 1, m)).  Furthermore,\n    if S1irr == Sirr, then p is in k[t], and if t is nonlinear or Liouvillian\n    over k, then deg(p) <= N.\n\n    So that the special part is always computed, this function calls the more\n    general prde_special_denom() automatically if it cannot determine that\n    S1irr == Sirr.  Furthermore, it will automatically call bound_degree() when\n    t is linear and non-Liouvillian, which for the transcendental case, implies\n    that Dt == a*t + b with for some a, b in k*.\n    ' #NEWLINE# ( dn , ds ) = splitfactor ( fd , DE ) #NEWLINE# E = [ splitfactor ( gd , DE ) for ( _ , gd ) in G ] #NEWLINE# ( En , Es ) = list ( zip ( * E ) ) #NEWLINE# c = reduce ( ( lambda i , j : i . lcm ( j ) ) , ( ( dn , ) + En ) ) #NEWLINE# hn = c . gcd ( c . diff ( DE . t ) ) #NEWLINE# a = hn #NEWLINE# b = ( - derivation ( hn , DE ) ) #NEWLINE# N = 0 #NEWLINE# if ( DE . case in [ 'base' , 'primitive' , 'exp' , 'tan' ] ) : #NEWLINE# #INDENT# hs = reduce ( ( lambda i , j : i . lcm ( j ) ) , ( ( ds , ) + Es ) ) #NEWLINE# a = ( hn * hs ) #NEWLINE# b = ( ( - derivation ( hn , DE ) ) - ( hn * derivation ( hs , DE ) ) . quo ( hs ) ) #NEWLINE# mu = min ( order_at_oo ( fa , fd , DE . t ) , min ( [ order_at_oo ( ga , gd , DE . t ) for ( ga , gd ) in G ] ) ) #NEWLINE# N = ( ( hn . degree ( DE . t ) + hs . degree ( DE . t ) ) + max ( 0 , ( ( 1 - DE . d . degree ( DE . t ) ) - mu ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# V = [ ( ( ( - a ) * hn ) * ga ) . cancel ( gd , include = True ) for ( ga , gd ) in G ] #NEWLINE# return ( a , b , a , N , ( ( a * hn ) * fa ) . cancel ( fd , include = True ) , V )