Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 11 down vote accepted

Here's another way:

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

enter image description here

share|improve this answer
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)

share|improve this answer

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]


share|improve this answer
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:


(* Hold[-1^(int[a]+int[b]+int[c]+int[d])] *)

where intp is positive integer.

share|improve this answer
man... this is hard core stuff... – Saullo Castro Nov 21 '13 at 13:18
This technique is usually good for create data type. Too brutal for this case. – Shenghui Nov 22 '13 at 1:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.