Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

4 Answers 4

up vote 10 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
2  
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
1  
@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
add comment
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
add comment

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}$

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
1  
@SaulloCastro This should work but using multiple domains shouldn't. –  Kuba Nov 21 '13 at 9:33
1  
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
add comment

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]
/;SameQ@@((Head/@List@@x)~Join~{intp})

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

where intp is positive integer.

share|improve this answer
2  
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
add comment

Your Answer

 
discard

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.