$\iint_S$ r.n $dS$
Over the surface of the sphere with radius $a$ centered at the origin
Now this is obviously trivial and the answer is $4\pi a^3$ but I want to do it the hard way because there's something I don't understand
The surface is $x^2 + y^2 + z^2 = a^2$ , then the normal vector $n = \nabla S$
$\hat n$ = $\frac{\nabla S}{|\nabla S|}$ = $\frac{x \hat i + y \hat j + z \hat k}{a}$
$dS = \frac{dxdy}{|\hat n . \hat k|} = \frac{dxdy}{a/z}$
Then $\iint_S$ r.n $dS$ = $\iint_S \frac{x^2 + y^2}{\sqrt{a^2 -x^2 -y^2}} + \sqrt{a^2 -y^2 -x^2}$ $dxdy$
Switching to polar coordinates, $x=\rho cos\phi , y =\rho \sin\phi$
Then $\iint_S$ r.n $dS$ = $\iint_S \frac{\rho^2}{\sqrt{a^2 -\rho^2}} + \sqrt{a^2 - \rho^2}$ $\rho d\rho d\phi$
Integrating $\rho$ from $0$ to $a$ and $\phi$ from $0$ to $2\pi$ , we get:
$\iint_S$ r.n $dS$ = $2\pi a^3$ which is half the required answer $4\pi a^3$ , is it because I only took into account that $dS = \frac{dxdy}{|\hat n . \hat k|} = \frac{dxdy}{a/z}$ and should have changed this surface element starting from a specific point? If so, how? Thanks
notice that $$\vec r \cdot \vec n = \frac{x^2+y^2+z^2} a = \frac {a^2} a = a$$
which is a constant so can be taken outside the integral
so $$\iint_S \vec r \cdot \vec n \;dS = a \iint_S \;dS $$