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

[Don't merge] Connecting diophantine and solveset #10994

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@Shekharrajak
Copy link
Member

commented Apr 10, 2016

Now solveset returns Integers solution for an equation using diophantine.py .

>>> solveset(2*x + 3*y - 5, x, S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) | t₀ ∊ ℤ}
>>> solveset(2*x + 3*y - 5, domain=S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) | t₀ ∊ ℤ}

Please suggest if something more is expected.

If we want the solution in Finiteset then we will get :

>>> solveset(2*x + 3*y - 5, domain=S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) }

which is similar to the way used in linsolve.

@Shekharrajak

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2016

@smichr

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

Your 2nd and 3rd example in the OP are the same -- could you please update them so it's clear how to get one behavior or the other?

@Shekharrajak

This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2016

@smichr , thanks for your response.

>>> solveset(2*x + 3*y - 5, x, S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) | t₀ ∊ ℤ}
>>> solveset(2*x + 3*y - 5, domain=S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) | t₀ ∊ ℤ}

In second case solution would be in the order of variable, present in the equation, we just need to give domain= S.Integers to get integer solution.
In first case, I am little confused. Should we pass more than one symbol in solveset, similar to solve ?
If we pass x then solution for x in terms of t₀ is 3⋅t₀ - 5, where for all value of y = -2⋅t₀ + 5 .
So both x ,y value is connected. So need to show both values. But if we have 3 or more free_symbols then need to specify all other solution in condition expression, isn't it ?
So I think it is better to return all the solution for any symbol.

@@ -540,6 +540,7 @@ def _solveset(f, symbol, domain, _check=False):
# _check controls whether the answer is checked or not

from sympy.simplify.simplify import signsimp
from sympy.solvers.diophantine import diop_solve

This comment has been minimized.

Copy link
@smichr

smichr May 3, 2016

Member

diophantine is more general that diop_solve -- it does pre-conditioning on the equation of interest.

This comment has been minimized.

Copy link
@Shekharrajak

Shekharrajak May 3, 2016

Author Member

Yeah, actually I was little confused because diophantine returns set of tuples , where diop_solve returns solution tuple (easy to convert into FIniteSet).
Now I think diophantine should be used.

if domain.is_subset(S.Reals):
if domain is S.Integers:
# calling methods from diophantine.py
solution = diop_solve(orig_f)

This comment has been minimized.

Copy link
@smichr

smichr May 3, 2016

Member

solveset can solve equations in which there is an integer solution that are beyond the scope of diophantine. Also, the solution returned from diophantine does not claim to be complete (and probably shouldn't be, e.g. in the case of sums of squares there is a lot of redundancy in returning the full solution). The solution from solveset should be complete. So if the solution can be be found -- there should be an error if it can't -- then the signs and orders of the results should be permuted as necessary. classify_diop could be used to know when to do that; but there is no current hardcoded method of indicating when only an unpermuted subset of solutions is being returned from diophantine.

@Shekharrajak

This comment has been minimized.

Copy link
Member Author

commented Aug 5, 2016

New PR : #11234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.