#NEWLINE# @ classmethod #NEWLINE# def eval( cls , arg ) : #NEWLINE# #INDENT# from sympy.functions.special.polynomials import chebyshevt #NEWLINE# 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 . One #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( arg is S . Infinity ) or ( arg is S . NegativeInfinity ) ) : #NEWLINE# #INDENT# return AccumBounds ( ( - 1 ) , 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if isinstance ( arg , AccumBounds ) : #NEWLINE# #INDENT# return sin ( ( arg + ( S . Pi / 2 ) ) ) #NEWLINE# #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 cosh ( i_coeff ) #NEWLINE# #UNINDENT# pi_coeff = _pi_coeff ( arg ) #NEWLINE# if ( nval is not None ) : #NEWLINE# #INDENT# if pi_coeff . is_integer : #NEWLINE# #INDENT# return ( S . NegativeOne ** pi_coeff ) #NEWLINE# #UNINDENT# if ( 2 * pi_coeff ) . is_integer : #NEWLINE# #INDENT# if pi_coeff . is_even : #NEWLINE# #INDENT# return ( S . NegativeOne ** ( pi_coeff / 2 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( pi_coeff . is_even is False ) : #NEWLINE# #INDENT# return S . Zero #NEWLINE# #UNINDENT# #UNINDENT# #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# cst_table_some = { #NEWLINE# #INDENT# 3 : S . Half , #NEWLINE# 5 : ( ( sqrt ( 5 ) + 1 ) / 4 ) , #NEWLINE# #UNINDENT# } #NEWLINE# if pi_coeff . is_Rational : #NEWLINE# #INDENT# q = pi_coeff . q #NEWLINE# p = ( pi_coeff . p % ( 2 * q ) ) #NEWLINE# if ( p > q ) : #NEWLINE# #INDENT# narg = ( ( pi_coeff - 1 ) * S . Pi ) #NEWLINE# return ( - cls ( narg ) ) #NEWLINE# #UNINDENT# if ( ( 2 * p ) > q ) : #NEWLINE# #INDENT# narg = ( ( 1 - pi_coeff ) * S . Pi ) #NEWLINE# return ( - cls ( narg ) ) #NEWLINE# #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# if ( q in table2 ) : #NEWLINE# #INDENT# ( a , b ) = ( ( ( p * S . Pi ) / table2 [ q ] [ 0 ] ) , ( ( p * S . Pi ) / table2 [ q ] [ 1 ] ) ) #NEWLINE# ( nvala , nvalb ) = ( cls ( a ) , cls ( b ) ) #NEWLINE# if ( ( None == nvala ) or ( None == nvalb ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return ( ( nvala * nvalb ) + ( cls ( ( ( S . Pi / 2 ) - a ) ) * cls ( ( ( S . Pi / 2 ) - b ) ) ) ) #NEWLINE# #UNINDENT# if ( q > 12 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( q in cst_table_some ) : #NEWLINE# #INDENT# cts = cst_table_some [ pi_coeff . q ] #NEWLINE# return chebyshevt ( pi_coeff . p , cts ) . expand ( ) #NEWLINE# #UNINDENT# if ( 0 == ( q % 2 ) ) : #NEWLINE# #INDENT# narg = ( ( pi_coeff * 2 ) * S . Pi ) #NEWLINE# nval = cls ( narg ) #NEWLINE# if ( None == nval ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# x = ( ( ( 2 * pi_coeff ) + 1 ) / 2 ) #NEWLINE# sign_cos = ( ( - 1 ) ** ( ( ( - 1 ) if ( x < 0 ) else 1 ) * int ( abs ( x ) ) ) ) #NEWLINE# return ( sign_cos * sqrt ( ( ( 1 + nval ) / 2 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return None #NEWLINE# #UNINDENT# if arg . is_Add : #NEWLINE# #INDENT# ( x , m ) = _peeloff_pi ( arg ) #NEWLINE# if m : #NEWLINE# #INDENT# return ( ( cos ( m ) * cos ( x ) ) - ( sin ( m ) * sin ( x ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( arg . func is acos ) : #NEWLINE# #INDENT# return arg . args [ 0 ] #NEWLINE# #UNINDENT# if ( arg . func is atan ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return ( 1 / sqrt ( ( 1 + ( x ** 2 ) ) ) ) #NEWLINE# #UNINDENT# if ( arg . func is atan2 ) : #NEWLINE# #INDENT# ( y , x ) = arg . args #NEWLINE# return ( x / sqrt ( ( ( x ** 2 ) + ( y ** 2 ) ) ) ) #NEWLINE# #UNINDENT# if ( arg . func is asin ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return sqrt ( ( 1 - ( x ** 2 ) ) ) #NEWLINE# #UNINDENT# if ( arg . func is acot ) : #NEWLINE# #INDENT# x = arg . args [ 0 ] #NEWLINE# return ( 1 / sqrt ( ( 1 + ( 1 / ( x ** 2 ) ) ) ) )