Inequality Solvers¶
-
sympy.solvers.inequalities.
solve_rational_inequalities
(eqs)[source]¶ Solve a system of rational inequalities with rational coefficients.
See also
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)), '>=')]]) Union(Interval.open(-oo, 0), Interval.Lopen(0, 1))
-
sympy.solvers.inequalities.
solve_poly_inequality
(poly, rel)[source]¶ Solve a polynomial inequality with rational coefficients.
See also
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'), '!=') [Interval.open(-oo, -1), Interval.open(-1, 1), Interval.open(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) Eq(x, 0)
>>> reduce_rational_inequalities([[x + 2 > 0]], x) (-2 < x) & (x < oo) >>> reduce_rational_inequalities([[(x + 2, ">")]], x) (-2 < x) & (x < oo) >>> reduce_rational_inequalities([[x + 2]], x) Eq(x, -2)
-
sympy.solvers.inequalities.
reduce_abs_inequality
(expr, rel, gen)[source]¶ Reduce an inequality with nested absolute values.
See also
Examples
>>> from sympy import Abs, Symbol >>> from sympy.solvers.inequalities import reduce_abs_inequality >>> x = Symbol('x', real=True)
>>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x) (2 < x) & (x < 8)
>>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x) (-19/3 < x) & (x < 7/3)
-
sympy.solvers.inequalities.
reduce_abs_inequalities
(exprs, gen)[source]¶ Reduce a system of inequalities with nested absolute values.
See also
Examples
>>> from sympy import 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) (-2/3 < x) & (x < 4) & (((-oo < x) & (x < -38)) | ((-12 < x) & (x < oo)))
>>> reduce_abs_inequalities([(Abs(x - 4) + Abs(3*x - 5) - 7, '<')], x) (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 sympify as S, Symbol >>> from sympy.abc import x, y >>> from sympy.solvers.inequalities import reduce_inequalities
>>> reduce_inequalities(0 <= x + 3, []) (-3 <= x) & (x < oo)
>>> reduce_inequalities(0 <= x + y*2 - 1, [x]) (x < oo) & (x >= -2*y + 1)
-
sympy.solvers.inequalities.
solve_univariate_inequality
(expr, gen, relational=True, domain=Reals, continuous=False)[source]¶ Solves a real univariate inequality.
- Parameters
expr : Relational
The target inequality
gen : Symbol
The variable for which the inequality is solved
relational : bool
A Relational type output is expected or not
domain : Set
The domain over which the equation is solved
continuous: bool
True if expr is known to be continuous over the given domain (and so continuous_domain() doesn’t need to be called on it)
- Raises
NotImplementedError
The solution of the inequality cannot be determined due to limitation in \(solvify\).
See also
solvify
solver returning solveset solutions with solve’s output API
Notes
Currently, we cannot solve all the inequalities due to limitations in \(solvify\). Also, the solution returned for trigonometric inequalities are restricted in its periodic interval.
Examples
>>> from sympy.solvers.inequalities import solve_univariate_inequality >>> from sympy import Symbol, sin, Interval, S >>> x = Symbol('x')
>>> solve_univariate_inequality(x**2 >= 4, x) ((2 <= x) & (x < oo)) | ((x <= -2) & (-oo < x))
>>> solve_univariate_inequality(x**2 >= 4, x, relational=False) Union(Interval(-oo, -2), Interval(2, oo))
>>> domain = Interval(0, S.Infinity) >>> solve_univariate_inequality(x**2 >= 4, x, False, domain) Interval(2, oo)
>>> solve_univariate_inequality(sin(x) > 0, x, relational=False) Interval.open(0, pi)