On Sep 8, 5:01 am, Peng Yu <PengYu... at gmail.com> wrote:
> Hi,
>
> Solve[(x - 1)^2 == 0, x]
>
> The above code would give me the solution
> {{x -> 1}, {x -> 1}}
>
> But one is a duplicate of the other. I'm wondering how to only produce
> the unique solutions.
>
> Thanks,
> Peng
It is very simple.
Solve gives you a list, that is a collection of elements which may be
duplicates and have (and have a specific order, but that is not
important now).
You want to transform this into a set, that is a collection of
elements without duplicates.
Union does that, among other things.
So:
In[7]:= Solve[(x - 1)^2 == 0, x]
Out[7]= {{x -> 1}, {x -> 1}}
In[8]:= Union[%]
Out[8]= {{x -> 1}}