(expr, rel, gen, assume=True)
return reduce_rational_inequalities(inequalities, gen, assume)
Reduce an inequality with nested absolute values.

    Examples
    ========

    >>> from sympy import Q, Abs
    >>> from sympy.abc import x
    >>> from sympy.solvers.inequalities import reduce_abs_inequality

    >>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x, assume=Q.real(x))
    And(2 < x, x < 8)

    >>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x, assume=Q.real(x))
    And(-19/3 < x, x < 7/3)

    See Also
    ========
    reduce_abs_inequalities
Reduce an inequality with nested absolute values.
Reduce an inequality with nested absolute values .
def reduce_abs_inequality(expr, rel, gen, assume=True):
    """Reduce an inequality with nested absolute values.

    Examples
    ========

    >>> from sympy import Q, Abs
    >>> from sympy.abc import x
    >>> from sympy.solvers.inequalities import reduce_abs_inequality

    >>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x, assume=Q.real(x))
    And(2 < x, x < 8)

    >>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x, assume=Q.real(x))
    And(-19/3 < x, x < 7/3)

    See Also
    ========
    reduce_abs_inequalities
    """
    if not ask(Q.real(gen), assumptions=assume):
        raise NotImplementedError("can't solve inequalities with absolute "
            "values of a complex variable")

    def _bottom_up_scan(expr):
        exprs = []

        if expr.is_Add or expr.is_Mul:
            op = expr.__class__

            for arg in expr.args:
                _exprs = _bottom_up_scan(arg)

                if not exprs:
                    exprs = _exprs
                else:
                    args = []

                    for expr, conds in exprs:
                        for _expr, _conds in _exprs:
                            args.append((op(expr, _expr), conds + _conds))

                    exprs = args
        elif expr.is_Pow:
            n = expr.exp

            if not n.is_Integer or n < 0:
                raise ValueError(
                    "only non-negative integer powers are allowed")

            _exprs = _bottom_up_scan(expr.base)

            for expr, conds in _exprs:
                exprs.append((expr**n, conds))
        elif isinstance(expr, Abs):
            _exprs = _bottom_up_scan(expr.args[0])

            for expr, conds in _exprs:
                exprs.append(( expr, conds + [Ge(expr, 0)]))
                exprs.append((-expr, conds + [Lt(expr, 0)]))
        else:
            exprs = [(expr, [])]

        return exprs

    exprs = _bottom_up_scan(expr)

    mapping = {'<': '>', '<=': '>='}
    inequalities = []

    for expr, conds in exprs:
        if rel not in mapping.keys():
            expr = Relational( expr, 0, rel)
        else:
            expr = Relational(-expr, 0, mapping[rel])

        inequalities.append([expr] + conds)

    return reduce_rational_inequalities(inequalities, gen, assume)
def reduce_abs_inequality ( expr , rel , gen , assume = True ) : if not ask ( Q . real ( gen ) , assumptions = assume ) : raise NotImplementedError ( "can't solve inequalities with absolute " "values of a complex variable" ) def _bottom_up_scan ( expr ) : exprs = [ ] if expr . is_Add or expr . is_Mul : op = expr . __class__ for arg in expr . args : _exprs = _bottom_up_scan ( arg ) if not exprs : exprs = _exprs else : args = [ ] for expr , conds in exprs : for _expr , _conds in _exprs : args . append ( ( op ( expr , _expr ) , conds + _conds ) ) exprs = args elif expr . is_Pow : n = expr . exp if not n . is_Integer or n < 0 : raise ValueError ( "only non-negative integer powers are allowed" ) _exprs = _bottom_up_scan ( expr . base ) for expr , conds in _exprs : exprs . append ( ( expr ** n , conds ) ) elif isinstance ( expr , Abs ) : _exprs = _bottom_up_scan ( expr . args [ 0 ] ) for expr , conds in _exprs : exprs . append ( ( expr , conds + [ Ge ( expr , 0 ) ] ) ) exprs . append ( ( - expr , conds + [ Lt ( expr , 0 ) ] ) ) else : exprs = [ ( expr , [ ] ) ] return exprs exprs = _bottom_up_scan ( expr ) mapping = { '<' : '>' , '<=' : '>=' } inequalities = [ ] for expr , conds in exprs : if rel not in mapping . keys ( ) : expr = Relational ( expr , 0 , rel ) else : expr = Relational ( - expr , 0 , mapping [ rel ] ) inequalities . append ( [ expr ] + conds ) return reduce_rational_inequalities ( inequalities , gen , assume )