/

# Inequality Solvers¶

sympy.solvers.inequalities.solve_rational_inequalities(eqs)[source]

Solve a system of rational inequalities with rational coefficients.

Examples

>>> from sympy.abc import x
>>> from sympy import Poly
>>> from sympy.solvers.inequalities import solve_rational_inequalities

>>> solve_rational_inequalities([[
... ((Poly(-x + 1), Poly(1, x)), '>='),
... ((Poly(-x + 1), Poly(1, x)), '<=')]])
{1}

>>> solve_rational_inequalities([[
... ((Poly(x), Poly(1, x)), '!='),
... ((Poly(-x + 1), Poly(1, x)), '>=')]])
(-oo, 0) U (0, 1]

sympy.solvers.inequalities.solve_poly_inequality(poly, rel)[source]

Solve a polynomial inequality with rational coefficients.

solve_poly_inequalities

Examples

>>> from sympy import Poly
>>> from sympy.abc import x
>>> from sympy.solvers.inequalities import solve_poly_inequality

>>> solve_poly_inequality(Poly(x, x, domain='ZZ'), '==')
[{0}]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '!=')
[(-oo, -1), (-1, 1), (1, oo)]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '==')
[{-1}, {1}]

sympy.solvers.inequalities.reduce_rational_inequalities(exprs, gen, relational=True)[source]

Reduce a system of rational inequalities with rational coefficients.

Examples

>>> from sympy import Poly, Symbol
>>> from sympy.solvers.inequalities import reduce_rational_inequalities

>>> x = Symbol('x', real=True)

>>> reduce_rational_inequalities([[x**2 <= 0]], x)
x == 0

>>> reduce_rational_inequalities([[x + 2 > 0]], x)
And(-2 < x, x < oo)
>>> reduce_rational_inequalities([[(x + 2, ">")]], x)
And(-2 < x, x < oo)
>>> reduce_rational_inequalities([[x + 2]], x)
x == -2

sympy.solvers.inequalities.reduce_abs_inequality(expr, rel, gen)[source]

Reduce an inequality with nested absolute values.

Examples

>>> from sympy import Q, Abs, Symbol
>>> from sympy.solvers.inequalities import reduce_abs_inequality
>>> x = Symbol('x', real=True)

>>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x)
And(2 < x, x < 8)

>>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x)
And(-19/3 < x, x < 7/3)

sympy.solvers.inequalities.reduce_abs_inequalities(exprs, gen)[source]

Reduce a system of inequalities with nested absolute values.

Examples

>>> from sympy import Q, Abs, Symbol
>>> from sympy.abc import x
>>> from sympy.solvers.inequalities import reduce_abs_inequalities
>>> x = Symbol('x', real=True)

>>> reduce_abs_inequalities([(Abs(3*x - 5) - 7, '<'),
... (Abs(x + 25) - 13, '>')], x)
And(-2/3 < x, Or(And(-12 < x, x < oo), And(-oo < x, x < -38)), x < 4)

>>> reduce_abs_inequalities([(Abs(x - 4) + Abs(3*x - 5) - 7, '<')], x)
And(1/2 < x, x < 4)

sympy.solvers.inequalities.reduce_inequalities(inequalities, symbols=[])[source]

Reduce a system of inequalities with rational coefficients.

Examples

>>> from sympy import Q, sympify as S, Symbol
>>> from sympy.abc import x, y
>>> from sympy.solvers.inequalities import reduce_inequalities

>>> x = Symbol('x', real=True)
>>> reduce_inequalities(S(0) <= x + 3, [])
And(-3 <= x, x < oo)

>>> x = Symbol('x')
>>> reduce_inequalities(S(0) <= x + y*2 - 1, [x])
-2*y + 1 <= x

sympy.solvers.inequalities.solve_univariate_inequality(expr, gen, relational=True)[source]

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(And(-oo < x, x <= -2), And(2 <= x, x < oo))

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


Diophantine

Tensor Module