-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Adding classes to represent implicitly defined regions #19681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Algorithm to determine the parametric representation of a Conic:
|
✅ Hi, I am the SymPy bot (v160). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like: This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
🟠Hi, I am the SymPy bot (v160). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files: If these files were added/deleted on purpose, you can ignore this message. |
sympy/vector/implicitregion.py
Outdated
|
||
# Finding a point on the Curve. | ||
# Needs to find a better way than random looping. | ||
for i in range(100): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to find a better way to find a point on the conic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you thought about some deterministic-iterative algorithm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you cannot solve the equation... maybe you are at a singular point, right? Can you determine singular points from the gradient of the implicit equation? Maybe thinking of example equations where this case happens, may help think about a solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on it. I think I will implement a general algorithm for monoids which will work for all conics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found on an algorithm for determining a point on the conic:
https://www3.risc.jku.at/publications/download/risc_1355/Rational%20Points%20on%20Conics.pdf.
@Upabjojr the algorithm is non-trivial. Is it worth it to implement? Even parametrizing conics seems to be a tough task,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to make the user input a point on the curve apart from implicit equation.
An example:
C = ImplicitCurve(Eq(x**2 + y**2 - 4))
C.parametrization(Point(0, 2)) #Takes a point on a curve
(2*cos(theta), 2*sin(theta))
@Upabjojr Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting the point is fine with me, especially if it makes the code simpler to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can work with this and maybe later implement the algorithm for finding a rational point on the curve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course... always start with a simple algorithm. We can open as many pull requests as we like, so no need to do it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I will complete this work then. This point will be optional. If not given, the algorithm will iterate over some point. If it is unable to find a point on the curve, it raises NotImplementedError.
A better way is to use an algorithm to parameterize a monoid. A monoid is an algebraic curve of degree n that has a point of multiplicity n -1. All conics and singular conics are monoids. But this requires determining the (n -1) fold point. I currently do not know how to determine this. |
ping @Upabjojr |
…ioon defined imperically to ParametricRegion object
@Upabjojr My concern is that the parametric representation determined by these algorithms are mostly in terms of large and complex expression. 'ParametricIntegral
There is little benefit of adding functions to determine parametric representation of implicit region if |
Sage has a function for rational parametrization of Curves. See But it requires the implementation of many other related classes. |
Sage is GPL'd. We cannot reuse their code. Their approach to this problem is a lot more theoretical... they define lots of algebraic structures. Is this really the purpose of |
That is a bug of |
Probably something like this can become part of the geometry module. I had to email authors of a few research papers to understand some of these concepts. I highly doubt Mathematica integrates over implicit regions this way. It can handle many complex curves and surfaces including inequalities that most likely are not easily parametrizable.
I agree. I did not thought it in this way. |
That's a nice research. In case you decide not to implement this algorithm, what about writing a page on SymPy's wiki? |
OK, For either case, I will try to summarize what I have learned on parametrizing rational curves/surfaces. |
@Upabjojr I have implemented the algorithm for the parametrization of monoids. We can now determine the rational parametrization of all algebraic curves and surfaces of degree > 2 if a parametrization exists. It is important to note that the algorithm returns rational parametrization so in some cases the result may not be convenient. >>> c = ImplicitRegion((x, y), x**2 + y**2 - 16)
>>> c.rational_parametrization()
(-4 + 8/(t**2 + 1), 8*t/(t**2 + 1)) |
Codecov Report
@@ Coverage Diff @@
## master #19681 +/- ##
=============================================
- Coverage 75.709% 75.704% -0.005%
=============================================
Files 659 664 +5
Lines 171401 172364 +963
Branches 40437 40652 +215
=============================================
+ Hits 129766 130487 +721
- Misses 35982 36164 +182
- Partials 5653 5713 +60 |
That's pretty nice. |
I will try to implement the algorithm for finding a regular point on a Conic in a separate PR. Maybe we can then get rid of |
sympy/vector/implicitregion.py
Outdated
|
||
return m | ||
|
||
def rational_parametrization(self, parameter1='t', parameter2='s', reg_point=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to work for 2D only? What about parameters = ('t', 's')
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will work for curves and surfaces given that they are monoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The report which I followed had algorithms only for curves and surfaces. No Volume regions or higher dimensional region.
What about parameters = ('t', 's') instead?
This looks better. I will fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to work for 2D only? What about parameters = ('t', 's') instead?
It does not work for 3-D curves. It works for 3-D surfaces but does not support higher-dimensional surfaces..
References to other Issues or PRs
#19320
Brief description of what is fixed or changed
The vector module has support to define regions using parametric representation and integrate over them.
In some cases, It is easier to work to define regions using their implicit equation. This Pull Request aims to add classes to represent implicitly defined regions.
Other comments
This PR is a draft and the structure of the PR is not fixed.
Release Notes