0

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]

rhermans
  • 36,518
  • 4
  • 57
  • 149
Wolpertinger
  • 167
  • 9
  • Why is integral alternatively capitalized? – Feyre May 24 '17 at 08:39
  • I get, FullSimplify[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
  • @Feyre oops, the capitalized 'integral' was a typo. I corrected it, the script should run now. About the other comment: yep, I get that too. That is really not expected though, how is the integral with n=m infinite? Also I tried setting n=m at the start and then compute the integral, that gave a different and finite result. – Wolpertinger May 24 '17 at 08:44
  • @Feyre see edit, does that clarify? – Wolpertinger May 24 '17 at 08:47
  • 3
    Mathematica will usually only generate generically correct answers. – J. M.'s missing motivation May 24 '17 at 08:53
  • @J.M. ah I see, thanks! That answers why does Mathematica not account for this special case? Remains the second question Is there any way to force it to distinguish the cases? Maybe declaring that they are integer before the integral will help to make $m=n$ a non-zero measure subset? – Wolpertinger May 24 '17 at 08:55

0 Answers0