def difference_delta(expr, n=None, step=1):
 expr = sympify(expr)
 if (n is None):
  f = expr.free_symbols
  if (len(f) == 1):
   n = f.pop()
  elif (len(f) == 0):
   return S.Zero
  else:
   raise ValueError(('Since there is more than one variable in the expression, a variable must be supplied to take the difference of %s' % expr))
 step = sympify(step)
 if (step.is_number is False):
  raise ValueError('Step should be a number.')
 elif (step in [S.Infinity, (- S.Infinity)]):
  raise ValueError('Step should be bounded.')
 if hasattr(expr, '_eval_difference_delta'):
  result = expr._eval_difference_delta(n, step)
  if result:
   return result
 return (expr.subs(n, (n + step)) - expr)

def difference_delta ( expr , n = None , step = 1 ) : expr = sympify ( expr ) if ( n is None ) : f = expr . free_symbols if ( len ( f ) == 1 ) : n = f . pop ( ) elif ( len ( f ) == 0 ) : return S . Zero else : raise ValueError ( ( 'Since there is more than one variable in the expression, a variable must be supplied to take the difference of %s' % expr ) ) step = sympify ( step ) if ( step . is_number is False ) : raise ValueError ( 'Step should be a number.' ) elif ( step in [ S . Infinity , ( - S . Infinity ) ] ) : raise ValueError ( 'Step should be bounded.' ) if hasattr ( expr , '_eval_difference_delta' ) : result = expr . _eval_difference_delta ( n , step ) if result : return result return ( expr . subs ( n , ( n + step ) ) - expr )
difference operator .