<s>[INST] Finding $\int_S z\,dS$ where $S=\left\{ \big(x,y,z\big):x^2+y^2+z^2=a^2,z\ge 0, a>0\right\}$ $$\int_Sz\,dS$$
$$S=\big\{ \big(x,y,z\big):x^2+y^2+z^2=a^2,z\ge 0, a>0\big\}$$

I've already calculate this surface integral " by hand " :
$$z=\sqrt{a^2-x^2-y^2}\text{, thus,}$$
$$\int_SzdS=\int\int_{x^2+y^2\le a^2}\sqrt{a^2-x^2-y^2}\cdot\bigg(\sqrt{1+z_x^2+z_y^2}\bigg)dxdy$$
$$=\int_SzdS=\int\int_{x^2+y^2\le a^2}\sqrt{a^2-x^2-y^2}\cdot\bigg(\sqrt{\frac{a^2}{a^2-x^2-y^2}}\bigg)dxdy=\int_SzdS=\int\int_{x^2+y^2\le a^2}adxdy=a^3\pi.$$

I want to prove it by using the Gauss divergence theorem, but im making a mistake somewhere:
$$\text{Let } F=(F_1,F_2,F_3),$$
$$\text{And i want  to find the unit normal vector $\hat n$ of $S$ }$$
$$\hat n =\frac{\nabla f}{\lvert \nabla f \rvert}\text{, where } f:=x^2+y^2+z^2-a^2$$
$$\text{we get: }\hat n=\big(\frac{x}{a},\frac{y}{a},\frac{z}{a}\big)\quad \text{ we want:}$$
$$F\cdot\hat n=z \Rightarrow F_1=F_2=0,F_3=a$$
$$\Rightarrow \nabla \cdot F=0+0+0=0$$
$$\text{but obviously } \int_S zdS\ne 0$$
What am i doing wrong?
thank you.

 [/INST] With the same trick, you can use Stokes' theorem in one of two ways. First is directly:
$$\nabla \times H = (0,0,a) \to H = (0,ax,0)$$
which gives us the line integral
$$\int\limits_{x^2+y^2=a^2\:\cap\:z=0}(0,ax,0)\cdot dr = a^3\int_0^{2\pi}\cos^2 t\:dt = \pi a^3$$
Or we can use a corollary of Stokes' theorem, which says that we can shift the surface integral over to another surface that shares the same boundary as the original (Think distorting a bubble when you blow it from a hoop). In this case we can say that
$$\iint\limits_{x^2+y^2+z^2=a^2\:\cap\:z\geq 0}(0,0,a)\cdot dS = \iint\limits_{x^2+y^2\leq a^2\:\cap \:z=0}(0,0,a)\cdot dS = a\iint\limits_{x^2+y^2\leq a^2}\;dA = \pi a^3$$
</s>