\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{enumerate}
\usepackage{ifthen}
\usepackage{ulem} % for strikethrough \sout{...} command
\usepackage{color}
\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{-0.5in}
\setlength{\headheight}{0.0in}
\setlength{\headsep}{0.0in}
\setlength{\topskip}{0.0in}
\setlength{\textheight}{9.5in}
\setlength{\textwidth}{7.5in}

\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usepackage{tikz}
\usepgfplotslibrary{fillbetween}

%\newcommand{\bdot}{\, {\bf \cdot} \,}
\newcommand{\bdot}{\, {\scriptstyle{\bullet}} \,}
\newcommand{\B}[1]{{\bf {#1}}}
\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}

\newcommand{\force}{{$\mbox{\;}$}}

\begin{document}

\pagestyle{empty}

\noindent
\fbox{\parbox{7.4in}{\parbox{1.5in}{\bf Math 2130} \hfill \parbox{3in}{\LARGE\bf\force\hfill Verifying Stokes \hfill\force} \hfill \parbox{1.5in}{\force\hfill\bf Example}}}

\vspace{0.15in}

\noindent
Consider the upper hemisphere $S_1$: $x^2+y^2+z^2=9$, $z\geq 0$ oriented upward. Also, let $\B F(x,y,z) = \langle z,x,x^2+y^2+z^2\rangle$. 

\vspace{0.1in}

\noindent
\parbox{1.25in}{We want to show:\\ \force\\} \qquad $\displaystyle \begin{array}{ccc} \displaystyle \iint_{S_1} (\nabla \times {\bf F}) \bdot {\bf n}\,d\sigma & = & \displaystyle \int_{\partial S_1} {\bf F} \bdot d{\bf r} \\ \vspace{0.15in} \text{\bf II.} & & \text{\bf \quad I.} \end{array}$

\vspace{-1.25in}

\force\hfill
\begin{tikzpicture}[scale=1]
\begin{axis}[
  axis x line=none, axis y line=none,
  width=3in, height=3.5in,     % size of the image
  ymin=-0.75, ymax=2, ytick={0}, ylabel=${}$,
  xmin=-1.25, xmax=1.5, xtick={0}, xlabel=${}$,
]

\draw (axis cs:{1.65*1*cos(60)},{1.65*0.25*sin(60)})--(axis cs:{1*cos(240)},{0.25*sin(240)});
\draw (axis cs:{1*cos(180)},{0.25*sin(180)})--(axis cs:{1*cos(0)},{0.25*sin(0)});
\draw (axis cs:0,0)--(axis cs:0,0.95);

\addplot[thick,name path=A, domain=0:180] ({1*cos(x)},{0.25*sin(x)});
\addplot[ultra thick,name path=B, domain=180:360] ({1*cos(x)},{0.25*sin(x)});
\addplot[name path=C, domain=0:180] ({1*cos(x)},{0.95*sin(x)});
\addplot[green!60] fill between[of=B and C];

\addplot[ultra thick,name path=B, domain=200:300,->] ({1*cos(x)},{0.25*sin(x)});

\draw[thick,->] (axis cs:{1*cos(240)},{0.25*sin(240)})--(axis cs:{1.65*1*cos(240)},{1.65*0.25*sin(240)});
\draw[thick,->] (axis cs:{1*cos(0)},{0.25*sin(0)})--(axis cs:{1.3*1*cos(0)},{1.3*0.25*sin(0)});
\draw[thick] (axis cs:{1*cos(180)},{0.25*sin(180)})--(axis cs:{1.3*1*cos(180)},{1.3*0.25*sin(180)});
\draw[thick,->] (axis cs:0,0.95)--(axis cs:0,1.2);

\draw[ultra thick,->] (axis cs:-0.3,0.7)--(axis cs:-0.55,1.25);

\addplot[thick, domain=-20:280,->] ({0.15*cos(12)*cos(x)+0.1*sin(12)*sin(x)-0.3},{0.15*cos(12)*sin(x)+0.1*sin(12)*cos(x)+0.7});

\node at (axis cs:0.3,0.6) {$S_1$};

\node at (axis cs:-0.7,1.175) {${\bf n}$};

\node at (axis cs:0.75,-0.35) {$\partial S_1$};

\node at (axis cs:{1.65*1*cos(240)-0.0975},{1.65*0.25*sin(240)+0.05}) {$x$};
\node at (axis cs:{1.3*1*cos(0)-0.1},{1.3*0.25*sin(0)-0.1}) {$y$};
\node at (axis cs:0.125,1.2) {$z$};

\end{axis}
\end{tikzpicture}

\vspace{-1.75in}

\noindent {\large\bf I.} \quad  The boundary of $S_1$ (i.e., $\partial S_1$) is the circle $x^2+y^2=9$ and $z=0$ (i.e., the\\ intersection of the hemisphere with the $xy$-plane). Considering the  orientation for\\ our surface, the orientation of this circle is counter-clockwise (consider someone\\ walking near the edge on top of $S_1$ trying to keep the surface to their left). 

\noindent
\begin{tikzpicture}[scale=0.55]
\begin{axis}[
  axis x line=middle, axis y line=middle,
  width=3in, height=3in,     % size of the image
  ymin=-1.25, ymax=1.25, ytick={0}, ylabel=${}$,
  xmin=-1.25, xmax=1.25, xtick={0}, xlabel=${}$,
]

\addplot[ultra thick,domain=-420:40,->,smooth] ({cos(x)},{sin(x)});

\node at (axis cs:0.9,0.9) {\LARGE $\partial S_1$};

\node at (axis cs:1.1,-0.15) {\large $x$};
\node at (axis cs:-0.15,1.1) {\large $y$};
\end{axis}
\end{tikzpicture}
 
\vspace{-1.3in}

\force \hspace*{1.25in}
\parbox{3.35in}{We can parameterize the circle as follows:\\ $\partial S_1$: ${\bf r}(t) = \langle 3\cos(t), 3\sin(t), 0 \rangle$ where $0 \leq t \leq 2\pi$. This is properly oriented since our standard parameterization goes counter-clockwise ($\partial S_1$ should be counter-clockwise oriented).}

\force\hspace*{1.25in}
\parbox{5.9in}{Thus ${\bf r}'(t) = \langle -3\sin(t),3\cos(t),0\rangle$ and so $\displaystyle \int_{\partial S_1} {\bf F} \bdot d{\bf r} = \int_0^{2\pi} \langle 0,3\cos(t),9 \rangle \bdot \langle -3\sin(t),3\cos(t),0\rangle\,dt$ since (from our parameterization ${\bf r}(t)$) we have $z(t)=0$, $x(t)=3\cos(t)$, and $x(t)^2+y(t)^2+z(t)^2=9+0=9$.}  

Simplifying,  we find that $\displaystyle \int_{\partial S_1} {\bf F}\bdot d{\bf r} = \int_0^{2\pi} 9\cos^2(t)\,dt = \int_0^{2\pi} \dfrac{9}{2}\Big(1+\cos(2t)\Big)\,dt = \dfrac{9}{2}t+\dfrac{9}{4}\sin(2t) \,\Bigg|_0^{2\pi} =$ \fbox{$9\pi$}

\vspace{0.15in}

\noindent {\large\bf II.} \quad First, we will compute the curl of our vector field: $\displaystyle \nabla \times {\bf F} = \begin{vmatrix} {\bf i} & {\bf j} & {\bf k} \large\strut \\ \frac{\partial}{\partial x} & \frac{\partial}{\partial y} & \frac{\partial}{\partial z} \large\strut \\ z & x & x^2+y^2+z^2 \large\strut \end{vmatrix} = \langle 2y-0,-(2x-1),1-0\rangle$.

\vspace{-0.1in}

Thus $\nabla \times {\bf F} = \langle 2y,1-2x,1\rangle$. 

Next, using spherical coordinates, see that our hemisphere is $\rho^2=9$ (i.e., $\rho=3$) with $0 \leq \theta \leq 2\pi$ and $0 \leq \varphi \leq \pi/2$ (since $z \geq 0$). Thus we get the parameterization for $S_1$: ${\bf r}(\varphi,\theta) = \langle 3\cos(\theta)\sin(\varphi), 3\sin(\theta)\sin(\varphi), 3\cos(\varphi) \rangle$. We then need to find the ``derivative'' of our parameterization:

$\displaystyle {\bf r}_{\varphi} \times {\bf r}_{\theta} =\begin{vmatrix} \  {\bf i} \  \  {\bf j} \  \  {\bf k} \  \large\strut \\ {\bf r}_\varphi \large\strut \\ {\bf r}_\theta \large\strut \end{vmatrix} =  \begin{vmatrix} {\bf i} & {\bf j} & {\bf k} \large\strut \\  3\cos(\theta)\cos(\varphi) & 3\sin(\theta)\cos(\varphi) & -3\sin(\varphi) \large\strut \\ -3\sin(\theta)\sin(\varphi) & 3\cos(\theta)\sin(\varphi) & 0 \large\strut \end{vmatrix} = \langle 9\cos(\theta)\sin^2(\varphi), 9\sin(\theta)\sin^2(\varphi), 9\sin(\varphi)\cos(\varphi) \rangle$

Note that $\sin(\varphi)$ and $\cos(\varphi)$ are non-negative when $0 \leq \varphi \leq \pi/2$, so the ${\bf k}$-component of ${\bf r}_\varphi \times {\bf r}_\theta$ is non-negative. This means that our ``derivative'' matches the required upward orientation. Also, recall that ${\bf n}\,d\sigma = \pm \frac{{\bf r}_\varphi \times {\bf r}_\theta}{|{\bf r}_\varphi \times {\bf r}_\theta|} \, |{\bf r}_\varphi \times {\bf r}_\theta|\,dA = \pm {\bf r}_\varphi \times {\bf r}_\theta\,dA$ (we keep the $+$). Plugging in our parameterization in we get $(\nabla \times {\bf F})({\bf r}(\varphi,\theta)) = \langle 2\cdot 3\sin(\theta)\sin(\varphi), 1-2\cdot 3\cos(\theta)\sin(\varphi), 1 \rangle$ since $x(\varphi,\theta) = 3\cos(\theta)\sin(\varphi)$ and $y(\varphi,\theta) = 3\sin(\theta)\sin(\varphi)$. Putting this altogether we get:

$$\iint_{S_1} (\nabla \times {\bf F}) \bdot {\bf n}\,d\sigma = \int_0^{2\pi}\int_0^{\pi/2} \langle 6\sin(\theta)\sin(\varphi), 1-6\cos(\theta)\sin(\varphi), 1 \rangle \bdot  \langle 9\cos(\theta)\sin^2(\varphi), 9\sin(\theta)\sin^2(\varphi), 9\sin(\varphi)\cos(\varphi) \rangle\,d\varphi\,d\theta$$ 

$$=  \int_0^{2\pi}\int_0^{\pi/2} \Big( 54\sin(\theta)\cos(\theta)\sin^3(\varphi)+9\sin(\theta)\sin^2(\varphi)-54\sin(\theta)\cos(\theta)\sin^3(\varphi)+9\sin(\varphi)\cos(\varphi)\Big)\,d\varphi\,d\theta$$

$$=  \int_0^{\pi/2}\int_0^{2\pi} \Big( 9\sin(\theta)\sin^2(\varphi)+9\sin(\varphi)\cos(\varphi)\Big)\,d\theta\,d\varphi = \int_0^{\pi/2}\int_0^{2\pi} \Big( 0+9\sin(\varphi)\cos(\varphi)\Big)\,d\theta\,d\varphi$$

$$=\int_0^{\pi/2} 18\pi \sin(\varphi)\cos(\varphi)\,d\varphi = 9\pi \sin^2(\varphi) \Bigg|_0^{\pi/2} = \mbox{\fbox{$9\pi$}}$$

\noindent
{\it Calculation Notes:} First, we simplified (computing the dot product and then canceling terms). Next, after changing the order of integration, we note that $\sin(\theta)$ integrated over the interval $[0,2\pi]$ yields an answer of $0$. Then, the inner integral is constant with respect to theta, so we just multiply by the length of the interval (i.e., $2\pi$). Finally, the last integral is done with a simple substitution: $u=\sin(\varphi)$ so $du=\cos(\varphi)\,d\varphi$.

\vspace{0.05in}

\noindent
Therefore, both the flux and line integral calculations yield the same answer (as they must).


\end{document}


