Divergence of a vector field in cylindrical coordinates Let $\bar{F}:\mathbb{R}^3\rightarrow\mathbb{R}^3$ be a vector field such that $\bar{F}(x,y,z)=(x,y,z)$. Then we know that:
$$\nabla\cdot\bar{F}=\frac{\partial\bar{F}_x}{\partial x}+\frac{\partial\bar{F}_y}{\partial y}+\frac{\partial\bar{F}_z}{\partial z} = 1+1+1=3$$
However, we also know that $\bar{F}$ in cylindrical coordinates equals to: $\bar{F}=(r\cos\theta,r\sin\theta,z)$, and the divergence in cylindrical coordinates is the following:
$$\nabla\cdot\bar{F}=\frac{1}{r}\frac{\partial(r\bar{F}_r)}{\partial r}+\frac{1}{r}\frac{\partial(\bar{F}_\theta)}{\partial \theta}+\frac{\partial(\bar{F}_z)}{\partial z}$$
The big question is: what are $\bar{F}_{r,\theta,z}$ ? No matter what I decide them to be, I get weird answers (using the formula above); the ones I got most frequently are $3+\frac{1}{r}$ and $3\cos\theta+1$, but I believe them both to be incorrect, since I belive the answer must be $3$: the vector fields are equivalent (I was just changing the coordinates), so their divergences also must be equivalent, am I right?
Thanks!
 A: Let's do it in general. What we need is to write a vector
$\vec{v} = v_x \hat{x} + v_y \hat{y} + v_z \hat{z}$ as
$\vec{v} = f_r \hat{r} + f_{\theta}\hat{\theta} + f_z \hat{z}$ by using the coordinate transformations
$x = r\cos \theta,\quad y=r\sin \theta,\quad z=z$
Then, $$f_{r} = \vec{v}\cdot \hat{r} = (v_x \hat{x} + v_y \hat{y} + v_z \hat{z})\cdot \hat{r}$$ $$=v_x \hat{x}\cdot \hat{r} + v_y \hat{y}\cdot \hat{r} + v_z\hat{z}\cdot \hat{r} $$ and similarly, $$f_{\theta} = \vec{v}\cdot \hat{\theta} = v_x\hat{x}\cdot \hat{\theta} + v_y \hat{y}\cdot \hat{\theta} + v_z\hat{z}\cdot \hat{\theta}$$ $$f_{z} = \vec{v}\cdot \hat{z} = v_x\hat{x}\cdot \hat{z} + v_y \hat{y}\cdot \hat{z} + v_z\hat{z}\cdot \hat{z}$$
The euclidean coordinates tell us that $\hat{x}\cdot \hat{z}= \hat{y}\cdot \hat{z} =0$ (in particular, we inmediatly get $f_z= v_z$) so we only need to compute the rest. We also can see that, since $\hat{r},\hat{\theta}$ lives in the XOY plane, $\hat{z}\cdot \hat{r} = \hat{z}\cdot \hat{\theta} = 0$.
For the others I will provide a picture 
Here, we see that $$\hat{x}\cdot \hat{r} = \cos \theta,\quad \hat{y}\cdot \hat{r} = \sin \theta$$
$$\hat{x}\cdot \hat{\theta}= \cos \left(\frac{\pi}{2}+\theta \right) = -\sin \theta,\quad \hat{y}\cdot \hat{\theta} = \cos \theta$$
Therefore:
$$f_{r} = v_x\cos \theta + v_y \sin\theta$$ $$f_{\theta} = -v_x\sin \theta + v_y \cos\theta$$ $$f_z = v_z$$

In particular for your exercise:
$$f_{r} = r\cos^2 \theta + r\sin^2 \theta = r $$ $$f_{\theta} = -r\cos\theta \sin \theta + r\sin\theta \cos\theta = 0$$ $$f_z = z$$
Hence,
$$\nabla \cdot F = \dfrac{1}{r} \dfrac{\partial}{\partial r} (r^2) + \dfrac{\partial}{\partial z} (z) = 3$$
