#NEWLINE# def _eval_expand_trig( self , **hints ) : #NEWLINE# #INDENT# from sympy import im , re #NEWLINE# arg = self . args [ 0 ] #NEWLINE# x = None #NEWLINE# if arg . is_Add : #NEWLINE# #INDENT# from sympy import symmetric_poly #NEWLINE# n = len ( arg . args ) #NEWLINE# TX = [ ] #NEWLINE# for x in arg . args : #NEWLINE# #INDENT# tx = tan ( x , evaluate = False ) . _eval_expand_trig ( ) #NEWLINE# TX . append ( tx ) #NEWLINE# #UNINDENT# Yg = numbered_symbols ( 'Y' ) #NEWLINE# Y = [ next ( Yg ) for i in range ( n ) ] #NEWLINE# p = [ 0 , 0 ] #NEWLINE# for i in range ( ( n + 1 ) ) : #NEWLINE# #INDENT# p [ ( 1 - ( i % 2 ) ) ] += ( symmetric_poly ( i , Y ) * ( ( - 1 ) ** ( ( i % 4 ) // 2 ) ) ) #NEWLINE# #UNINDENT# return ( p [ 0 ] / p [ 1 ] ) . subs ( list ( zip ( Y , TX ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( coeff , terms ) = arg . as_coeff_Mul ( rational = True ) #NEWLINE# if ( coeff . is_Integer and ( coeff > 1 ) ) : #NEWLINE# #INDENT# I = S . ImaginaryUnit #NEWLINE# z = Symbol ( 'dummy' , real = True ) #NEWLINE# P = ( ( 1 + ( I * z ) ) ** coeff ) . expand ( ) #NEWLINE# return ( im ( P ) / re ( P ) ) . subs ( [ ( z , tan ( terms ) ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# return tan ( arg )