5
$\begingroup$

Here is a list of algebraicly identical equations, and I like to delete all the duplicate equations from this list and get only two equations. I tried the following:

Clear[ss];
listEqs = {
   x + y == x^2 + z,
   y + z == x^2 + z,
   x + y == z + x^2,
   y + z == z + x^2,
   x^2 + z == x + y,
   z + x^2 == x + y,
   x^2 + z == y + z,
   z + x^2 == y + x
   };

DeleteDuplicates[listEqs]

I got:

{
 x + y == x^2 + z,
 y + z == x^2 + z, 
 x^2 + z == x + y,
 x^2 + z == y + z
}

Can someone tell me how to reduce the list to only two equations?

EDIT 1

I noticed a misunderstanding of my question. Here is a second list:

listEqs = {
   y + z == x^2 + z,
   a + b == k + g, 
   x + y == x^2 + z, 
   b + a == g + k,
   x + y == z + x^2,
   a + b == g + k,
   y + z == z + x^2,
   x^2 + z == x + y,
   z + x^2 == x + y,
   x^2 + z == y + z,
   z + x^2 == y + x};

The code:

DeleteDuplicatesBy[listEqs, MemberQ@Level[listEqs, -1]]

picks the first element of the list, which is not what I asked. I want the following list to be the output of the code:

{
y + z == x^2 + z,
a + b == k + g,
x + y == x^2 + z
}

Basically, I just want to pick the non-identical equations from the list. The desired equations can be placed in the middle, end or beginning of the list. The position of the equations are not the issue.

$\endgroup$
  • $\begingroup$ listEqs // Simplify // Union $\endgroup$ – Bob Hanlon Oct 20 '18 at 23:27
  • $\begingroup$ @BobHanlon: Your proposal is not quite what I want since it creates new equations by cancelling the common terms on both sides of the equations, a result of Simplify command. Thanks for your suggestion. $\endgroup$ – Tugrul Temel Oct 20 '18 at 23:59
4
$\begingroup$

Maybe

DeleteDuplicatesBy[listEqs, Reduce] (* or *)
DeleteDuplicatesBy[listEqs, Sort]

{x + y == x^2 + z, y + z == x^2 + z}

For the longer input list:

DeleteDuplicatesBy[listEqs2, Reduce] 

{y + z == x^2 + z, a + b == g + k, x + y == x^2 + z}

$\endgroup$
  • $\begingroup$ It is a typo. Sorry for confusion, but your answer is the right one and it works for me. Thank you very much. $\endgroup$ – Tugrul Temel Oct 20 '18 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.