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

2 Answers 2

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
    
ybeltukov, you haven't been active on this site recently. I want to let you know that your contributions are missed. –  Mr.Wizard Jun 3 at 21:26
    
@Mr.Wizard I'm sorry that I have no spare time to participate on this site now. I hope I'll be back in September or earlier. I was glad to talk with Leonid at the recent Wolfram conference in St. Petersburg. –  ybeltukov Jun 4 at 13:46

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

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.