def TR2(rv):
 def f(rv):
  if (rv.func is tan):
   a = rv.args[0]
   return (sin(a) / cos(a))
  elif (rv.func is cot):
   a = rv.args[0]
   return (cos(a) / sin(a))
  return rv
 return bottom_up(rv, f)

def TR2 ( rv ) : def f ( rv ) : if ( rv . func is tan ) : a = rv . args [ 0 ] return ( sin ( a ) / cos ( a ) ) elif ( rv . func is cot ) : a = rv . args [ 0 ] return ( cos ( a ) / sin ( a ) ) return rv return bottom_up ( rv , f )
replace tan and cot with sin/cos and cos/sin examples .