Using Solve function in Mathematica, we may get several solutions, e.g.
In[1]:= Solve[x == 1 && 2 >= y >= 1, {x, y}, Integers]
Out[1]= {{x -> 1, y -> 1}, {x -> 1, y -> 2}}
In case there are tens of solutions, the lists above will be messy.
Now I want to list only all possible values of x and y with a list like this
{x->1, y->1,2}
Is there any easy way to reformat the output of the solution?
Another question, how to use the value from a solution?
In[1]:= Solve[x == 1,{x}]
Out[1]= {x -> 1}
In[2]:= x
Out[2]= x
In[3]:= Definition[x]
Out[3]= Null
In[4]:= ?x
Global`x
For your first question you might use:
For your second question please see this answer.
Most handily:
This makes assignments to the symbol
gg.The function is then used with the syntax
gg[1][17]to mean the first solution, anda == 17: