# Aligning dot product with spherical coordinates for integrals

I am slightly doubting something I have always thought obvious at the moment. Consider two vectors $$\vec{a},\vec{b}$$ in $$\mathbb{R}^3$$. We know that $$\vec{a}\cdot\vec{b} = |\vec{a}||\vec{b}|\cos\gamma$$, where $$\gamma$$ is the angle between the two vectors. I use $$\gamma$$ to distinguish it from spherical coordinates. Clearly, in general $$\gamma$$ has nothing to do with polar or azimuthal angles $$\theta,\phi$$ in spherical coordinates, since in general $$\gamma$$ will depend on $$\theta_a,\theta_b,\phi_a,\phi_b$$, the angular coordinates of each vector.

Now suppose I wish to do integrals of the form \begin{align} I = \int d^3x\, f((\vec{x}-\vec{a})^2)\,. \end{align} One simple case would be e.g. when $$f$$ is Gaussian. In spherical coordinates, my volume element will be $$d^3x = r^2\sin\theta\,dr\,d\theta\,d\phi$$. Now, I always thought that I could now do the following: \begin{align} (\vec{x}-\vec{a})^2 = |\vec{x}|^2+|\vec{a}|^2-2|\vec{x}||\vec{a}|\cos\gamma \end{align} and the integral is straightforward. However, now this looks like I will have to need $$\vec{a}$$ to be along the $$z$$-axis in order for $$\gamma$$ to be the same as the $$\theta$$ in the volume element, which then can be straightforwardly integrated (crucially, it does not depend on $$\phi$$). Does that mean that if $$\vec{a}$$ is not along the $$z$$-direction, I cannot do this (i.e. $$\phi$$-independent integral)? The fact that the integral depends on the distance $$|\vec{x}-\vec{a}|$$ seems to me implying that I could always set $$\gamma=\theta$$ even if $$\vec{a}$$ is not along the $$z$$-axis.

• If you are prepared to specify the domain of integration in a new coordinate system you can essentially re-coordinatize however you want. For example, you could use spherical coordinates in which the azimuthal angle measures declination relative to the vector $\vec{a}$, and define the polar angle accordingly. Or even better, you could use spherical coordinates centered around $\vec{a}$ so that $f((\vec{x}-\vec{a})^2)$ becomes $f(r^2)$. Both of these coordinatizations will use essentially the same volume element as spherical coordinates. – subrosar Aug 11 '19 at 5:33

$$\gamma$$ does depends on $$(\theta,\phi)$$ and, in the general case where $$\vec{a}$$ is not in the $$z$$-direction, you may not replace $$\gamma$$ with $$\theta$$.
To see so, suppose the orientation of $$\vec{a}$$ is $$(\theta_a$$, $$\phi_a)$$, you should decompose the vectors along three perpendicular directions and express the squared distance $$d^2$$ as,
$$(\vec{x}-\vec{a})^2=(r\sin\theta\cos\phi-a\sin\theta_a\cos\phi_a)^2 + (r\sin\theta\sin\phi-a\sin\theta_a\sin\phi_a)^2 + (r\cos\theta-a\cos\theta_a)^2 =d^2(r,\theta,\phi)$$
As a result, $$\gamma$$ depends on $$\theta$$ and $$\phi$$ according to, $$\cos\gamma= \frac{d^2(r,\theta,\phi)-r^2-a^2}{2ar}$$
As can be seen from the expression, $$\gamma$$ depends on both $$\theta$$ and $$\phi$$ in a complex way. You may not simply replace $$\gamma$$ it with $$\theta$$. The resulting integration could be fairly iterative and may not be easy to perform.