I was running the following script in Mathematica
f = Sin[n*Pi*q]*Sin[m*Pi*p]*Exp[I*b*(q - p)] + Sin[n*Pi*q]*Sin[m*Pi*p]*Exp[-I*b*(q - p)]
integral = Integrate[Integrate[f, {p, 0, q}], {q, 0, 1}]
SimpleIntegral = Simplify[integral, n ∈ Integers && m ∈ Integers]
SimpleIntegral /. n -> m
and noticed that the resulting double integral was incorrect for the special case n=m. In fact the result is singular at m=n.
My question is why does Mathematica not account for this special case? Is there any way to force it to distinguish the cases? Right now I have to compute the m=n case separately and then synthesize my own formula from the two results.
For clarity what I really want to compute is the integral $$\int_0^1 \int_0^q \left[\sin(n\pi q)\sin(m\pi p)e^{ib(q - p)} + \sin(n\pi q)\sin(m\pi p)e^{-ib(q - p)}\right]$$
under the condition that $n$ and $m$ are integers. $n$ and $m$ may or may not be equal.
To see why this integral is indeed wrong for the special case n=m try the following code, where the assumption is put at the start and that gives a finite result
f = Sin[n*Pi*q]*Sin[n*Pi*p]*Exp[I*b*(q - p)] +
Sin[n*Pi*q]*Sin[n*Pi*p]*Exp[-I*b*(q - p)]
integral = Integrate[Integrate[f, {p, 0, q}], {q, 0, 1}]
SimpleIntegral = Simplify[integral, n ∈ Integers]
integralalternatively capitalized? – Feyre May 24 '17 at 08:39FullSimplify[integral, n \[Element] Integers && m \[Element] Integers] /. n -> m..Power::infy: Infinite expression 1/0 encountered. >>as expected. – Feyre May 24 '17 at 08:40