# Integer parameter assumption gives incorrect result when integrating

There are some dangerous pitfalls that can happen when evaluating some integrals, assuming that some parameters are integers. For example, consider the following:

Assuming[m \[Element] Integers, Integrate[Exp[I m x], {x, 0, 2 \[Pi]}]] (*output: 0*)


The correct result should have been $$2 \pi \delta_0^m$$. Is there a proper way to do such an integral? There is another thread discussing a similar issue, but GenerateConditions does not do anything in this case. Is there really no other way other than trying lots of values of $$m$$ until one find the one ($$m=0$$) for which the integral is not trivial?

• Assuming[m \[Element] Integers, Integrate[Piecewise[{{1, m == 0}}, Exp[I m x]], {x, 0, 2 \[Pi]}]] May 9 at 23:58