Assumptions behavior in Refine[Sin[n Pi/2]]



I don't understand why this first expression returns a correct result:

In> Refine[Sin[n Pi/2], Element[n, Integers] && Mod[n, 2] == 1]

Out> I^(-1 + n)

But this one returns a warning and an unexpected result:

In> Refine[Sin[n Pi/2], Element[n, Integers] && EvenQ[n]]

Refine: Warning: one or more assumptions evaluated to False.

Out> Sin[(n \[Pi])/2]

I don't understand the warning considering that Mod[n,2]==1 and OddQ[n] return the same result for any Integer ....

Bonus question : how to force Mathematica to return (-1)^n instead of I^(-1 + n) ?

thanks :)


Posted 2020-05-05T05:10:15.457

Reputation: 91

Question was closed 2020-05-05T17:22:54.033

5The message is correct. You are effectively evaluating Refine[Sin[n Pi/2], Element[n, Integers] && False]. Recall that *Q[] functions are designed to immediately return a Boolean value, so EvenQ[n] will immediately return False if n is symbolic. (This is a dupe, but I cannot find the original question about this right now.) – J. M.'s ennui – 2020-05-05T06:00:19.223

ahh ok just saw this in "possible issues" in the help for OddQ .... many thanks – youyou – 2020-05-05T06:24:02.100

To the "Bonus Question": (-1)^nis not the same as I^(-1+n) ! See Table[{{n}, Sin[(n \[Pi])/2], I^(-1 + n), (-1)^n}, {n, -5, 5, 2}] . – Akku14 – 2020-05-05T12:52:41.070

yes @Artesit does thanks :) – youyou – 2020-05-05T13:39:33.037

No answers