# How to make Mathematica simplify $\cos[(i + j + k)\pi]$ to $(-1)^{i+j+k}$?

We know that: $$\cos\left[(i+j+k)\pi\right] = (-1)^{i+j+k}$$ for $i, j, k$ being positive integers. In Mathematica I've tried:

FullSimplify[Cos[(i + j + k)*Pi], Assumptions -> Element[{i, j, k}, {Positive, Integers}]]


But it still returns the Cos function. Does anyone know how to perform this simplification?

-

Here's another way:

 Assuming[Element[{i, j, k}, Integers], Refine[Cos[(i + j + k) Pi]]]


-
It can be shorter: Refine[Cos[(i + j + k) Pi], Element[{i, j, k}, Integers]] – Kuba Nov 21 '13 at 9:41
@Kuba. Indeed. Thanks – RunnyKine Nov 21 '13 at 9:42
@RunnyKine So... Refine can simplify better than FullSimplify in this case? – Saullo Castro Nov 21 '13 at 9:42
@SaulloCastro. It would seem so since FullSimplify is more general than Refine and it seems Refine is best suited for this situation. – RunnyKine Nov 21 '13 at 9:45
FullSimplify[Cos[(i + j + k)*Pi],
Assumptions -> Element[i + j + k, Integers], ComplexityFunction -> LeafCount]


(-1)^(i + j + k)

Simplify[Cos[t*Pi], Element[t, Integers]] /. t :> i + j + k


(-1)^(i + j + k)

-

Element is not Listable, also, Positive is not valid domain so it is reasonable to me that it is not working.

If you put the assumptions more carefully then everything is alright:

 Simplify[Cos[(i + j + k)*Pi],
Element[{i, j, k}, Integers] && And @@ (# > 0 & /@ {i, j, k}),
ComplexityFunction -> LeafCount]


$(-1)^{i+j+k}$

-
Thank you... you mean that when I do Element[{i, j, k}, Integers] it is not applying the assumptions for all the variables? – Saullo Castro Nov 21 '13 at 9:31
@SaulloCastro This should work but using multiple domains shouldn't. – Kuba Nov 21 '13 at 9:33
The ComplexityFunction option is very useful in this situation to determine the rule for ranking the most simplified – Shenghui Nov 21 '13 at 10:30

Another way is basically use the Mathematica's build in Head for all expressions. The following may seem less elegant but works for arbitrary number of summands:

Cos[(intp[a]+intp[b]+intp[c]+intp[d])*Pi]/.Cos[(Plus[x__])*Pi]:>Hold[-1^x]

where intp is positive integer.