Skip to content
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

detection of infinite solution request #21999

Closed
smichr opened this issue Sep 1, 2021 · 6 comments · Fixed by #22005
Closed

detection of infinite solution request #21999

smichr opened this issue Sep 1, 2021 · 6 comments · Fixed by #22005

Comments

@smichr
Copy link
Member

smichr commented Sep 1, 2021

>>> solve_poly_system((x - 1,), x, y)
Traceback (most recent call last):
...
NotImplementedError:
only zero-dimensional systems supported (finite number of solutions)
>>> solve_poly_system((y - 1,), x, y)  <--- this is not handled correctly
[(1,)]
diff --git a/sympy/solvers/polysys.py b/sympy/solvers/polysys.py
index b9809fd4e9..674322d4eb 100644
--- a/sympy/solvers/polysys.py
+++ b/sympy/solvers/polysys.py
@@ -240,7 +240,7 @@ def _solve_reduced_system(system, gens, entry=False):
 
         univariate = list(filter(_is_univariate, basis))
 
-        if len(univariate) == 1:
+        if len(univariate) == 1 and len(gens) == 1:
             f = univariate.pop()
         else:
             raise NotImplementedError(filldedent('''
diff --git a/sympy/solvers/tests/test_polysys.py b/sympy/solvers/tests/test_polysys.py
index 58419f8762..9e674a6fe6 100644
--- a/sympy/solvers/tests/test_polysys.py
+++ b/sympy/solvers/tests/test_polysys.py
@@ -48,6 +48,10 @@ def test_solve_poly_system():
     raises(NotImplementedError, lambda: solve_poly_system(
         [z, -2*x*y**2 + x + y**2*z, y**2*(-z - 4) + 2]))
     raises(PolynomialError, lambda: solve_poly_system([1/x], x))
+    raises(NotImplementedError, lambda: solve_poly_system(
+        Poly(x - 1, x, y), (x, y)))
+    raises(NotImplementedError, lambda: solve_poly_system(
+        Poly(y - 1, x, y), (x, y)))
 
 
 def test_solve_biquadratic():
@smichr smichr added Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. polys solvers.solve labels Sep 1, 2021
skirpichev added a commit to skirpichev/diofant that referenced this issue Sep 2, 2021
mohajain added a commit to mohajain/sympy that referenced this issue Sep 2, 2021
@mohajain mohajain mentioned this issue Sep 2, 2021
@praneethratna
Copy link
Contributor

This is not a possible solution i feel , since some of the tests are failing and also weirdly solve_poly_system([2*x - 3, y*Rational(3, 2) - 2*x, z - 5*y], x, y, z) is throwing a NotImplementedError .

@smichr smichr removed the Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. label Sep 2, 2021
@smichr
Copy link
Member Author

smichr commented Sep 2, 2021

Hmm. Well, they should yield similar results: an error or a solution. Looks like maybe a solution, then, should be returned? I am not sure. Maybe @jksuom would have some idea.

@jksuom
Copy link
Member

jksuom commented Sep 2, 2021

It seems that the number of polynomials in the Gröbner basis should be the same as the number of variables so there should be something like

    if len(basis) != len(gens):
        raise NotImplementedError(...)

@praneethratna
Copy link
Contributor

It seems that the number of polynomials in the Gröbner basis should be the same as the number of variables

This raises a NotImplementedError for solve_poly_system([x*y - 2*y, 2*y**2 - x**2], x, y) but which isn't the case since it has a solution.

@jksuom
Copy link
Member

jksuom commented Sep 2, 2021

It looks like the test could be if len(basis) < len(gens) though I'm not sure if the implementation can handle all cases where len(basis) > len(gens).

@praneethratna
Copy link
Contributor

praneethratna commented Sep 2, 2021

Yes this works and now solve_poly_system((y - 1,), x, y) also returns NotImplementedError , I'll open a PR for this.
I'm not sure but all cases of len(basis) > len(gens) are being handled.

praneethratna added a commit to praneethratna/sympy that referenced this issue Sep 2, 2021
smichr added a commit that referenced this issue Sep 2, 2021
solvers - fixes issue #21999 and solve_poly_system returns correct output for some equations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants