# Inequality Solvers¶

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

Solve a system of rational inequalities with rational coefficients.

Examples

>>> from diofant.abc import x
>>> from diofant import Poly
>>> from diofant.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]

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

Solve a polynomial inequality with rational coefficients.

Examples

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

>>> 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}]

diofant.solvers.inequalities.solve_poly_inequalities(polys)[source]

Solve polynomial inequalities with rational coefficients.

Examples

>>> from diofant.solvers.inequalities import solve_poly_inequalities
>>> from diofant.polys import Poly
>>> from diofant.abc import x
>>> solve_poly_inequalities(((Poly(x**2 - 3), ">"),
...                          (Poly(-x**2 + 1), ">")))
(-oo, -sqrt(3)) U (-1, 1) U (sqrt(3), oo)

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

Reduce a system of rational inequalities with rational coefficients.

Examples

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

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

>>> reduce_rational_inequalities([[x**2 <= 0]], x)
Eq(x, 0)
>>> reduce_rational_inequalities([[x + 2 > 0]], x)
-2 < x
>>> reduce_rational_inequalities([[(x + 2, ">")]], x)
-2 < x
>>> reduce_rational_inequalities([[x + 2]], x)
Eq(x, -2)

diofant.solvers.inequalities.reduce_piecewise_inequality(expr, rel, gen)[source]

Reduce an inequality with nested piecewise functions.

Examples

>>> from diofant import Abs, Symbol, Piecewise
>>> from diofant.solvers.inequalities import reduce_piecewise_inequality

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

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

>>> reduce_piecewise_inequality(Piecewise((1, x < 1),
...                                       (3, True)) - 1, '>', x)
1 <= x

diofant.solvers.inequalities.reduce_piecewise_inequalities(exprs, gen)[source]

Reduce a system of inequalities with nested piecewise functions.

Examples

>>> from diofant import Abs, Symbol
>>> from diofant.solvers.inequalities import reduce_piecewise_inequalities

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

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

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

Reduce a system of inequalities with rational coefficients.

Examples

>>> from diofant.solvers.inequalities import reduce_inequalities

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

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

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

Solves a real univariate inequality.

Examples

>>> from diofant.solvers.inequalities import solve_univariate_inequality
>>> from diofant.core.symbol import Symbol

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

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