0

1

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 :)

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.223ahh 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)^n`

is 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.070yes @Artesit does thanks :) – youyou – 2020-05-05T13:39:33.037