Hello,
I am Kshitij Saraogi and I will be a GSoC applicant this year under SymPy.
I wanted to discuss about the Solvers project.[1]
After going through the discussions mentioned on the Ideas page, I would like to get inputs on a few ideas for this project:
1. Search based Solvers [2]:
I find this idea quite intriguing. I understand only an abstract view of the idea was presented there.
I think we should try to implement this as it would make the API cleaner and robust.
Since, not much has been written about this, I would like to know more about it.
- What is the methodology we are thinking to use for ranking solutions (if any)?
- What would be the parameters on which the cost function of different sets depend ?
So, I would appreciate guidance in this direction.
2. Simplifying solutions returned from equations involving trigonometric expressions:
The solveset module needs improvement with regards to the trignometric equation solver.
An equation,as simple as, sin(x)=0 gives an output which should be simplified.
This should be a big concern.
What would be some good starting points to get an overview of the issue and possibly a few ideas to resolve this ?
3. Implementing more equation solvers: [3]
System of multivariate linear equations.
Nonlinear multivariate equation solver.
Equations solvable by LamberW function (Transcendental equation solver)
Nested trignometric expressions.
As Amit pointed out here[4], that we need (ii) and (iii) to make solveset at par with solve.
I found this paper [5] which talks about implementing a parallel Gauss method for solving this issue. Is it relevant ?
While fixing an issue [6], I came to know that we need a more reliable multivariate nonlinear equation solver.
I would like to know more about these solvers with respect to their immediate need and the possible methods of their implementation.
4. Solving f(x + a) - f(x) = 0 equations: [7]
While going through some issues, I found that the current solvers can’t handle these type of equations.
5. Building the set infrastructure:
Implementing functions to handle multidimensional ImageSet
Can we be more elaborate on what other features are we expecting ?
I would really appreciate if someone can point out the issues I may have missed.
Also, any relevant resources or links for further readings would help too.
Thanks,
Kshitij Saraogi
In [10]: solveset(sin(x), x)Out[10]: {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ}In [11]: solveset(sin(3*x), x)Out[11]: ⎧ 2⋅π ⎫ ⎧ 2⋅π {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} ∪ ⎨2⋅n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─── | ⎩ 3 ⎭ ⎩ 3
⎫ ⎧ π ⎫ ⎧ π ⎫ n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π - ─ | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ | n ∊ ℤ⎬ ⎭ ⎩ 3 ⎭ ⎩ 3 ⎭
I found this paper [5] which talks about implementing a parallel Gauss method for solving this issue. Is it relevant ?
This needs to figured out.
5. Building the set infrastructure:
Implementing functions to handle multidimensional ImageSet
Can we be more elaborate on what other features are we expecting ?
1. Search Based Solvers:This idea is currently vague, we need to figure out how exactlywe can develop this. It would be ambitious to develop this idea and It should beaccompanied with lot of research. Currently an abstract is written in the docs:
2. Simplifying solutions returned from equations involving trigonometric expressions:With the Introduction of solveset an important problem of representing infinite solutionhas been solved to some extent, but still there are some issues with ImageSet Union,due to which a lot of simpler results are not displayed properly. This needs to be figuredout to get better ImageSet Union.In [10]: solveset(sin(x), x)Out[10]: {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ}In [11]: solveset(sin(3*x), x)Out[11]:⎧ 2⋅π ⎫ ⎧ 2⋅π{2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} ∪ ⎨2⋅n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─── |⎩ 3 ⎭ ⎩ 3⎫ ⎧ π ⎫ ⎧ π ⎫n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π - ─ | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ | n ∊ ℤ⎬⎭ ⎩ 3 ⎭ ⎩ 3 ⎭
Here is a previous approach on fixing this: https://github.com/sympy/sympy/pull/7673
3. Implementing more Equation solversA lot of thing which needs to be done is already done in old solve, like thesolving of multivariate equation solver, you need to figure out how that worksand how you can port those in solveset following the principles of solveset.
5. Building the set infrastructure:
Implementing functions to handle multidimensional ImageSet
Can we be more elaborate on what other features are we expecting ?See this for motivation: https://github.com/sympy/sympy/issues/10008
In []: solveset(sin(x)<0, x, domain=S.Reals)Out[]: (-∞, 0)
In []: solveset(sin(x)>0, x, domain=S.Reals)Out[]: (0, π)There are a lot of equations which are not solved the solveset or solve ingeneral, the equation you mentioned could just be one of them, It doesn'tdenotes a well known type of equation which could be targeted, I would liketo know if there is a special case which you are interested in? Also If that'snot solved by solve as well? If that's solved by solve, you can get a grasp ofthe algorithm which could be implemented in solveset.
In general solving inequality is not a big deal if we are able tosolve the equality first. After solving the equality if just a matterof returning the solution in a restricted interval. So, I wouldfirst like to see the equality being solved then inequality wouldwork for most of the cases, as inequality solvers calls solve/solvesetinternally. So we need to make sure the solveset returns the correctresults.
In []: solveset(sin(x), x)Out[]: {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ}
In []: solveset(sin(x)>0, x, domain=S.Reals)Out[]: (0, π)
In []: solveset(sin(x)<0, x, domain=S.Reals)Out[]: (-∞, 0)
If you are planning to implement search based solver, then I wouldrecommend you to work on a concrete plan soon.
As It would take alot of time to have a consensus from the community on somethingwhich has not been explored much and frankly speaking I am skepticalabout it currently.
For the case you mentioned, I am not able to make much
sense from it for implementing a special case solver.
In []: solveset(sin(x), x)Out[]: {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ}
In []: solveset((sin(x)).rewrite(exp), x)Out[]: {n⋅π | n ∊ ℤ}
Though, when you would write your plan of execution, It may get more clear then.
More general set to native type converters, they include Bool to Set and Set to Bool conversion for multidimensional sets and bools.
I read that we already have Boolean to Set converters in SymPy but I am not able to find them.
Do we still have them in our codebase or has it been removed ?
Moreover, I would like to know a good usecase for this.
This post is with regards to the Set Infrastructure part of the project idea.
After reading a few resources and the ``sets`` module, I would like to know about a few of these points:
- Handling multidimensional sets
The Ideas Page states that we need to implement few functions to handle multidimensional set objects.
We have a ProductSet class which represents Cartesian Product of Sets.
Shouldn't a n-ary ProductSet object represent a n-dimensional set object ?
If not, I would like to know more about this topic.
While reading Harsh's GSoC Application Proposal, I came across a few points that I think need to be addressed.
- Sets need to get more powerful to deal with countable infinite sets. I think this needs to be implemented as it enhances over power to deal with ImageSet objects. I will read the relevant resources and try to implement them. Harsh's PR #2904 might come in handy as well.
- Better imageset evaluator I would like to know what exactly is the inspiration behind this ?
In [11]: solveset(sin(3*x), x)Out[11]: ⎧ 2⋅π ⎫ ⎧ 2⋅π {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} ∪ ⎨2⋅n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─── | ⎩ 3 ⎭ ⎩ 3
⎫ ⎧ π ⎫ ⎧ π ⎫ n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π - ─ | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ | n ∊ ℤ⎬ ⎭ ⎩ 3 ⎭ ⎩ 3 ⎭
More general set to native type converters, they include Bool to Set and Set to Bool conversion for multidimensional sets and bools.
I read that we already have Boolean to Set converters in SymPy but I am not able to find them.
In [18]: bool = Interval(3, 5).as_relational(x)
In [19]: boolOut[19]: 3 ≤ x ∧ x ≤ 5
In [20]: bool.as_set()Out[20]: [3, 5]
Do we still have them in our codebase or has it been removed ?
Moreover, I would like to know a good usecase for this.Feel free to add the points I might have overlooked here.
-------------------
Kshitij Saraogi
- Handling multidimensional sets
The Ideas Page states that we need to implement few functions to handle multidimensional set objects.
We have a ProductSet class which represents Cartesian Product of Sets.
Shouldn't a n-ary ProductSet object represent a n-dimensional set object ?
If not, I would like to know more about this topic.Yes, that can work as well. See the implementation of ComplexRegion for Two-Dimensional representation of the argand plane.
While reading Harsh's GSoC Application Proposal, I came across a few points that I think need to be addressed.
- Sets need to get more powerful to deal with countable infinite sets. I think this needs to be implemented as it enhances over power to deal with ImageSet objects. I will read the relevant resources and try to implement them. Harsh's PR #2904 might come in handy as well.
- Better imageset evaluator I would like to know what exactly is the inspiration behind this ?
The following could be much simplified with a better Imageset evaluator.In [11]: solveset(sin(3*x), x)Out[11]:⎧ 2⋅π ⎫ ⎧ 2⋅π{2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} ∪ ⎨2⋅n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─── |⎩ 3 ⎭ ⎩ 3⎫ ⎧ π ⎫ ⎧ π ⎫n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π - ─ | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ | n ∊ ℤ⎬⎭ ⎩ 3 ⎭ ⎩ 3 ⎭
More general set to native type converters, they include Bool to Set and Set to Bool conversion for multidimensional sets and bools.
I read that we already have Boolean to Set converters in SymPy but I am not able to find them.
as_relational and as_set functions are implemented.In [18]: bool = Interval(3, 5).as_relational(x)In [19]: boolOut[19]: 3 ≤ x ∧ x ≤ 5In [20]: bool.as_set()Out[20]: [3, 5]
- Handling multidimensional sets
The Ideas Page states that we need to implement few functions to handle multidimensional set objects.
We have a ProductSet class which represents Cartesian Product of Sets.
Shouldn't a n-ary ProductSet object represent a n-dimensional set object ?
If not, I would like to know more about this topic.Yes, that can work as well. See the implementation of ComplexRegion for Two-Dimensional representation of the argand plane.I see that we have used a ProductSet object to define the desired region on the Argand Plane.
While reading Harsh's GSoC Application Proposal, I came across a few points that I think need to be addressed.
- Sets need to get more powerful to deal with countable infinite sets. I think this needs to be implemented as it enhances over power to deal with ImageSet objects. I will read the relevant resources and try to implement them. Harsh's PR #2904 might come in handy as well.
- Better imageset evaluator I would like to know what exactly is the inspiration behind this ?
The following could be much simplified with a better Imageset evaluator.In [11]: solveset(sin(3*x), x)Out[11]:⎧ 2⋅π ⎫ ⎧ 2⋅π{2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} ∪ ⎨2⋅n⋅π - ─── | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─── |⎩ 3 ⎭ ⎩ 3⎫ ⎧ π ⎫ ⎧ π ⎫n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π - ─ | n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ | n ∊ ℤ⎬⎭ ⎩ 3 ⎭ ⎩ 3 ⎭Thanks for this. I will continue Harsh's work and then we can compare these results with that of a heuristic implementation.Would this be a decent enough approach ?