# Taylor expansion of $\frac {1}{|x-y|}$with x and y two vectors

This equation comes from a physics script on electrodynamics, saying that this equation comes from a Taylor series expansion. I understand the first equality, but not the second one. It is really not clear for me how the second equality relates to Taylor series.

I try to make sense out of this but I'm stuck. I saw this post exactly about this problem, but there is no explanation on how we find this Taylor expansion.

If $$\theta$$ is the angle between $$\vec{r}$$ and $$\vec{x}$$, then $$\frac{1}{\sqrt{r^2+x^2-2\vec{r}\cdot\vec{x}}} = (r^2+x^2-2rx\cos\theta)^{-1/2} =\frac{1}{r}\left(1+\frac{x^2}{r^2} - 2\frac{x}{r}\cos\theta \right)^{-1/2}$$ Use the Taylor series $$(1+z)^{-1/2} = 1 -\frac{1}{2}z + O(z^2)$$ as $$z \to 0$$.
Then as $${x/r} \to 0$$ we get $$\frac{1}{\sqrt{r^2+x^2-2\vec{r}\cdot\vec{x}}} = \frac{1}{r}\left(1 - \frac{1}{2}\left(- 2\frac{x}{r}\cos\theta\right) +O\left(\frac{x^2}{r^2}\right)\right) = \frac{1}{r} + \frac{x}{r^2}\cos\theta +O\left(\frac{x^2}{r^3}\right) \\= \frac{1}{r} + \frac{\vec{x}\cdot\vec{r}}{r^3} +O\left(\frac{x^2}{r^3}\right)$$
The OP did not say whether $$x/r \to 0$$ or $$x/r \to \infty$$. But if $$\infty$$, then we get a different answer, so it must mean $$0$$.