Volume integral vs Volume I have to calculate the divergence of an electric field and the charge in a cylindrical space ($r=3$, $z=3$).
So the correct way of doing it would be taking a volume integral of that field as it's shown below:
$$\int_V \nabla\cdot E\,dV=\int_0^3\int_0^{2\pi}\int_0^3(90r-5)r\,drd\phi dz$$
where $90r-5$ is $\nabla\cdot E$.
Now, this may sound stupid, but why cannot I just multiply the field $E$ by the volume of the cylinder e.g. $( \nabla\cdot E   \pi  r^2  z )$ ?
 A: First, since you're integrating the divergence of $E$, using $E$ itself would not make sense.
Second, as long as the divergence is not constant, well, you can't pull it out of the integral.  You're basically suggesting you should be able to pull something out of the integral so that you can rewrite it as $(\nabla \cdot E) \int 1 \, dV$.  You can only do this if the divergence is constant--if it doesn't depend on any of the integration variables $r, \phi, z$.
In short, how could you do this...
$$\int_V \rho(r, \phi z) \, r \, dr \, d\phi \, dz \to \rho(r, \phi, z) \int_V r \, dr \, \phi \, dz$$
...if integrating completely removes all dependence on $r, \phi, z$?  You can't pull something out that depends on integration variables.  That's the problem.
In your particular problem, however, you can use the divergence theorem to convert this volume integral into a surface integral.  Then, you integrate $E$ directly on the surface of the cylinder.  This can be convenient because then, for example, $E \cdot \hat n$ may be constant on the curved wall of the cylinder (this is often the case in problems involving cylindrical symmetry).
A: I honestly don't understand why you think what you're saying might be the right answer. Someone has told you you cant take the divergence out because it's not constant, but you're not taking the divergence but the field instead. That would give an expression dependent of coordinates (as I guess E is not constant in space). That quantity is nothing, it's just the field itself multiplied by an arbitrary constant tht happens to be the volume of a cylinder.
The right way to do it, knowing that the divergence of E is the charge density divided by $\epsilon_0$, then:
$\epsilon_0\int_V\nabla\cdot E=\int_V\rho=Q$
I suppose you know that the integral of the charge density $\rho$ to the volume is the charge. 
You know the value of the divergence of E so you're done. Take into acount, for another problems, that if your system has point charges, then the divergence of E will go up to infinity in those points and you won't be able to integrate, so you can look for some gaussian surface and use the gauss theorem:
$\int_V\nabla\cdot E=\int_{\partial V}E$
being $\partial V$ the surface that's the limit to the volume.
Hope it helped.
