(rv)
return bottom_up(rv, f)
Change products of ``tan`` or ``cot``.

    Examples
    ========

    >>> from sympy.simplify.fu import TR13
    >>> from sympy import tan, cot, cos
    >>> TR13(tan(3)*tan(2))
    -tan(2)/tan(5) - tan(3)/tan(5) + 1
    >>> TR13(cot(3)*cot(2))
    cot(2)*cot(5) + 1 + cot(3)*cot(5)
Change products of ``tan`` or ``cot``.
Change products of tan or cot .
def TR13(rv):
    """Change products of ``tan`` or ``cot``.

    Examples
    ========

    >>> from sympy.simplify.fu import TR13
    >>> from sympy import tan, cot, cos
    >>> TR13(tan(3)*tan(2))
    -tan(2)/tan(5) - tan(3)/tan(5) + 1
    >>> TR13(cot(3)*cot(2))
    cot(2)*cot(5) + 1 + cot(3)*cot(5)
    """

    def f(rv):
        if not rv.is_Mul:
            return rv

        # XXX handle products of powers? or let power-reducing handle it?
        args = {tan: [], cot: [], None: []}
        for a in ordered(Mul.make_args(rv)):
            if a.func in (tan, cot):
                args[a.func].append(a.args[0])
            else:
                args[None].append(a)
        t = args[tan]
        c = args[cot]
        if len(t) < 2 and len(c) < 2:
            return rv
        args = args[None]
        while len(t) > 1:
            t1 = t.pop()
            t2 = t.pop()
            args.append(1 - (tan(t1)/tan(t1 + t2) + tan(t2)/tan(t1 + t2)))
        if t:
            args.append(tan(t.pop()))
        while len(c) > 1:
            t1 = c.pop()
            t2 = c.pop()
            args.append(1 + cot(t1)*cot(t1 + t2) + cot(t2)*cot(t1 + t2))
        if c:
            args.append(cot(c.pop()))
        return Mul(*args)

    return bottom_up(rv, f)
def TR13 ( rv ) : def f ( rv ) : if not rv . is_Mul : return rv # XXX handle products of powers? or let power-reducing handle it? args = { tan : [ ] , cot : [ ] , None : [ ] } for a in ordered ( Mul . make_args ( rv ) ) : if a . func in ( tan , cot ) : args [ a . func ] . append ( a . args [ 0 ] ) else : args [ None ] . append ( a ) t = args [ tan ] c = args [ cot ] if len ( t ) < 2 and len ( c ) < 2 : return rv args = args [ None ] while len ( t ) > 1 : t1 = t . pop ( ) t2 = t . pop ( ) args . append ( 1 - ( tan ( t1 ) / tan ( t1 + t2 ) + tan ( t2 ) / tan ( t1 + t2 ) ) ) if t : args . append ( tan ( t . pop ( ) ) ) while len ( c ) > 1 : t1 = c . pop ( ) t2 = c . pop ( ) args . append ( 1 + cot ( t1 ) * cot ( t1 + t2 ) + cot ( t2 ) * cot ( t1 + t2 ) ) if c : args . append ( cot ( c . pop ( ) ) ) return Mul ( * args ) return bottom_up ( rv , f )