<s> from sympy . core . sympify import sympify <EOL> from sympy . solvers . solveset import solveset <EOL> from sympy . simplify import simplify <EOL> from sympy import S <EOL> def singularities ( expr , sym ) : <EOL> """<STR_LIT>""" <EOL> if not expr . is_rational_function ( sym ) : <EOL> raise NotImplementedError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> return solveset ( simplify ( <NUM_LIT:1> / expr ) , sym ) <EOL> def is_increasing ( f , interval = S . Reals , symbol = None ) : <EOL> """<STR_LIT>""" <EOL> f = sympify ( f ) <EOL> free_sym = f . free_symbols <EOL> if symbol is None : <EOL> if len ( free_sym ) > <NUM_LIT:1> : <EOL> raise NotImplementedError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if len ( free_sym ) == <NUM_LIT:0> : <EOL> return True <EOL> symbol = free_sym . pop ( ) <EOL> df = f . diff ( symbol ) <EOL> df_nonneg_interval = solveset ( df >= <NUM_LIT:0> , symbol , domain = S . Reals ) <EOL> return interval . is_subset ( df_nonneg_interval ) <EOL> def is_strictly_increasing ( f , interval = S . Reals , symbol = None ) : <EOL> """<STR_LIT>""" <EOL> f = sympify ( f ) <EOL> free_sym = f . free_symbols <EOL> if symbol is None : <EOL> if len ( free_sym ) > <NUM_LIT:1> : <EOL> raise NotImplementedError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> elif len ( free_sym ) == <NUM_LIT:0> : <EOL> return False <EOL> symbol = free_sym . pop ( ) <EOL> df = f . diff ( symbol ) <EOL> df_pos_interval = solveset ( df > <NUM_LIT:0> , symbol , domain = S . Reals ) <EOL> return interval . is_subset ( df_pos_interval ) <EOL> def is_decreasing ( f , interval = S . Reals , symbol = None ) : <EOL> """<STR_LIT>""" <EOL> f = sympify ( f ) <EOL> free_sym = f . free_symbols <EOL> if symbol is None : <EOL> if len ( free_sym ) > <NUM_LIT:1> : <EOL> raise NotImplementedError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> elif len ( free_sym ) == <NUM_LIT:0> : <EOL> return True <EOL> symbol = free_sym . pop ( ) <EOL> df = f . diff ( symbol ) <EOL> df_nonpos_interval = solveset ( df <= <NUM_LIT:0> , symbol , domain = S . Reals ) <EOL> return interval . is_subset ( df_nonpos_interval ) <EOL> def is_strictly_decreasing ( f , interval = S . Reals , symbol = None ) : <EOL> """<STR_LIT>""" <EOL> f = sympify ( f ) <EOL> free_sym = f . free_symbols <EOL> if symbol is None : <EOL> if len ( free_sym ) > <NUM_LIT:1> : <EOL> raise NotImplementedError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> elif len ( free_sym ) == <NUM_LIT:0> : <EOL> return False <EOL> symbol = free_sym . pop ( ) <EOL> df = f . diff ( symbol ) <EOL> df_neg_interval = solveset ( df < <NUM_LIT:0> , symbol , domain = S . Reals ) <EOL> return interval . is_subset ( df_neg_interval ) <EOL> def is_monotonic ( f , interval = S . Reals , symbol = None ) : <EOL> """<STR_LIT>""" <EOL> from sympy . core . logic import fuzzy_or <EOL> f = sympify ( f ) <EOL> free_sym = f . free_symbols <EOL> if symbol is None and len ( free_sym ) > <NUM_LIT:1> : <EOL> raise NotImplementedError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> inc = is_increasing ( f , interval , symbol ) <EOL> dec = is_decreasing ( f , interval , symbol ) <EOL> return fuzzy_or ( [ inc , dec ] ) </s>
