Changing Inequality solver output API to set Interval (as_set())

127 views
Skip to first unread message

AMiT Kumar

unread,
Jan 9, 2015, 1:43:35 PM1/9/15
to sy...@googlegroups.com
Hi,

I am AMiT Kumar, a 3rd year Undergrad Pursuing Mathematics and Computing Engineering, at Delhi Technological University, India. 

I was going through the inequalities solvers, while working on this issue: https://github.com/sympy/sympy/issues/8715 , I saw that inequality solvers returns sympy Boolean objects such as And/Or. I think this limits the extending capabilities of inequalities solver, since we can't manipulate these objects, for e.g. say removing an element from the returned solution, as in the issue #8715 we saw that solve(x + 1/x > -2 + 1/x) returns a solution which makes denominator zero.

I was trying to implement a check for singularities (as suggested by @smichr) : which will find singularities and remove those from the solution. This can easily be done if I convert the Boolean object into a set Interval by using  .as_set()  (which I have fixed for infinite intervals: https://github.com/sympy/sympy/pull/8784), but at the time I don't see a method to convert the set interval object into Boolean object such as And/Or to return the solution in the form of current output API.

So, I think converting the output API to return a set interval (for univariate) solves the problem.
Also (1, 2) is more readable than And(1 < x, x < 2).

Please, do tell me if I am going the wrong way, would love to hear from you.

Cheers!
Amit Kumar

AMiT Kumar

unread,
Jan 10, 2015, 7:01:59 AM1/10/15
to sy...@googlegroups.com
Yes, we can convert set Interval to Boolean object,using as_relational().
In [4]: Interval(0,1).as_relational(x)
Out[4]: 0 ≤ x ∧ x ≤ 1
Thanks Sergey, for clearing the doubt.

Cheers!
Amit Kumar. 

Aaron Meurer

unread,
Jan 29, 2015, 4:22:58 PM1/29/15
to sy...@googlegroups.com
I think the new solveset will always return a set object. I don't know if it supports inequalities yet, but we should focus on improving it, so that it can eventually replace solve().

Aaron Meurer

--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
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/4780296c-a5ed-48cf-9305-395eb7feaf5b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

AMiT Kumar

unread,
Jan 30, 2015, 9:25:38 AM1/30/15
to sy...@googlegroups.com
Yes, the new solveset always returns set  & it does support inequalities, and I have gone through the work of Harsh, I came to know there is still lot of work to do in solveset as mentioned by Harsh and on ideas page, I am working on it, I will soon come up with a new thread on what I plan to implement this summer to extend the capabilities of solveset.

Amit Kumar
3rd Year UnderGrad
Delhi Technological University

AMiT Kumar

unread,
Jan 30, 2015, 1:10:48 PM1/30/15
to sy...@googlegroups.com
Forgot to mention:
Currently solve and solveset, both are dependent on the submodule inequalities.py (in solvers) for solving inequalities, which eventually also uses solve(). 

Aaron Meurer

unread,
Jan 30, 2015, 3:03:37 PM1/30/15
to sy...@googlegroups.com
That's probably a good thing. All algorithms should be eventually consolidated.

Aaron Meurer

Harsh Gupta

unread,
Jan 31, 2015, 2:40:28 AM1/31/15
to sy...@googlegroups.com
Currently solve and solveset, both are dependent on the submodule inequalities.py (in solvers) for solving inequalities, which eventually also uses solve()

You should replace the `solve()` in inequality.py with solveset_reals (solver for real equations). See https://github.com/sympy/sympy/issues/8711

AMiT Kumar

unread,
Jan 31, 2015, 11:53:54 PM1/31/15
to sy...@googlegroups.com
Thanks Harsh, I do have that PR in my TODO List. We need to consider output API (return type) also while replacing `solve` with `solveset` functions. I am working on that.

AMiT Kumar
Reply all
Reply to author
Forward
0 new messages