In Mathematica, how can I simplify expressions like a == b || a == -b into a^2 = b^2? Every function that I have tried (including Reduce, Simplify, and FullSimplify) does not do it.
Note that I want this to work for an arbitrary (polynomial) expressions a and b. As another example,
a == b || a == -b || a == i b || a == -i b
(for imaginary i) and
a^2 == b^2 || a^2 == -b^2
should both be simplified to a^4 == b^4.
Note: the solution should work at the logical level so as not to harm other unrelated logical cases. For example,
a == b || a == -b || c == d
should become
a^2 == b^2 || c == d.
The Boolean expression can be converted to the algebraic form as follows:
EDIT
In response to making the transformation leave out parts in other variables, one can write
Ortransformation function, and use inSimplify:Alternatively: