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.

I am obtaining in Mathematica:

Cos[2*Pi*FractionalPart[1/2*(i + j + k)]]

We know that for $i, j, k$ being positive integers this expression after simplification should give:

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

I would like to know why the one of the solutions proposed for this similar question:

 Refine[Cos[2*Pi*FractionalPart[1/2*(i + j + k)]], 
    Assumptions -> {Element[{i, j, k}, Integers], i > 0, j > 0, k > 0}]

did not work for this case?

share|improve this question
    
@Kuba sorry, that was a copy paste issue from the real code.. I fixed now... –  Saullo Castro Feb 3 at 8:15
    
    
@Artes this is not a duplicate because the question is asking why the Refine is not working in this case, while the other question was asking how to simplify the expression... –  Saullo Castro Feb 3 at 14:13
1  
@Artes I think that it is not a duplicate since Refine/FullSimplify works bad with FractionalPart. –  ybeltukov Feb 3 at 15:32
    
@ybeltukov I would retract my close vote if you provided at least a bit more optimal approach e.g. Simplify[Cos[ 2 Pi (# - Floor@#)&[(i + j + k)/2]], (i | j | k) ∈ Integers] –  Artes Feb 3 at 17:00
add comment

2 Answers

up vote 6 down vote accepted

One can use x-Floor[x] instead of FractionalPart[x] for positive x

FullSimplify[Cos[2 Pi ((i + j + k)/2 - Floor[(i + j + k)/2])], 
   Assumptions -> (i | j | k) ∈ Integers]

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

share|improve this answer
add comment

Using the solution proposed in this answer also works:

FullSimplify[Cos[2 Pi FractionalPart[1/2 (i + j + k)]], 
             Assumptions -> {Element[i + j + k, Integers], i > 0, j > 0, k > 0},
             ComplexityFunction -> LeafCount]

Giving:

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

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