def exp_re(DE, r, k):
 RE = S.Zero
 g = DE.atoms(Function).pop()
 mini = None
 for t in Add.make_args(DE):
  (coeff, d) = t.as_independent(g)
  if isinstance(d, Derivative):
   j = (len(d.args) - 1)
  else:
   j = 0
  if ((mini is None) or (j < mini)):
   mini = j
  RE += (coeff * r((k + j)))
 if mini:
  RE = RE.subs(k, (k - mini))
 return RE

def exp_re ( DE , r , k ) : RE = S . Zero g = DE . atoms ( Function ) . pop ( ) mini = None for t in Add . make_args ( DE ) : ( coeff , d ) = t . as_independent ( g ) if isinstance ( d , Derivative ) : j = ( len ( d . args ) - 1 ) else : j = 0 if ( ( mini is None ) or ( j < mini ) ) : mini = j RE += ( coeff * r ( ( k + j ) ) ) if mini : RE = RE . subs ( k , ( k - mini ) ) return RE
converts a de with constant coefficients into a re .