(expr, gen, assume=True, relational=True)
return rv if not relational else rv.as_relational(gen)
Solves a real univariate inequality.

    Examples
    ========

    >>> from sympy.solvers.inequalities import solve_univariate_inequality
    >>> from sympy.core.symbol import Symbol
    >>> x = Symbol('x', real=True)

    >>> solve_univariate_inequality(x**2 >= 4, x)
    Or(x <= -2, x >= 2)
    >>> solve_univariate_inequality(x**2 >= 4, x, relational=False)
    (-oo, -2] U [2, oo)
Solves a real univariate inequality.
Solves a real univariate inequality .
def solve_univariate_inequality(expr, gen, assume=True, relational=True):
    """Solves a real univariate inequality.

    Examples
    ========

    >>> from sympy.solvers.inequalities import solve_univariate_inequality
    >>> from sympy.core.symbol import Symbol
    >>> x = Symbol('x', real=True)

    >>> solve_univariate_inequality(x**2 >= 4, x)
    Or(x <= -2, x >= 2)
    >>> solve_univariate_inequality(x**2 >= 4, x, relational=False)
    (-oo, -2] U [2, oo)

    """

    # Implementation for continous functions

    from sympy.solvers.solvers import solve

    solns = solve(expr.lhs - expr.rhs, gen, assume=assume)
    oo = S.Infinity

    start = -oo

    sol_sets = [S.EmptySet]

    for x in sorted(s for s in solns if s.is_real):
        end = x
        if expr.subs(gen, (start + end)/2 if start != -oo else end - 1):
            sol_sets.append(Interval(start, end, True, True))

        if expr.subs(gen, x):
            sol_sets.append(FiniteSet(x))

        start = end

    end = oo

    if expr.subs(gen, start + 1):
        sol_sets.append(Interval(start, end, True, True))

    rv = Union(*sol_sets)
    return rv if not relational else rv.as_relational(gen)
def solve_univariate_inequality ( expr , gen , assume = True , relational = True ) : # Implementation for continous functions from sympy . solvers . solvers import solve solns = solve ( expr . lhs - expr . rhs , gen , assume = assume ) oo = S . Infinity start = - oo sol_sets = [ S . EmptySet ] for x in sorted ( s for s in solns if s . is_real ) : end = x if expr . subs ( gen , ( start + end ) / 2 if start != - oo else end - 1 ) : sol_sets . append ( Interval ( start , end , True , True ) ) if expr . subs ( gen , x ) : sol_sets . append ( FiniteSet ( x ) ) start = end end = oo if expr . subs ( gen , start + 1 ) : sol_sets . append ( Interval ( start , end , True , True ) ) rv = Union ( * sol_sets ) return rv if not relational else rv . as_relational ( gen )