<s> """<STR_LIT>""" <EOL> from sympy import ( And , Eq , FiniteSet , Ge , Gt , Interval , Le , Lt , Ne , oo , <EOL> Or , S , sin , sqrt , Symbol , Union , Integral , Sum , <EOL> Function , Poly , PurePoly , pi , root , log , exp ) <EOL> from sympy . solvers . inequalities import ( reduce_inequalities , <EOL> solve_poly_inequality as psolve , <EOL> reduce_rational_inequalities , <EOL> solve_univariate_inequality as isolve , <EOL> reduce_abs_inequality ) <EOL> from sympy . polys . rootoftools import rootof <EOL> from sympy . solvers . solvers import solve <EOL> from sympy . abc import x , y <EOL> from sympy . utilities . pytest import raises , slow <EOL> inf = oo . evalf ( ) <EOL> def test_solve_poly_inequality ( ) : <EOL> assert psolve ( Poly ( <NUM_LIT:0> , x ) , '<STR_LIT>' ) == [ S . Reals ] <EOL> assert psolve ( Poly ( <NUM_LIT:1> , x ) , '<STR_LIT>' ) == [ S . EmptySet ] <EOL> assert psolve ( PurePoly ( x + <NUM_LIT:1> , x ) , "<STR_LIT:>>" ) == [ Interval ( - <NUM_LIT:1> , oo , True , False ) ] <EOL> def test_reduce_poly_inequalities_real_interval ( ) : <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Eq ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == FiniteSet ( <NUM_LIT:0> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == FiniteSet ( <NUM_LIT:0> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == S . EmptySet <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ge ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == S . Reals if x . is_real else Interval ( - oo , oo ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Gt ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == FiniteSet ( <NUM_LIT:0> ) . complement ( S . Reals ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ne ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = False ) == FiniteSet ( <NUM_LIT:0> ) . complement ( S . Reals ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Eq ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == FiniteSet ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == Interval ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == Interval ( - <NUM_LIT:1> , <NUM_LIT:1> , True , True ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ge ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == Union ( Interval ( - oo , - <NUM_LIT:1> ) , Interval ( <NUM_LIT:1> , oo ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Gt ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == Interval ( - <NUM_LIT:1> , <NUM_LIT:1> ) . complement ( S . Reals ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ne ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ] , x , relational = False ) == FiniteSet ( - <NUM_LIT:1> , <NUM_LIT:1> ) . complement ( S . Reals ) <EOL> assert reduce_rational_inequalities ( [ [ Eq ( <EOL> x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == FiniteSet ( - <NUM_LIT:1.0> , <NUM_LIT:1.0> ) . evalf ( ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == Interval ( - <NUM_LIT:1.0> , <NUM_LIT:1.0> ) <EOL> assert reduce_rational_inequalities ( [ [ Lt ( <EOL> x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == Interval ( - <NUM_LIT:1.0> , <NUM_LIT:1.0> , True , True ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ge ( x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == Union ( Interval ( - inf , - <NUM_LIT:1.0> ) , Interval ( <NUM_LIT:1.0> , inf ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Gt ( x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == Union ( Interval ( - inf , - <NUM_LIT:1.0> , right_open = True ) , <EOL> Interval ( <NUM_LIT:1.0> , inf , left_open = True ) ) <EOL> assert reduce_rational_inequalities ( [ [ Ne ( <EOL> x ** <NUM_LIT:2> , <NUM_LIT:1.0> ) ] ] , x , relational = False ) == FiniteSet ( - <NUM_LIT:1.0> , <NUM_LIT:1.0> ) . complement ( S . Reals ) <EOL> s = sqrt ( <NUM_LIT:2> ) <EOL> assert reduce_rational_inequalities ( [ [ Lt ( <EOL> x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) , Gt ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False ) == S . EmptySet <EOL> assert reduce_rational_inequalities ( [ [ Le ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) , Ge ( <EOL> x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False ) == FiniteSet ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> - <NUM_LIT:2> , <NUM_LIT:0> ) , Ge ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False <EOL> ) == Union ( Interval ( - s , - <NUM_LIT:1> , False , False ) , Interval ( <NUM_LIT:1> , s , False , False ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> - <NUM_LIT:2> , <NUM_LIT:0> ) , Gt ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False <EOL> ) == Union ( Interval ( - s , - <NUM_LIT:1> , False , True ) , Interval ( <NUM_LIT:1> , s , True , False ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> - <NUM_LIT:2> , <NUM_LIT:0> ) , Ge ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False <EOL> ) == Union ( Interval ( - s , - <NUM_LIT:1> , True , False ) , Interval ( <NUM_LIT:1> , s , False , True ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> - <NUM_LIT:2> , <NUM_LIT:0> ) , Gt ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False <EOL> ) == Union ( Interval ( - s , - <NUM_LIT:1> , True , True ) , Interval ( <NUM_LIT:1> , s , True , True ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> - <NUM_LIT:2> , <NUM_LIT:0> ) , Ne ( x ** <NUM_LIT:2> - <NUM_LIT:1> , <NUM_LIT:0> ) ] ] , x , relational = False <EOL> ) == Union ( Interval ( - s , - <NUM_LIT:1> , True , True ) , Interval ( - <NUM_LIT:1> , <NUM_LIT:1> , True , True ) , <EOL> Interval ( <NUM_LIT:1> , s , True , True ) ) <EOL> def test_reduce_poly_inequalities_complex_relational ( ) : <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Eq ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == Eq ( x , <NUM_LIT:0> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == Eq ( x , <NUM_LIT:0> ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == False <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ge ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == And ( Lt ( - oo , x ) , Lt ( x , oo ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Gt ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == And ( Or ( And ( Lt ( - oo , x ) , Lt ( x , <NUM_LIT:0> ) ) , And ( Lt ( <NUM_LIT:0> , x ) , Lt ( x , oo ) ) ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ne ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) ] ] , x , relational = True ) == And ( Or ( And ( Lt ( - oo , x ) , Lt ( x , <NUM_LIT:0> ) ) , And ( Lt ( <NUM_LIT:0> , x ) , Lt ( x , oo ) ) ) ) <EOL> for one in ( S ( <NUM_LIT:1> ) , S ( <NUM_LIT:1.0> ) ) : <EOL> inf = one * oo <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Eq ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == Or ( Eq ( x , - one ) , Eq ( x , one ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Le ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == And ( And ( Le ( - one , x ) , Le ( x , one ) ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Lt ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == And ( And ( Lt ( - one , x ) , Lt ( x , one ) ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ge ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == And ( Or ( And ( Le ( one , x ) , Lt ( x , inf ) ) , And ( Le ( x , - one ) , Lt ( - inf , x ) ) ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Gt ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == And ( Or ( And ( Lt ( - inf , x ) , Lt ( x , - one ) ) , And ( Lt ( one , x ) , Lt ( x , inf ) ) ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ Ne ( x ** <NUM_LIT:2> , one ) ] ] , x , relational = True ) == Or ( And ( Lt ( - inf , x ) , Lt ( x , - one ) ) , <EOL> And ( Lt ( - one , x ) , Lt ( x , one ) ) , <EOL> And ( Lt ( one , x ) , Lt ( x , inf ) ) ) <EOL> def test_reduce_rational_inequalities_real_relational ( ) : <EOL> assert reduce_rational_inequalities ( [ ] , x ) == False <EOL> assert reduce_rational_inequalities ( <EOL> [ [ ( x ** <NUM_LIT:2> + <NUM_LIT:3> * x + <NUM_LIT:2> ) / ( x ** <NUM_LIT:2> - <NUM_LIT:16> ) >= <NUM_LIT:0> ] ] , x , relational = False ) == Union ( Interval . open ( - oo , - <NUM_LIT:4> ) , Interval ( - <NUM_LIT:2> , - <NUM_LIT:1> ) , Interval . open ( <NUM_LIT:4> , oo ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ ( ( - <NUM_LIT:2> * x - <NUM_LIT:10> ) * ( <NUM_LIT:3> - x ) ) / ( ( x ** <NUM_LIT:2> + <NUM_LIT:5> ) * ( x - <NUM_LIT:2> ) ** <NUM_LIT:2> ) < <NUM_LIT:0> ] ] , x , <EOL> relational = False ) == Union ( Interval . open ( - <NUM_LIT:5> , <NUM_LIT:2> ) , Interval . open ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> assert reduce_rational_inequalities ( [ [ ( x + <NUM_LIT:1> ) / ( x - <NUM_LIT:5> ) <= <NUM_LIT:0> ] ] , x , <EOL> relational = False ) == Interval . Ropen ( - <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> assert reduce_rational_inequalities ( [ [ ( x ** <NUM_LIT:2> + <NUM_LIT:4> * x + <NUM_LIT:3> ) / ( x - <NUM_LIT:1> ) > <NUM_LIT:0> ] ] , x , <EOL> relational = False ) == Union ( Interval . open ( - <NUM_LIT:3> , - <NUM_LIT:1> ) , Interval . open ( <NUM_LIT:1> , oo ) ) <EOL> assert reduce_rational_inequalities ( [ [ ( x ** <NUM_LIT:2> - <NUM_LIT:16> ) / ( x - <NUM_LIT:1> ) ** <NUM_LIT:2> < <NUM_LIT:0> ] ] , x , <EOL> relational = False ) == Union ( Interval . open ( - <NUM_LIT:4> , <NUM_LIT:1> ) , Interval . open ( <NUM_LIT:1> , <NUM_LIT:4> ) ) <EOL> assert reduce_rational_inequalities ( [ [ ( <NUM_LIT:3> * x + <NUM_LIT:1> ) / ( x + <NUM_LIT:4> ) >= <NUM_LIT:1> ] ] , x , <EOL> relational = False ) == Union ( Interval . open ( - oo , - <NUM_LIT:4> ) , Interval . Ropen ( S ( <NUM_LIT:3> ) / <NUM_LIT:2> , oo ) ) <EOL> assert reduce_rational_inequalities ( [ [ ( x - <NUM_LIT:8> ) / x <= <NUM_LIT:3> - x ] ] , x , <EOL> relational = False ) == Union ( Interval . Lopen ( - oo , - <NUM_LIT:2> ) , Interval . Lopen ( <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> assert reduce_rational_inequalities ( <EOL> [ [ x < oo , x >= <NUM_LIT:0> , - oo < x ] ] , x , relational = False ) == Interval ( <NUM_LIT:0> , oo ) <EOL> def test_reduce_abs_inequalities ( ) : <EOL> e = abs ( x - <NUM_LIT:5> ) < <NUM_LIT:3> <EOL> ans = And ( Lt ( <NUM_LIT:2> , x ) , Lt ( x , <NUM_LIT:8> ) ) <EOL> assert reduce_inequalities ( e ) == ans <EOL> assert reduce_inequalities ( e , x ) == ans <EOL> assert reduce_inequalities ( abs ( x - <NUM_LIT:5> ) ) == Eq ( x , <NUM_LIT:5> ) <EOL> assert reduce_inequalities ( <EOL> abs ( <NUM_LIT:2> * x + <NUM_LIT:3> ) >= <NUM_LIT:8> ) == Or ( And ( Le ( S ( <NUM_LIT:5> ) / <NUM_LIT:2> , x ) , Lt ( x , oo ) ) , <EOL> And ( Le ( x , - S ( <NUM_LIT:11> ) / <NUM_LIT:2> ) , Lt ( - oo , x ) ) ) <EOL> assert reduce_inequalities ( abs ( x - <NUM_LIT:4> ) + abs ( <EOL> <NUM_LIT:3> * x - <NUM_LIT:5> ) < <NUM_LIT:7> ) == And ( Lt ( S ( <NUM_LIT:1> ) / <NUM_LIT:2> , x ) , Lt ( x , <NUM_LIT:4> ) ) <EOL> assert reduce_inequalities ( abs ( x - <NUM_LIT:4> ) + abs ( <NUM_LIT:3> * abs ( x ) - <NUM_LIT:5> ) < <NUM_LIT:7> ) == Or ( And ( S ( - <NUM_LIT:2> ) < x , x < - <NUM_LIT:1> ) , And ( S ( <NUM_LIT:1> ) / <NUM_LIT:2> < x , x < <NUM_LIT:4> ) ) <EOL> nr = Symbol ( '<STR_LIT>' , real = False ) <EOL> raises ( TypeError , lambda : reduce_inequalities ( abs ( nr - <NUM_LIT:5> ) < <NUM_LIT:3> ) ) <EOL> assert reduce_inequalities ( x < <NUM_LIT:3> , symbols = [ x , nr ] ) == And ( - oo < x , x < <NUM_LIT:3> ) <EOL> def test_reduce_inequalities_general ( ) : <EOL> assert reduce_inequalities ( Ge ( sqrt ( <NUM_LIT:2> ) * x , <NUM_LIT:1> ) ) == And ( sqrt ( <NUM_LIT:2> ) / <NUM_LIT:2> <= x , x < oo ) <EOL> assert reduce_inequalities ( PurePoly ( x + <NUM_LIT:1> , x ) > <NUM_LIT:0> ) == And ( S ( - <NUM_LIT:1> ) < x , x < oo ) <EOL> def test_reduce_inequalities_boolean ( ) : <EOL> assert reduce_inequalities ( <EOL> [ Eq ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) , True ] ) == Eq ( x , <NUM_LIT:0> ) <EOL> assert reduce_inequalities ( [ Eq ( x ** <NUM_LIT:2> , <NUM_LIT:0> ) , False ] ) == False <EOL> assert reduce_inequalities ( x ** <NUM_LIT:2> >= <NUM_LIT:0> ) is S . true <EOL> def test_reduce_inequalities_multivariate ( ) : <EOL> assert reduce_inequalities ( [ Ge ( x ** <NUM_LIT:2> , <NUM_LIT:1> ) , Ge ( y ** <NUM_LIT:2> , <NUM_LIT:1> ) ] ) == And ( <EOL> Or ( And ( Le ( <NUM_LIT:1> , x ) , Lt ( x , oo ) ) , And ( Le ( x , - <NUM_LIT:1> ) , Lt ( - oo , x ) ) ) , <EOL> Or ( And ( Le ( <NUM_LIT:1> , y ) , Lt ( y , oo ) ) , And ( Le ( y , - <NUM_LIT:1> ) , Lt ( - oo , y ) ) ) ) <EOL> def test_reduce_inequalities_errors ( ) : <EOL> raises ( NotImplementedError , lambda : reduce_inequalities ( Ge ( sin ( x ) + x , <NUM_LIT:1> ) ) ) <EOL> raises ( NotImplementedError , lambda : reduce_inequalities ( Ge ( x ** <NUM_LIT:2> * y + y , <NUM_LIT:1> ) ) ) <EOL> def test_hacky_inequalities ( ) : <EOL> assert reduce_inequalities ( x + y < <NUM_LIT:1> , symbols = [ x ] ) == ( x < <NUM_LIT:1> - y ) <EOL> assert reduce_inequalities ( x + y >= <NUM_LIT:1> , symbols = [ x ] ) == ( x >= <NUM_LIT:1> - y ) <EOL> assert reduce_inequalities ( Eq ( <NUM_LIT:0> , x - y ) , symbols = [ x ] ) == Eq ( x , y ) <EOL> assert reduce_inequalities ( Ne ( <NUM_LIT:0> , x - y ) , symbols = [ x ] ) == Ne ( x , y ) <EOL> def test_issue_6343 ( ) : <EOL> eq = - <NUM_LIT:3> * x ** <NUM_LIT:2> / <NUM_LIT:2> - <NUM_LIT> * x / <NUM_LIT:4> + S ( <NUM_LIT> ) / <NUM_LIT:2> > <NUM_LIT:0> <EOL> assert reduce_inequalities ( eq ) == And ( x < - S ( <NUM_LIT:15> ) / <NUM_LIT:4> + sqrt ( <NUM_LIT> ) / <NUM_LIT:4> , - sqrt ( <NUM_LIT> ) / <NUM_LIT:4> - S ( <NUM_LIT:15> ) / <NUM_LIT:4> < x ) <EOL> def test_issue_8235 ( ) : <EOL> assert reduce_inequalities ( x ** <NUM_LIT:2> - <NUM_LIT:1> < <NUM_LIT:0> ) == And ( S ( - <NUM_LIT:1> ) < x , x < S ( <NUM_LIT:1> ) ) <EOL> assert reduce_inequalities ( x ** <NUM_LIT:2> - <NUM_LIT:1> <= <NUM_LIT:0> ) == And ( S ( - <NUM_LIT:1> ) <= x , x <= <NUM_LIT:1> ) <EOL> assert reduce_inequalities ( x ** <NUM_LIT:2> - <NUM_LIT:1> > <NUM_LIT:0> ) == Or ( And ( - oo < x , x < - <NUM_LIT:1> ) , And ( x < oo , S ( <NUM_LIT:1> ) < x ) ) <EOL> assert reduce_inequalities ( x ** <NUM_LIT:2> - <NUM_LIT:1> >= <NUM_LIT:0> ) == Or ( And ( - oo < x , x <= S ( - <NUM_LIT:1> ) ) , And ( S ( <NUM_LIT:1> ) <= x , x < oo ) ) <EOL> eq = x ** <NUM_LIT:8> + x - <NUM_LIT:9> <EOL> sol = solve ( eq >= <NUM_LIT:0> ) <EOL> tru = Or ( And ( rootof ( eq , <NUM_LIT:1> ) <= x , x < oo ) , And ( - oo < x , x <= rootof ( eq , <NUM_LIT:0> ) ) ) <EOL> assert sol == tru <EOL> assert solve ( sqrt ( ( - x + <NUM_LIT:1> ) ** <NUM_LIT:2> ) < <NUM_LIT:1> ) == And ( S ( <NUM_LIT:0> ) < x , x < <NUM_LIT:2> ) <EOL> def test_issue_5526 ( ) : <EOL> assert reduce_inequalities ( S ( <NUM_LIT:0> ) <= <EOL> x + Integral ( y ** <NUM_LIT:2> , ( y , <NUM_LIT:1> , <NUM_LIT:3> ) ) - <NUM_LIT:1> , [ x ] ) == ( x >= - Integral ( y ** <NUM_LIT:2> , ( y , <NUM_LIT:1> , <NUM_LIT:3> ) ) + <NUM_LIT:1> ) <EOL> f = Function ( '<STR_LIT:f>' ) <EOL> e = Sum ( f ( x ) , ( x , <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> assert reduce_inequalities ( S ( <NUM_LIT:0> ) <= x + e + y ** <NUM_LIT:2> , [ x ] ) == ( x >= - y ** <NUM_LIT:2> - Sum ( f ( x ) , ( x , <NUM_LIT:1> , <NUM_LIT:3> ) ) ) <EOL> def test_solve_univariate_inequality ( ) : <EOL> assert isolve ( x ** <NUM_LIT:2> >= <NUM_LIT:4> , x , relational = False ) == Union ( Interval ( - oo , - <NUM_LIT:2> ) , <EOL> Interval ( <NUM_LIT:2> , oo ) ) <EOL> assert isolve ( x ** <NUM_LIT:2> >= <NUM_LIT:4> , x ) == Or ( And ( Le ( <NUM_LIT:2> , x ) , Lt ( x , oo ) ) , And ( Le ( x , - <NUM_LIT:2> ) , <EOL> Lt ( - oo , x ) ) ) <EOL> assert isolve ( ( x - <NUM_LIT:1> ) * ( x - <NUM_LIT:2> ) * ( x - <NUM_LIT:3> ) >= <NUM_LIT:0> , x , relational = False ) == Union ( Interval ( <NUM_LIT:1> , <NUM_LIT:2> ) , Interval ( <NUM_LIT:3> , oo ) ) <EOL> assert isolve ( ( x - <NUM_LIT:1> ) * ( x - <NUM_LIT:2> ) * ( x - <NUM_LIT:3> ) >= <NUM_LIT:0> , x ) == Or ( And ( Le ( <NUM_LIT:1> , x ) , Le ( x , <NUM_LIT:2> ) ) , And ( Le ( <NUM_LIT:3> , x ) , Lt ( x , oo ) ) ) <EOL> assert isolve ( x ** <NUM_LIT:3> - <NUM_LIT:2> * x - <NUM_LIT:1> > <NUM_LIT:0> , x , relational = False ) == Union ( Interval ( - <NUM_LIT:1> , - sqrt ( <NUM_LIT:5> ) / <NUM_LIT:2> + S ( <NUM_LIT:1> ) / <NUM_LIT:2> , True , True ) , <EOL> Interval ( S ( <NUM_LIT:1> ) / <NUM_LIT:2> + sqrt ( <NUM_LIT:5> ) / <NUM_LIT:2> , oo , True , True ) ) <EOL> assert isolve ( x ** <NUM_LIT:3> - x ** <NUM_LIT:2> + x - <NUM_LIT:1> > <NUM_LIT:0> , x , relational = False ) == Interval ( <NUM_LIT:1> , oo , True ) <EOL> assert isolve ( sin ( x ) < S . Half , x ) == Or ( And ( - oo < x , x < pi / <NUM_LIT:6> ) , And ( <NUM_LIT:5> * pi / <NUM_LIT:6> < x , x < oo ) ) <EOL> assert isolve ( sin ( x ) > S . Half , x ) == And ( pi / <NUM_LIT:6> < x , x < <NUM_LIT:5> * pi / <NUM_LIT:6> ) <EOL> assert isolve ( x ** <NUM_LIT:7> - x - <NUM_LIT:2> > <NUM_LIT:0> , x ) == And ( rootof ( x ** <NUM_LIT:7> - x - <NUM_LIT:2> , <NUM_LIT:0> ) < x , x < oo ) <EOL> assert isolve ( <NUM_LIT:1> / ( x - <NUM_LIT:2> ) > <NUM_LIT:0> , x ) == And ( S ( <NUM_LIT:2> ) < x , x < oo ) <EOL> den = ( ( x - <NUM_LIT:1> ) * ( x - <NUM_LIT:2> ) ) . expand ( ) <EOL> assert isolve ( ( x - <NUM_LIT:1> ) / den <= <NUM_LIT:0> , x ) == Or ( And ( - oo < x , x < <NUM_LIT:1> ) , And ( S ( <NUM_LIT:1> ) < x , x < <NUM_LIT:2> ) ) <EOL> def test_issue_9954 ( ) : <EOL> assert isolve ( x ** <NUM_LIT:2> >= <NUM_LIT:0> , x , relational = False ) == S . Reals <EOL> assert isolve ( x ** <NUM_LIT:2> >= <NUM_LIT:0> , x , relational = True ) == S . Reals . as_relational ( x ) <EOL> assert isolve ( x ** <NUM_LIT:2> < <NUM_LIT:0> , x , relational = False ) == S . EmptySet <EOL> assert isolve ( x ** <NUM_LIT:2> < <NUM_LIT:0> , x , relational = True ) == S . EmptySet . as_relational ( x ) <EOL> def test_slow_general_univariate ( ) : <EOL> r = rootof ( x ** <NUM_LIT:5> - x ** <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> assert solve ( sqrt ( x ) + <NUM_LIT:1> / root ( x , <NUM_LIT:3> ) > <NUM_LIT:1> ) == Or ( And ( S ( <NUM_LIT:0> ) < x , x < r ** <NUM_LIT:6> ) , And ( r ** <NUM_LIT:6> < x , x < oo ) ) <EOL> def test_issue_8545 ( ) : <EOL> eq = <NUM_LIT:1> - x - abs ( <NUM_LIT:1> - x ) <EOL> ans = And ( Lt ( <NUM_LIT:1> , x ) , Lt ( x , oo ) ) <EOL> assert reduce_abs_inequality ( eq , '<STR_LIT:<>' , x ) == ans <EOL> eq = <NUM_LIT:1> - x - sqrt ( ( <NUM_LIT:1> - x ) ** <NUM_LIT:2> ) <EOL> assert reduce_inequalities ( eq < <NUM_LIT:0> ) == ans <EOL> def test_issue_8974 ( ) : <EOL> assert isolve ( - oo < x , x ) == And ( - oo < x , x < oo ) <EOL> assert isolve ( oo > x , x ) == And ( - oo < x , x < oo ) <EOL> def test_issue_10198 ( ) : <EOL> assert reduce_inequalities ( <EOL> - <NUM_LIT:1> + <NUM_LIT:1> / abs ( <NUM_LIT:1> / x - <NUM_LIT:1> ) < <NUM_LIT:0> ) == Or ( <EOL> And ( - oo < x , x < <NUM_LIT:0> ) , And ( S ( <NUM_LIT:0> ) < x , x < S ( <NUM_LIT:1> ) / <NUM_LIT:2> ) <EOL> ) <EOL> assert reduce_inequalities ( abs ( <NUM_LIT:1> / sqrt ( x ) ) - <NUM_LIT:1> , x ) == Eq ( x , - <NUM_LIT:1> ) <EOL> assert reduce_abs_inequality ( - <NUM_LIT:3> + <NUM_LIT:1> / abs ( <NUM_LIT:1> - <NUM_LIT:1> / x ) , '<STR_LIT:<>' , x ) == Or ( And ( - oo < x , x < <NUM_LIT:0> ) , <EOL> And ( S ( <NUM_LIT:0> ) < x , x < S ( <NUM_LIT:3> ) / <NUM_LIT:4> ) , And ( S ( <NUM_LIT:3> ) / <NUM_LIT:2> < x , x < oo ) ) <EOL> raises ( ValueError , lambda : reduce_abs_inequality ( - <NUM_LIT:3> + <NUM_LIT:1> / abs ( <EOL> <NUM_LIT:1> - <NUM_LIT:1> / sqrt ( x ) ) , '<STR_LIT:<>' , x ) ) <EOL> def test_issue_10047 ( ) : <EOL> assert solve ( sin ( x ) < <NUM_LIT:2> ) == And ( - oo < x , x < oo ) <EOL> def test_issue_10268 ( ) : <EOL> assert solve ( log ( x ) < <NUM_LIT:1000> ) == And ( - oo < x , x < exp ( <NUM_LIT:1000> ) ) </s>
