Extract value from AND object specified by reduce_rational_inequality parameters ([[- 3 <2 * x + 1]], x). example.And (-2 <x, x <oo)
I want to extract a value from the result that I get with reduce_rational_inequalities([[-3 < 2*x + 1]], x)
. For example my answer after running the specified function
AND (-2 <x, x <oo)
... Now I want
-2
from this exit. I also do the operation with a different equation. reduce_rational_inequalities([[2*x + 1 < 5]], x)
... And the answer I get is
And (-oo <x, x <2)
... Now I want
2
out of this exit. and want to combine these two outputs.
If anyone has gone through this simplex library with a specific operation. Please let me know.
Thanks for any help in advance.
source share
Someone can give a better answer. But this approach really works.
>>> reduce_rational_inequalities([[-3 < 2*x + 1]], x) And(-2 < x, x < oo) >>> result = reduce_rational_inequalities([[-3 < 2*x + 1]], x) >>> result.args (-2 < x, x < oo) >>> result.args[0] -2 < x >>> result.args[1] x < oo >>> result.args[0].args[0] -2 >>> result.args[0].args[0].is_number True
Even when the result can be expressed as a tuple of one-sided intervals, as is the case here, the included constants can still appear on either side of the inequality. However, you can use the method is_number
to determine which side contains the number.
Let him hope someone has a better way.
source share