4
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ @Kuba sorry, that was a copy paste issue from the real code.. I fixed now... $\endgroup$ Commented Feb 3, 2014 at 8:15
  • $\begingroup$ possible duplicate of How to make Mathematica simplify Cos[(i + j + k) Pi] to (-1)^(i+j+k)? $\endgroup$
    – Artes
    Commented Feb 3, 2014 at 12:36
  • $\begingroup$ @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... $\endgroup$ Commented Feb 3, 2014 at 14:13
  • 1
    $\begingroup$ @Artes I think that it is not a duplicate since Refine/FullSimplify works bad with FractionalPart. $\endgroup$
    – ybeltukov
    Commented Feb 3, 2014 at 15:32
  • $\begingroup$ @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] $\endgroup$
    – Artes
    Commented Feb 3, 2014 at 17:00

2 Answers 2

6
$\begingroup$

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)

$\endgroup$
2
  • $\begingroup$ ybeltukov, you haven't been active on this site recently. I want to let you know that your contributions are missed. $\endgroup$
    – Mr.Wizard
    Commented Jun 3, 2014 at 21:26
  • $\begingroup$ @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. $\endgroup$
    – ybeltukov
    Commented Jun 4, 2014 at 13:46
2
$\begingroup$

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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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