Given the following list:
{a + b, c + d + e, - a + b, a - b, - c - d - e}
I would like to get as a result:
{a + b, a - b, c + d + e}
To clarify: I'd like to transform the first list in such a way that the first term in each element is normalized to a plus sign and throw away any elements that can be obtained from the final result by multiplying with -1
.
I have tried Collect[]
and FactorTerms[]
and some other functions that look remotely like they would be able to do what I need, but they never touch minus signs ....
Any help is greatly appreciated.
Use FactoredTermsList
:
In[5]:= FactorTermsList /@ {a + b, c + d + e, -a + b,
a - b, -c - d - e}
Out[5]= {{1, a + b}, {1, c + d + e}, {-1, a - b}, {1, a - b}, {-1,
c + d + e}}
In[6]:= DeleteDuplicates[%[[All, 2]]]
Out[6]= {a + b, c + d + e, a - b}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With