(p, DE, z)
return (qa, qd, b)
Integration of hyperexponential polynomials.

    Given a hyperexponential monomial t over k and p in k[t, 1/t], return q in
    k[t, 1/t] and a bool b in {True, False} such that p - Dq in k if b is True,
    or p - Dq does not have an elementary integral over k(t) if b is False.
Integration of hyperexponential polynomials.
Integration of hyperexponential polynomials .
def integrate_hyperexponential_polynomial(p, DE, z):
    """
    Integration of hyperexponential polynomials.

    Given a hyperexponential monomial t over k and p in k[t, 1/t], return q in
    k[t, 1/t] and a bool b in {True, False} such that p - Dq in k if b is True,
    or p - Dq does not have an elementary integral over k(t) if b is False.
    """
    from sympy.integrals.rde import rischDE

    t1 = DE.t
    dtt = DE.d.exquo(Poly(DE.t, DE.t))
    qa = Poly(0, DE.t)
    qd = Poly(1, DE.t)
    b = True

    if p.is_zero:
        return(qa, qd, b)

    with DecrementLevel(DE):
        for i in xrange(-p.degree(z), p.degree(t1) + 1):
            if not i:
                continue
            elif i < 0:
                # If you get AttributeError: 'NoneType' object has no attribute 'nth'
                # then this should really not have expand=False
                # But it shouldn't happen because p is already a Poly in t and z
                a = p.as_poly(z, expand=False).nth(-i)
            else:
                # If you get AttributeError: 'NoneType' object has no attribute 'nth'
                # then this should really not have expand=False
                a = p.as_poly(t1, expand=False).nth(i)

            aa, ad = frac_in(a, DE.t, field=True)
            aa, ad = aa.cancel(ad, include=True)
            iDt = Poly(i, t1)*dtt
            iDta, iDtd = frac_in(iDt, DE.t, field=True)
            try:
                va, vd = rischDE(iDta, iDtd, Poly(aa, DE.t), Poly(ad, DE.t), DE)
                va, vd = frac_in((va, vd), t1)
            except NonElementaryIntegralException:
                b = False
            else:
                qa = qa*vd + va*Poly(t1**i)*qd
                qd *= vd

    return (qa, qd, b)
def integrate_hyperexponential_polynomial ( p , DE , z ) : from sympy . integrals . rde import rischDE t1 = DE . t dtt = DE . d . exquo ( Poly ( DE . t , DE . t ) ) qa = Poly ( 0 , DE . t ) qd = Poly ( 1 , DE . t ) b = True if p . is_zero : return ( qa , qd , b ) with DecrementLevel ( DE ) : for i in xrange ( - p . degree ( z ) , p . degree ( t1 ) + 1 ) : if not i : continue elif i < 0 : # If you get AttributeError: 'NoneType' object has no attribute 'nth' # then this should really not have expand=False # But it shouldn't happen because p is already a Poly in t and z a = p . as_poly ( z , expand = False ) . nth ( - i ) else : # If you get AttributeError: 'NoneType' object has no attribute 'nth' # then this should really not have expand=False a = p . as_poly ( t1 , expand = False ) . nth ( i ) aa , ad = frac_in ( a , DE . t , field = True ) aa , ad = aa . cancel ( ad , include = True ) iDt = Poly ( i , t1 ) * dtt iDta , iDtd = frac_in ( iDt , DE . t , field = True ) try : va , vd = rischDE ( iDta , iDtd , Poly ( aa , DE . t ) , Poly ( ad , DE . t ) , DE ) va , vd = frac_in ( ( va , vd ) , t1 ) except NonElementaryIntegralException : b = False else : qa = qa * vd + va * Poly ( t1 ** i ) * qd qd *= vd return ( qa , qd , b )