def hyper_re(DE, r, k):
 RE = S.Zero
 g = DE.atoms(Function).pop()
 x = g.atoms(Symbol).pop()
 mini = None
 for t in Add.make_args(DE.expand()):
  (coeff, d) = t.as_independent(g)
  (c, v) = coeff.as_independent(x)
  l = v.as_coeff_exponent(x)[1]
  if isinstance(d, Derivative):
   j = len(d.args[1:])
  else:
   j = 0
  RE += ((c * rf(((k + 1) - l), j)) * r(((k + j) - l)))
  if ((mini is None) or ((j - l) < mini)):
   mini = (j - l)
 RE = RE.subs(k, (k - mini))
 m = Wild('m')
 return RE.collect(r((k + m)))

def hyper_re ( DE , r , k ) : RE = S . Zero g = DE . atoms ( Function ) . pop ( ) x = g . atoms ( Symbol ) . pop ( ) mini = None for t in Add . make_args ( DE . expand ( ) ) : ( coeff , d ) = t . as_independent ( g ) ( c , v ) = coeff . as_independent ( x ) l = v . as_coeff_exponent ( x ) [ 1 ] if isinstance ( d , Derivative ) : j = len ( d . args [ 1 : ] ) else : j = 0 RE += ( ( c * rf ( ( ( k + 1 ) - l ) , j ) ) * r ( ( ( k + j ) - l ) ) ) if ( ( mini is None ) or ( ( j - l ) < mini ) ) : mini = ( j - l ) RE = RE . subs ( k , ( k - mini ) ) m = Wild ( 'm' ) return RE . collect ( r ( ( k + m ) ) )
converts a de into a re .