# Integral with Dirac delta (me or wolfram mathematica?)

I asked the question on math.stackexchange but didn't get an answer so I came here.
I tried to compute with Wolfram Mathematica the following integral $$I=\int_0^\pi\int_{-\infty}^\infty x e^{-\mathrm jx\cos(\theta-\varphi)}f(\alpha\cos(\theta-\psi))\mathrm \, \mathrm dx\mathrm \, \mathrm d\theta$$ where $-\pi\leq\varphi,\psi\leq\pi$.

Assuming that the inner intergral is by definition the derivative of the Dirac delta function I get: $$I=2\pi \mathrm j\int_0^\pi\delta'(\cos(\theta-\varphi))f(\alpha\cos(\theta-\psi)) \, \mathrm \, \mathrm d\theta$$ Wolfram Mathematica tells me that $$I_\mathrm{wolfram}=0$$ Then I tried to do it by hand. If I use the definition of a delta function: $$\begin{eqnarray} \delta^{'} (\cos(\theta-\varphi))&=&\left[ \sum_i \frac{\delta(\theta-\varphi-\frac{\pi}{2}-i\pi)}{|\sin(\frac{\pi}{2}+i\pi)|}\right]^{'}=\sum_i \delta^{'}\left(\theta-\left(\varphi+\frac{\pi}{2}+i\pi\right)\right) \end{eqnarray}$$ $$\begin{eqnarray} I_\mathrm{me}&=&2\pi \mathrm j\sum_i\int_0^\pi\delta'\left(\theta-\left(\varphi+\frac{\pi}{2}+i\pi\right)\right)f(\alpha\cos(\theta-\psi)) \, \mathrm d\theta=\\ &=&-2\pi \mathrm j \sum_i f'(\alpha\cos(\varphi+\frac{\pi}{2}+i\pi-\psi))u(\pi -2 \varphi ) u(2 \varphi +\pi ) \end{eqnarray}$$ where $u(\cdot)$ is a Heaviside function. Here I used the fact that $$\int f(x)\delta'(x-a)\mathrm dx=-\int f'(x)\delta(x-a)\mathrm dx=-f'(a)$$
And $I_\mathrm{me}$ is actually not $0$.
So where's the catch?

-
Link to the post on math.stackexchange.com: math.stackexchange.com/questions/484081/… –  UwF Sep 12 at 11:34
@m0nhawk --- this product of Heaviside functions just says that $\phi$ should be in the interval $(-\pi/2,\pi/2)$, why would that be zero? –  Carlo Beenakker Sep 12 at 19:45
This should be probably be moved to mathematica.SE, as it is probably a matter of what Mma is thinking than anything else. –  Mariano Suárez-Alvarez Sep 13 at 6:43
the answer is indeed nonzero, and Mathematica does just fine; here is a screenshot of the output I got:
UPDATE: with some more experimentation, I think I know why Mathematica might have failed you; as you can see from the code I gave above, I'm evaluating the integral for one value of $\phi$ at the time; an attempt to get an answer with $\phi$ as a symbolic variable returns zero; no idea why, but fortunately there is a workaround, as shown above.
Amusingly, Integrate[ f[\[Alpha] Cos[\[Theta] - \[Psi]]] Derivative[1][DiracDelta][ Cos[\[Theta] - \[Phi]]], {\[Theta], 0, \[Pi]}, Assumptions :> \[Phi] > 0] evaluates correctly (albeit a bit strangely), as does the same thing but wth the assumption changed to <0 or ==0. But if the assumption is changed to Element[\[Phi], Reals] nothing is evaluated. –  Mariano Suárez-Alvarez Sep 13 at 6:42