# Vector valued integral in spherical coordinates

Whenever I have been presented with integrals as (*), I have always used some sort of symmetry to get around actually calculating the integral. Now it just struck me that I have no idea how to "mechanically" calculate (*):

$$\iiint \left(f(r)\hat{r}\right)\left(r^2\sin\phi\right) drd\phi d\theta \qquad \textbf{(*)}$$ If it is necessary to define what region you are talking about for the question to make sense, I'll pick the unit sphere.

Would this have been the integral $$\int f(x)\hat{x} dx$$ I would have proceeded by moving the unit vector outside of the integral and calculated as usual

$$\hat{x}\int f(x)\cdot dx = \hat{x}\left(F(x) +C\right)$$

However, the problem with the integral is that the direction of $\hat{r}$ changes as $\phi$ and $\theta$ changes. Therefore I don't see how I could treat the unit vector as a constant and have no idea how to start with (*).

I apologize in advance if this turns out to be a duplicate. How to integrate a vector function in spherical coordinates? verifies my gut feeling that $\hat{r}$ is not constant but doesn't make things much clearer for me than that.

• But the unit vector $\hat x$ likewise changes with $x$? Why can you take it outside the integral? – joriki Aug 24 '15 at 16:25
• I am having a hard time understanding how that could be. In a Cartesian coordinate system, I would have thought that $\hat{x}$ never changes. It points in the same direction all the time. – V.Vocor Aug 24 '15 at 16:34
• Then perhaps you're using some other convention. Under the convention that I was applying, $\hat x$ is the unit vector that points along the position vector $x$. Clearly the position vector $x$ doesn't always point in the same direction. – joriki Aug 24 '15 at 16:39
• I meant for $\hat{x}$ to be the direction of the x-axis in a fixed coordinate system. If there's is a less confusing way for me to write that, please, let me know. – V.Vocor Aug 24 '15 at 16:45
• Makes sense. My way is unnecessarily ambiguous. I'll try to adopt your approach in the future. Thank you, again. – V.Vocor Aug 24 '15 at 17:07

Since $\hat{\mathbf{r}} = \sin\theta\cos\phi\,\hat{\mathbf{x}} + \sin\theta\sin\phi\,\hat{\mathbf{y}} + \cos\theta\,\hat{\mathbf{z}}$, you can write
$$\iiint f(r)\,\hat{\mathbf{r}}\,r^2\sin\theta\,dr\,d\phi\,d\theta = \iiint f(r) \left(\sin\theta\cos\phi\,\hat{\mathbf{x}} + \sin\theta\sin\phi\,\hat{\mathbf{y}} + \cos\theta\,\hat{\mathbf{z}}\right)r^2\sin\theta\,dr\,d\phi\,d\theta$$ which is the sum of three separate integrals: $$\hat{\mathbf{x}} \iiint f(r)\sin\theta\cos\phi\,r^2\sin\theta\,dr\,d\phi\,d\theta = \hat{\mathbf{x}} \int f(r)\,r^2\,dr \int\sin^2\theta\,d\theta \int\cos\phi\,d\phi$$ $$\hat{\mathbf{y}}\iiint f(r)\,\sin\theta\sin\phi\,r^2\sin\theta\,dr\,d\phi\,d\theta = \hat{\mathbf{y}} \int f(r)\,r^2\,dr \int\sin^2\theta\,d\theta \int\sin\phi\,d\phi$$ $$\hat{\mathbf{z}}\iiint f(r)\,\cos\theta\,r^2\sin\theta\,dr\,d\phi\,d\theta = \hat{\mathbf{z}} \int f(r)\,r^2\,dr \int\sin\theta\cos\theta\,d\theta \int d\phi$$
where $\hat{\mathbf{r}}$ is the unit vector along the radial direction but $\hat{\mathbf{x}}$, $\hat{\mathbf{y}}$, and $\hat{\mathbf{z}}$ are the Cartesian unit vectors.
(Note that I'm using the convention where the volume element is $r^2\sin\theta\,dr\,d\phi\,d\theta\,$.)