Divergence theorem example I have this problem:

Verify the divergence theorem $$
\oint_{S} \mathbf{A} \cdot d \mathbf{S}=\int_{v} \nabla \cdot \mathbf{A} d v$$ for the following case: $\mathbf{A}=2 \rho z \mathbf{a}_{\rho}+3 z \sin \phi \mathbf{a}_{\phi}-4 \rho \cos \phi \mathbf{a}_{z}$ and $S$ is the surface of the wedge $0<\rho<2$, $0<\phi<45^{\circ}=\pi/4, 0<z<5$

So, I have solved both sides of the equation:
\begin{align*}
                \oint_{S} \mathbf{A} \cdot d \mathbf{S} &=\oint_{S} \left(2 \rho z ,+3 z \sin \phi ,-4 \rho \cos \phi\right)\cdot \left(\rho d\phi dz,d\rho dz, \rho d\phi d\rho\right)\\
                &= \oint_{S} \left(2 \rho z\rho d\phi dz +3 z \sin \phi d\rho dz -4 \rho \cos \phi \rho d\phi d\rho\right)\\
                &= \left(\iint_{\rho=0}+\iint_{\rho=2}+\iint_{\phi=0}+\iint_{\phi=\pi/4}+\iint_{z=0}+\iint_{z=5}\right)\\
                & \ \ \ \ \left(2 \rho^2 z d\phi dz + 3 z \sin \phi d\rho dz -4 \rho^2 \cos \phi d\phi d\rho\right)\\
                &=\iint_{\rho=2}2 \rho^2 z d\phi dz +\iint_{\phi=\pi/4} 3 z \sin \phi d\rho dz+\\
                & \ \ \ \ +\iint_{z=0}-4 \rho^2 \cos \phi d\phi d\rho+\iint_{z=5}-4 \rho^2 \cos \phi d\phi d\rho\\
                &= 8\int_{0}^{\pi/4}d\phi \int_0^5 zdz+\frac{3}{\sqrt{2}}\int_{0}^{5}zdz \int_{0}^{2}d\rho -8\int_0^2 \rho^2 d\rho \int_{0}^{\pi/4}\cos \phi d\phi\\
                &= 8\left(\frac{\pi}{4}\right)\left(\frac{5^2}{2}\right)+\frac{3}{\sqrt{2}}\left(\frac{5^2}{2}\right)\left(2\right)-8\left(\frac{2^3}{3}\right)\left(\sin\left(\frac{\pi}{4}\right)-\sin 0\right)\\
                &=25\pi +\frac{75}{\sqrt{2}}-\frac{64}{3\sqrt{2}}\\
                &= 25\pi +\frac{1}{\sqrt{2}}\left(\frac{75*3-64}{3}\right)\\
                &= 25\pi +\frac{1}{\sqrt{2}}\left(\frac{161}{3}\right)\\
            \end{align*}
and
\begin{align*}
                \int_{v} \nabla \cdot \mathbf{A} d v &=\int_v \left(\frac{1}{\rho} \frac{\partial}{\partial \rho}\left(\rho A_\rho\right)+\frac{1}{\rho} \frac{\partial A_\phi}{\partial \phi}+\frac{\partial A_z}{\partial z}\right)\rho d\rho d\phi dz\\
                &=\int_v \left(\frac{1}{\rho} \frac{\partial}{\partial \rho}\left(2\rho^2z\right)+\frac{1}{\rho} \frac{\partial (3z\sin \phi)}{\partial \phi}+\frac{\partial (-4\rho \cos\phi)}{\partial z}\right)\rho d\rho d\phi dz\\
                &= \int_v \left(4z+\frac{3z\cos\phi}{\rho}+0\right)\rho d\rho d\phi dz\\
                &= \int_v \left(4\rho z+3z\cos\phi\right) d\rho d\phi dz\\
                &= 4\int_{0}^{2}\rho d\rho\int_{0}^{\pi/4}d\phi  \int_0^5 zdz +3\int_{0}^{2}d\rho \int_{0}^{\pi/4}\cos\phi d\phi \int_0^5 zdz\\
                &= 4\left(\frac{2^2}{2}\right)\left(\frac{\pi}{4}\right)\left(\frac{5^2}{2}\right)+3\left(2\right)\left(\sin\left(
                    \frac{\pi}{4}
                \right)\right)\left(\frac{5^2}{2}\right)\\
                &= 25\pi +\frac{150}{2\sqrt{2}}
            \end{align*}
However, I didn't get same results, do you know where is the error and why? Maybe I have missed some basic property.
I think is something related to
$$\iint_{z=0}-4 \rho^2 \cos \phi d\phi d\rho+\iint_{z=5}-4 \rho^2 \cos \phi d\phi d\rho$$
but how am I justify those expressions cancel out each other?

On the $z = 0$ surface, the normal vector is $-\hat{z}$, not $\hat{z}$. That means that you should have
\begin{eqnarray}
&=&\iint_{\rho=2}2 \rho^2 z d\phi dz +\iint_{\phi=\pi/4} 3 z \sin \phi d\rho dz\\
                & &\ \ \ \ \color{red}{-} \iint_{z=0}-4 \rho^2 \cos \phi d\phi d\rho+\iint_{z=5}-4 \rho^2 \cos \phi d\phi d\rho\\
                &=& 8\int_{0}^{\pi/4}d\phi \int_0^5 zdz+\frac{3}{\sqrt{2}}\int_{0}^{5}zdz \int_{0}^{2}d\rho - \color{red}{0}
\end{eqnarray}
and then it all works out.
Note that this also applies to the $\phi = 0$ surface. The only reason you didn't run into that problem with it is that the integrand is identically 0 there.
