def recognize_log_derivative(a, d, DE, z=None):
 z = (z or Dummy('z'))
 (a, d) = a.cancel(d, include=True)
 (p, a) = a.div(d)
 pz = Poly(z, DE.t)
 Dd = derivation(d, DE)
 q = (a - (pz * Dd))
 (r, R) = d.resultant(q, includePRS=True)
 r = Poly(r, z)
 (Np, Sp) = splitfactor_sqf(r, DE, coefficientD=True, z=z)
 for (s, i) in Sp:
  a = real_roots(s.as_poly(z))
  if any(((not j.is_Integer) for j in a)):
   return False
 return True

def recognize_log_derivative ( a , d , DE , z = None ) : z = ( z or Dummy ( 'z' ) ) ( a , d ) = a . cancel ( d , include = True ) ( p , a ) = a . div ( d ) pz = Poly ( z , DE . t ) Dd = derivation ( d , DE ) q = ( a - ( pz * Dd ) ) ( r , R ) = d . resultant ( q , includePRS = True ) r = Poly ( r , z ) ( Np , Sp ) = splitfactor_sqf ( r , DE , coefficientD = True , z = z ) for ( s , i ) in Sp : a = real_roots ( s . as_poly ( z ) ) if any ( ( ( not j . is_Integer ) for j in a ) ) : return False return True
there exists a v in k(x)* such that f = dv/v where f a rational function if and only if f can be written as f = a/d where d is squarefree .