I want to find the distance between two points in spherical coordinates, so I want to express $||x-x'||$ where $x=(r,\theta, \phi)$ and $x' = (r', \theta',\phi')$ by the respective components. Is this possible? I just know that this is $\sqrt{r^2+r'^2-2rr'\cos(\theta- \theta')}$ if $\phi,\phi'$ is the same, but what is the most general distance?
Distance between two points in spherical coordinates
78.8k Views Asked by user66906 https://math.techqa.club/user/user66906/detail AtThere are 3 best solutions below
On
You have simply to write it in Cartesian coordinates and change variables: $x=r\sin(\theta)\cos(\phi)$, $y=r\sin(\theta)\sin(\phi)$, $z=r\cos(\theta)$ $$\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}=$$$$=\sqrt{r^2+r'^2-2rr'\left[\sin(\theta)\sin(\theta')\cos(\phi)\cos(\phi')+\sin(\theta)\sin(\theta')\sin(\phi)\sin(\phi')+\cos(\theta)\cos(\theta')\right]}$$ But I don't see a way to really improve this mess.
On
Building on the answer from @[David H], I wrote the distance in a way that highlights the difference in angles: $$ ||\vec r_1 - \vec r_2|| = \sqrt{ {r_1}^2 + {r_2}^2 - 2\, r_1 r_2 \cos(\theta_1 - \theta_2) - 2\, r_1 r_2 \sin \theta_1 \sin \theta_2 \left( \cos(\phi_1 - \phi_2) - 1 \right) } $$ It highlights the contributions from the difference in polar angle $\theta$ and the difference in the azimuthal angle $\phi$, (third and fourth terms, respectively, under the square root symbol). Note the intuitive scaling of the azimuthal contribution by $\sin \theta_1 \sin \theta_2$. Of course, when the angular differences are both $0$, the distance reduces to $||r_1-r_2||$.
The expression of the distance between two vectors in spherical coordinates provided in the other response is usually expressed in a more compact form that is not only easier to remember but is also ideal for capitalizing on certain symmetries when solving problems.
$$\begin{align} \|\mathbf{r}-\mathbf{r}^\prime\| &=\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\cos(\phi)\cos(\phi')}+\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\sin(\phi)\sin(\phi')}+\cos(\theta)\cos(\theta')\right]}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\left(\cos(\phi)\cos(\phi')+\sin(\phi)\sin(\phi')\right)}+\cos(\theta)\cos(\theta')\right]}\\ &=\sqrt{r^2+r'^2-2rr'\left[\color{red}{\sin(\theta)\sin(\theta')}\color{blue}{\cos(\phi-\phi')}+\cos(\theta)\cos(\theta')\right]}.\\ \end{align}$$
This form makes it fairly transparent how azimuthal symmetry allows you to automatically eliminate some of the angular dependencies in certain integration problems. Another advantage of this form is that you now have at least two variables, namely $\phi$ and $\phi'$, that appear in the equation only once, which can make finding series expansions w.r.t. these variables a little less of a pain than the others.