Hi Aaron,
On Mon, May 11, 2015 at 3:21 AM, Aaron Meurer <[email protected]> wrote:
> Why wouldn't the input just be the inequality object itself?
That would be a better way, thanks. Here is what I got now:
from sympy import Symbol, solve_poly_inequality,
solve_rational_inequalities, solve_univariate_inequality
def isolve(ineq_obj):
x = Symbol('x')
expr = ineq_obj.lhs
rel = ineq_obj.rel_op
if expr.is_polynomial():
# create a Poly() object
p = Poly(expr, x)
return solve_poly_inequality(p, rel)
elif expr.is_rational_function():
p1, p2 = expr.as_numer_denom()
num = Poly(p1)
denom = Poly(p2)
return solve_rational_inequalities([[
((num, denom), rel)
]])
else:
# solve_univariate_uninequality() function expects
# the expressesion in the form "expr" "rel" 0
return solve_univariate_inequality(ineq_obj , x, relational=False)
# polynomial
print(isolve(x+2<0))
# rational function
print(isolve((x-1)/(x+2)>0))
# non-polynomial, non-rational
print(isolve(sin(x)-1 < 0))
What do you think of it now?
One limitation is that I am assuming the variable is "x".
-Amit.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CANODV3m7nmqu8JrnWJ0ijxe%3DOt7Or9%3DFphpvELiddWCnjh0JhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.