#NEWLINE# @ classmethod #NEWLINE# def eval( cls , arg ) : #NEWLINE# #INDENT# from sympy.calculus.util import AccumBounds #NEWLINE# if arg . is_Number : #NEWLINE# #INDENT# if ( arg is S . NaN ) : #NEWLINE# #INDENT# return S . NaN #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( arg is S . Zero ) : #NEWLINE# #INDENT# return S . Zero #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( arg is S . Infinity ) or ( arg is S . NegativeInfinity ) ) : #NEWLINE# #INDENT# return AccumBounds ( S . NegativeInfinity , S . Infinity ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if isinstance ( arg , AccumBounds ) : #NEWLINE# #INDENT# ( min , max ) = ( arg . min , arg . max ) #NEWLINE# d = floor ( ( min / S . Pi ) ) #NEWLINE# if ( min is not S . NegativeInfinity ) : #NEWLINE# #INDENT# min = ( min - ( d * S . Pi ) ) #NEWLINE# #UNINDENT# if ( max is not S . Infinity ) : #NEWLINE# #INDENT# max = ( max - ( d * S . Pi ) ) #NEWLINE# #UNINDENT# if AccumBounds ( min , max ) . intersection ( FiniteSet ( ( S . Pi / 2 ) , ( ( 3 * S . Pi ) / 2 ) ) ) : #NEWLINE# #INDENT# return AccumBounds ( S . NegativeInfinity , S . Infinity ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return AccumBounds ( tan ( min ) , tan ( max ) ) #NEWLINE# #UNINDENT# #UNINDENT# if arg . could_extract_minus_sign ( ) : #NEWLINE# #INDENT# return ( - cls ( ( - arg ) ) ) #NEWLINE# #UNINDENT# i_coeff = arg . as_coefficient ( S . ImaginaryUnit ) #NEWLINE# if ( i_coeff is not None ) : #NEWLINE# #INDENT# return ( S . ImaginaryUnit * tanh ( i_coeff ) ) #NEWLINE# #UNINDENT# pi_coeff = _pi_coeff ( arg , 2 ) #NEWLINE# if ( pi_coeff is not None ) : #NEWLINE# #INDENT# if pi_coeff . is_integer : #NEWLINE# #INDENT# return S . Zero #NEWLINE# #UNINDENT# if ( not pi_coeff . is_Rational ) : #NEWLINE# #INDENT# narg = ( pi_coeff * S . Pi ) #NEWLINE# if ( narg != arg ) : #NEWLINE# #INDENT# return cls ( narg ) #NEWLINE# #UNINDENT# return None #NEWLINE# #UNINDENT# if pi_coeff . is_Rational : #NEWLINE# #INDENT# if ( not ( pi_coeff . q % 2 ) ) : #NEWLINE# #INDENT# narg = ( ( pi_coeff * S . Pi ) * 2 ) #NEWLINE# ( cresult , sresult ) = ( cos ( narg ) , cos ( ( narg - ( S . Pi / 2 ) ) ) ) #NEWLINE# if ( ( not isinstance ( cresult , cos ) ) and ( not isinstance ( sresult , cos ) ) ) : #NEWLINE# #INDENT# if ( sresult == 0 ) : #NEWLINE# #INDENT# return S . ComplexInfinity #NEWLINE# #UNINDENT# return ( ( 1 - cresult ) / sresult ) #NEWLINE# #UNINDENT# #UNINDENT# table2 = { #NEWLINE# #INDENT# 12 : ( 3 , 4 ) , #NEWLINE# 20 : ( 4 , 5 ) , #NEWLINE# 30 : ( 5 , 6 ) , #NEWLINE# 15 : ( 6 , 10 ) , #NEWLINE# 24 : ( 6 , 8 ) , #NEWLINE# 40 : ( 8 , 10 ) , #NEWLINE# 60 : ( 20 , 30 ) , #NEWLINE# 120 : ( 40 , 60 ) , #NEWLINE# #UNINDENT# } #NEWLINE# q = pi_coeff . q #NEWLINE# p = ( pi_coeff . p % q ) #NEWLINE# if ( q in table2 ) : #NEWLINE# #INDENT# ( nvala , nvalb ) = ( cls ( ( ( p * S . Pi ) / table2 [ q ] [ 0 ] ) ) , cls ( ( ( p * S . Pi ) / table2 [ q ] [ 1 ] ) ) ) #NEWLINE# if ( ( None == nvala ) or ( None == nvalb ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return ( ( nvala - nvalb ) / ( 1 + ( nvala * nvalb ) ) ) #NEWLINE# #UNINDENT# narg = ( ( ( ( pi_coeff + S . Half ) % 1 ) - S . Half ) * S . Pi ) #NEWLINE# ( cresult , sresult ) = ( cos ( narg ) , cos ( ( narg - ( S . Pi / 2 ) ) ) ) #NEWLINE# if ( ( not isinstance ( cresult , cos ) ) and ( not isinstance ( sresult , cos ) ) ) : #NEWLINE# #INDENT# if ( cresult == 0 ) : #NEWLINE# #INDENT# return S . ComplexInfinity #NEWLINE# #UNINDENT# return ( sresult / cresult ) #NEWLINE# #UNINDENT# if ( narg != arg ) : #NEWLINE# #INDENT# return cls ( narg ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if arg . is_Add : #NEWLINE# #INDENT# ( x , m ) = _peeloff_pi ( arg ) #NEWLINE# if m : #NEWLINE# #INDENT# tanm = tan ( m ) #NEWLINE# tanx = tan ( x ) #NEWLINE# if ( tanm is S . ComplexInfinity ) : #NEWLINE# #INDENT# return ( - cot ( x ) ) #NEWLINE# #UNINDENT# return ( ( tanm + tanm ) / ( 1 - ( tanm * tanx ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( arg . func is atan ) : #NEWLINE# #INDENT# return arg . args [ 0 ] #NEWLINE# #UNINDENT# if ( arg . func is atan2 ) : #NEWLINE# #INDENT# ( y , x ) = arg . args #NEWLINE# return ( y / x ) #NEWLINE# #UNINDENT# if ( arg . func is asin ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return ( x / sqrt ( ( 1 - ( x ** 2 ) ) ) ) #NEWLINE# #UNINDENT# if ( arg . func is acos ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return ( sqrt ( ( 1 - ( x ** 2 ) ) ) / x ) #NEWLINE# #UNINDENT# if ( arg . func is acot ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return ( 1 / x )