# What am I doing wrong in this integration (over the angle between any two three-dimensional vectors)?

I am trying to do a six dimensional integration involving functions of two vectors $\vec{p}$ and $\vec{p}'$ in spherical coordinates. So $\vec{p}$ is reprsented by $\{p,\theta,\phi\}$, and $\vec{p}'$ is represented by $\{p',\theta',\phi'\}$. The $\theta$'s range from 0 to $\pi$, and the $\phi$'s range from 0 to $2\pi$. The angle between the two vectors is given by $\cos\gamma = \cos\theta\cos\theta' + \sin\theta\sin\theta'\cos(\phi-\phi')$. I cannot take any of these to vectors to be the $z$-axis, since the $z$-axis is fixed by a third vector.

Suppose the function that I have to integrate is $$\frac{\cos(\phi-\phi')}{[p^2 + p'^2 + 2pp'\cos\gamma + M^2]^2}$$ where $M$ is a real constant. Then the integrals over $\phi$ and $\phi'$ would be of the form $$\int_0^{2\pi} d\phi' \int_0^{2\pi} d\phi \frac{\cos(\phi-\phi')}{[a + b\cos(\phi - \phi')]^2}$$ where I have used $a$ and $b$ to represent the terms that are independent of $\phi$ and $\phi'$. If I now do the following substitution $$\sin(\phi - \phi') = u$$ then the integration becomes $$\int_0^{2\pi} d\phi' \int_{-\sin\phi'}^{-\sin\phi'} du\frac{1}{[a+b\sqrt{1-u^2}]^2}$$ which is just zero.

There are a bunch of other functions which involve $\cos(\phi-\phi')$ that I am trying to integrate. I was expecting most of these to be nonzero. But from what I see it appears to me that if it involves $\cos(\phi-\phi')$ then for the given range of $\phi$ the integral will always be zero.

Am I doing something wrong here?

note that $\cos \theta = -\sqrt{1-\sin^2\theta}$ when $\theta \in (\frac \pi 2, \frac {3\pi} 2)$
In General $$I= \int_0^{2\pi}\cos\theta f(\cos \theta)d\theta \\= \int_0^{\frac \pi 2}\cos\theta f(\cos \theta)d\theta +\int_{\frac \pi 2}^{\frac {3\pi }2}\cos\theta f(\cos \theta)d\theta + \int_{\frac {3\pi }2}^{2\pi}\cos\theta f(\cos \theta)d\theta$$ now we can make the sine substitution in all three integrals, being careful to use $\cos\theta = -\sqrt{1-u^2}$ in the second integral $$I=\int _0^1f(\sqrt{1-u^2})du+\int _{1}^{-1}f(-\sqrt{1-u^2})du +\int _{-1}^0f(\sqrt{1-u^2})du \\=\int_{-1}^1\Bigg[ f(\sqrt{1-u^2})-f(-\sqrt{1-u^2}) \Bigg]du$$