solve_univariate_inequality()を使うのが良さそう。
環境
- SymPy 1.11
例
import sympy as sp x = sp.Symbol('x', nonnegative=True) expr = x ** 2 + 4 * x + 4 threshold = 9 sp.solve_univariate_inequality(expr >= threshold, x, relational=False, continuous=True) > (−∞,−5]∪[1,∞)
domainを使うことで、正数範囲のみを指定できたりする。
import sympy as sp x = sp.Symbol('x', nonnegative=True) expr = x ** 2 + 4 * x + 4 threshold = 9 domain = sp.Interval(0, sp.S.Infinity) sp.solve_univariate_inequality(expr >= threshold, x, relational=False, continuous=True, domain=domain) > [1,∞)