#NEWLINE# def prde_spde( a , b , Q , n , DE ) : #NEWLINE# #INDENT# '\n    Special Polynomial Differential Equation algorithm: Parametric Version.\n\n    Given a derivation D on k[t], an integer n, and a, b, q1, ..., qm in k[t]\n    with deg(a) > 0 and gcd(a, b) == 1, return (A, B, Q, R, n1), with\n    Qq = [q1, ..., qm] and R = [r1, ..., rm], such that for any solution\n    c1, ..., cm in Const(k) and q in k[t] of degree at most n of\n    a*Dq + b*q == Sum(ci*gi, (i, 1, m)), p = (q - Sum(ci*ri, (i, 1, m)))/a has\n    degree at most n1 and satisfies A*Dp + B*p == Sum(ci*qi, (i, 1, m))\n    ' #NEWLINE# ( R , Z ) = list ( zip ( * [ gcdex_diophantine ( b , a , qi ) for qi in Q ] ) ) #NEWLINE# A = a #NEWLINE# B = ( b + derivation ( a , DE ) ) #NEWLINE# Qq = [ ( zi - derivation ( ri , DE ) ) for ( ri , zi ) in zip ( R , Z ) ] #NEWLINE# R = list ( R ) #NEWLINE# n1 = ( n - a . degree ( DE . t ) ) #NEWLINE# return ( A , B , Qq , R , n1 )