I have a problem which surely someone else had on here, but in reading similar questions, I haven't found an answer.

The problem is really trivial:

Integrate[Sin[k*x]^2, {x, -Pi, Pi}, 
 Assumptions -> {k ∈ Integers}]

That shall simply give me


Because the whole result would be

$$\pi -\frac{\sin (2 \pi k)}{2 k}$$

But since $k\in\mathbb{Z}$ we have $\sin(2\pi k) = 0$ for every $k$.

Why doesn't mathematica print $\pi$ in the output, simply?

P.s. Of couse "Elements" denotes the $\in$ symbol. Here something went wrong during the copy of the input text!

  • $\begingroup$ What about k == 0? $\endgroup$
    – Greg Hurst
    Commented Sep 30, 2016 at 20:22
  • $\begingroup$ @ChipHurst Uhm, right! Let me try with two assumptions, namely that one and $k>0$... $\endgroup$
    – Enrico M.
    Commented Sep 30, 2016 at 20:24
  • $\begingroup$ @ChipHurst It still doesn't work... $\endgroup$
    – Enrico M.
    Commented Sep 30, 2016 at 20:24

1 Answer 1


Simplify is not automatically used

Assuming[{k ∈ Integers},
 Integrate[Sin[k*x]^2, {x, -Pi, Pi}] //

(*  π  *)
  • $\begingroup$ That worked! Thank you! $\endgroup$
    – Enrico M.
    Commented Sep 30, 2016 at 20:27

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