(a, d, DE, z=None)
return (q, (sn, sd))
Weak normalization.

    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)
Weak normalization.
Weak normalization .
def weak_normalizer(a, d, DE, z=None):
    """
    Weak normalization.

    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)
    """
    z = z or Dummy('z')
    dn, ds = splitfactor(d, DE)

    # Compute d1, where dn == d1*d2**2*...*dn**n is a square-free
    # factorization of d.
    g = gcd(dn, dn.diff(DE.t))
    d_sqf_part = dn.quo(g)
    d1 = d_sqf_part.quo(gcd(d_sqf_part, g))

    a1, b = gcdex_diophantine(d.quo(d1).as_poly(DE.t), d1.as_poly(DE.t),
        a.as_poly(DE.t))
    r = (a - Poly(z, DE.t)*derivation(d1, DE)).as_poly(DE.t).resultant(
        d1.as_poly(DE.t))
    r = Poly(r, z)

    if not r.has(z):
        return (Poly(1, DE.t), (a, d))

    N = [i for i in r.real_roots() if i in ZZ and i > 0]

    q = reduce(mul, [gcd(a - Poly(n, DE.t)*derivation(d1, DE), d1) for n in N],
        Poly(1, DE.t))

    dq = derivation(q, DE)
    sn = q*a - d*dq
    sd = q*d
    sn, sd = sn.cancel(sd, include=True)

    return (q, (sn, sd))
def weak_normalizer ( a , d , DE , z = None ) : z = z or Dummy ( 'z' ) dn , ds = splitfactor ( d , DE ) # Compute d1, where dn == d1*d2**2*...*dn**n is a square-free # factorization of d. g = gcd ( dn , dn . diff ( DE . t ) ) d_sqf_part = dn . quo ( g ) d1 = d_sqf_part . quo ( gcd ( d_sqf_part , g ) ) a1 , b = gcdex_diophantine ( d . quo ( d1 ) . as_poly ( DE . t ) , d1 . as_poly ( DE . t ) , a . as_poly ( DE . t ) ) r = ( a - Poly ( z , DE . t ) * derivation ( d1 , DE ) ) . as_poly ( DE . t ) . resultant ( d1 . as_poly ( DE . t ) ) r = Poly ( r , z ) if not r . has ( z ) : return ( Poly ( 1 , DE . t ) , ( a , d ) ) N = [ i for i in r . real_roots ( ) if i in ZZ and i > 0 ] q = reduce ( mul , [ gcd ( a - Poly ( n , DE . t ) * derivation ( d1 , DE ) , d1 ) for n in N ] , Poly ( 1 , DE . t ) ) dq = derivation ( q , DE ) sn = q * a - d * dq sd = q * d sn , sd = sn . cancel ( sd , include = True ) return ( q , ( sn , sd ) )