This is a big problem if you do anything with a Fourier Series. This statement:
Assuming[Element[{m, n}, Integers], Integrate[Cos[m*x]*Cos[n*x], {x, 0, 2 Pi}]]
returns 0. But the right answer is non-zero whenever $|m|=|n|$.
This other arrangement:
Integrate[Cos[m*x]*Cos[n*x], {x, 0, 2 Pi}, Assumptions -> Element[{m, n}, Integers]]
gives an answer that goes $0/0$ when $|m|=|n|$.
I know there are generic and non-generic answers, but this is pretty dang simple. And Fourier series work is pretty common!
What I need is a solution that will work when I didn't know there was a Cos[n x] in it:
Integrate[Integrate[Cos[m*x]*f[x], {x, 0, 2 Pi}, Assumptions -> Element[{m}, Integers]]
If my f[x] happens to have a Cos[] in it, Mathematica will give me wrong answers, unless I anticipate the situation and code around it. How could I do that?
RefineandSimplify. In a case like this, assumptions of integrality will have the predictable result. Here is a smaller variant: `Refine[Sin[m*Pi]/m, Assumptions->Element[m,Integers]]Out[5]= 0
– Daniel Lichtblau Nov 17 '14 at 23:46. If this does not return 0, thenRefineis effectively useless. And if it does, thenRefinecannot do better than support a generic result, when used inIntegrate`.