No real "problem" here, just wondering why this is happening and how one might force Mathematica to simplify this. Consider:
Reduce[(-1)^n == 1, n \[Element] Reals]
(* Out: (C[1] \[Element] Integers && n == 2 C[1]) || n == 0 *)
Note the weird "... || n == 0
" even though that's a special case of the left disjunct, with C[1] -> 0
. Applying Simplify
and FullSimplify
don't get rid of the superfluous n == 0
condition. (Including the assumption 0 \[Element] Integers
doesn't help either; it immediately evaluates to True
.)
Another strange thing is that
Reduce[(-1)^n == 1, n \[Element] Integers]
doesn't include the superfluous condition! It just returns (C[1] \[Element] Integers && n == 2 C[1])
.
What's causing this, and is there a general "lack of ability to unify special cases" in Simplify
and the like that it's worth watching out for? And why does using Integers
instead of Reals
change the behavior?
Integers
code and an analyticReals
code, each called separately in the first case, and the analytic code returns0
. $\endgroup$ExpToTrig
to(-1)^n
in the first example, the extraneousn == 0
goes away. $\endgroup$Simplify[Reduce[(-1)^n == 1, n \[Element] Reals], Assumptions -> n != 0]
givesElement[n/2, Integers]
in MMA 12.1 $\endgroup$