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

Closed
wants to merge 1 commit into from

## Conversation

Projects
None yet
2 participants
Member

### Shekharrajak 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`.
``` connecting diophantine and solveset ```
``` a89a631 ```
Member Author

Member

### smichr 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?
Member Author

### Shekharrajak commented Apr 11, 2016 • edited

 @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`.

### smichr reviewed May 3, 2016

 @@ -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

#### smichr May 3, 2016 • edited

Member

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

#### 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.

### smichr reviewed May 3, 2016

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

#### 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.

Member Author

### Shekharrajak commented Aug 5, 2016

 New PR : #11234