def _tan_repl_func(expr):
 if isinstance(expr, tan):
  return (sin(*expr.args) / cos(*expr.args))
 elif ((not expr.args) or expr.is_Derivative):
  return expr

def _tan_repl_func ( expr ) : if isinstance ( expr , tan ) : return ( sin ( * expr . args ) / cos ( * expr . args ) ) elif ( ( not expr . args ) or expr . is_Derivative ) : return expr
replace tan with sin/cos .