Implemented an algorithm to find a rational point on a conic#19807
Implemented an algorithm to find a rational point on a conic#19807Upabjojr merged 6 commits intosympy:masterfrom
Conversation
|
✅ 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. |
| if len(self.singular_points()) != 0: | ||
| singular_points = self.singular_points() | ||
| for spoint in singular_points: | ||
| syms = Tuple(*spoint).free_symbols |
There was a problem hiding this comment.
what about syms = set(spoint) ?
| sol = list(sol)[0] | ||
| syms = Tuple(*sol).free_symbols | ||
| rep = {s: 3 for s in syms} | ||
|
|
There was a problem hiding this comment.
There is a bug here. In cases like x*y = 1, the solution of diophantine equation is {(p2 + q2, -2pq, p2 - q2)}. If I substitute p = 3 and q = 3, z turns out to be zero. This leads to the result being nan. The algorithm requires the solution of diophantine equation to be non-trivial.
There was a problem hiding this comment.
What about pushing the solution of the diophantine equation into the equation solver? For example, in the case {(p2 + q2, -2pq, p2 - q2)}, can it help if you get p as a function of q?
There was a problem hiding this comment.
Yes, I think this should work. Solving for z != 0, then using one of its solutions.
There was a problem hiding this comment.
This is how I am trying to get the solutions for z != 0
for sol in solutions:
syms = Tuple(*sol).free_symbols
z = sol[2]
z_syms = ztemp.free_symbols
if len(z_syms) == 2:
print(solveset(Unequality(z, 0), next(iter(z_syms)), S.Integers))But solveset is too slow for returning an Integer solution.
There was a problem hiding this comment.
Have you thought about solving the equality and then taking the complement of the solutions? It should be equivalent to solveset(Unequality( ... )).
There was a problem hiding this comment.
This should work. In the case of two variables p and q, I will iterate p over S.Integers and then solve q for z != 0.
Co-authored-by: Naman Gera <namangera15@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #19807 +/- ##
=============================================
- Coverage 75.719% 75.709% -0.010%
=============================================
Files 664 666 +2
Lines 172374 172712 +338
Branches 40653 40717 +64
=============================================
+ Hits 130520 130759 +239
- Misses 36147 36225 +78
- Partials 5707 5728 +21 |
sympy/vector/implicitregion.py
Outdated
|
|
||
| - Christoph M. Hoffmann, Conversion Methods between Parametric and | ||
| Implicit Curves and Surfaces. | ||
| Implicit Curves and Surfaces, 1990. Available: |
There was a problem hiding this comment.
Publisher and authors are more important than the title itself. Christoph M. Hoffmann? Perdue e-Pubs?
|
This looks good to me. Please add the authors and publisher of all citations you've added (in the literatura, authors and publishing review company are usually more important than the title of the paper itself). |
References to other Issues or PRs
#19320
Brief description of what is fixed or changed
Implemented an algorithm to find a rational point on the conic. To parametrize a monoid of degree d, we need to find a point of multiplicity d - 1. This implies for curves of degree 2, we need to determine a rational point on it. While determining a point of multiplicity >= 2 is easy using sympy's non-linsolve, a separate algorithm needs to be implemented for points of multiplicity 1 or regular points.
The
regular_pointwas based on iterating over a set of points and checking whether they lie on the conic. This PR fixes this for conics. I have not yet implemented the algorithm for quadrics.Other comments
Release Notes