Integral involving angle between two vectors $\iint d\phi' \, d(\cos\theta')\cos\gamma = \pi\cos\theta$ This result is given in Jackson's Classical Electrodynamics. Let $\vec{x}$ and $\vec{x}'$ be two vectors in $\mathbb{R}^3$ corresponding to points $(r,\phi,\theta)$ and $(r',\phi',\theta')$ respectively. This is using physics notation where $\phi$'s are azimuthal and $\theta$'s are polar angles. The angle between the vectors is $\gamma$. Jackson claims:
$$\int_0^{2\pi} d\phi' \int_0^1 d(\cos\theta')\cos\gamma = \pi\cos\theta.$$
Do I express $\gamma$ in another form to proceed? A hint would be appreciated.
 A: We can write $\cos\gamma$ in terms of the scalar product of vectors:$$\cos\gamma=\frac{\vec x\cdot\vec x'}{|\vec x||\vec x'|}$$
If we write the chartesian coordinates for $\vec x$ we get:$$x=r\sin\theta\cos\phi\\y=r\sin\theta\sin\phi\\z=r\cos\theta$$
You get similar representation for $\vec x'$. The scalar product $$\vec x\cdot\vec x'=xx'+yy'+zz'$$ When we plug this in the expression for $\cos\gamma$, and using $|\vec x|=r$ and $|\vec x'|=r'$ we get:
$$\cos\gamma=\sin\theta\cos\phi\sin\theta'\cos\phi'+\sin\theta\sin\phi\sin\theta'\sin\phi'+\cos\theta\cos\theta'\\=\sin\theta\sin\theta'\cos(\phi-\phi')+\cos\theta\cos\theta'$$
Now let's do the integration over $\phi'$ first:
$$\int_0^{2\pi}d\phi'(\sin\theta\sin\theta'\cos(\phi-\phi')+\cos\theta\cos\theta')=\\\sin\theta\sin\theta'\int_0^{2\pi}d\phi'\cos(\phi-\phi')+\cos\theta\cos\theta'\int_0^{2\pi}d\phi'=0+2\pi\cos\theta\cos\theta'$$
Integrating now over $\cos\theta'$ you get:
$$\int_0^1d(\cos\theta')2\pi\cos\theta\cos\theta'=2\pi\cos\theta\frac{1}{2}$$
Therefore you get the final answer as $$\int_0^{2\pi}d\phi'\int_0^1d(\cos\theta')\cos\gamma=\pi\cos\theta$$
