I want to calculate the volume of Viviani's set. The set is defined as $Z:=\{(x,y,z)\in\mathbb{R}^3 | x^2+y^2+z^2\leq R^2, x^2+y^2\leq Rx\}$.
My approach is to use $\int_0^R\int_0^\sqrt{Rx-x^2} \sqrt{R^2-x^2-y^2} \,dy\,dx$ and then transform it to cylinder coordinates $(r,\varphi)$ with $x=r\cos(\varphi)$ and $y=r\sin(\varphi)$.
The equation $x^2+y^2\leq Rx$ is equivalent to $r^2\leq R \cos(\varphi)$ or $|r|\leq\sqrt{\cos(\varphi)}$. So I get the Integral $\int_0^{2\pi}\int_{0}^{\sqrt{R\cos(\varphi)}}\sqrt{R-r^2}r \,d r\,d\varphi$. But the correct answer is $2\int_0^{\pi}\int_0^{R\cos(\varphi)}\sqrt{R-r^2}r\,dr\,d\varphi$.
Why do I have to integrate from $0$ to $R\cos(\varphi)$ instead from $0$ to $\sqrt{R\cos(\varphi)}$?
The mistake lies in the fact that you have missed an $r$ due to the $x$ factor on the RHS. Instead, you have to consider $$x^2+y^2 \leq Rx \Rightarrow (r\cos \phi)^2+(r\sin \phi)^2 \leq Rr\cos \phi \Rightarrow r^2\leq Rr\cos \phi \Rightarrow r\leq R\cos \phi$$ Hope it helps.