\classheader{2012-11-13}

Today we'll talk about calculus of several variables.

On the real line, we know
\[\int_a^b f(x)\,dx=F(b)-F(a),\qquad f=F'.\]
Note that $\{a,b\}$ is the boundary of the interval $[a,b]$.

Does this generalize to higher dimensions? That is, given some region $H$, 
%\begin{center}
%\begin{tikzpicture}[scale=2]
%\draw[thick,fill=gray!40] plot [smooth cycle] coordinates {(0,0) (0.1,0.5) (0.2,1) (1,1.2) (1.3,0.8) (1.7,0.8) (2,0.7) (2.1,0.4) (2,0) (1.5,-0.3) (0.5,-0.4)};
%\node at (1,0.3) {$H$};
%\end{tikzpicture}
%\end{center}
can we say
\[\int_H(\text{something})=\int_{\partial H}(\text{something else})\quad ?\]
Let's start with the case when $H$ is a rectangle $[a,b]\times[c,d]$,
\begin{center}
\begin{tikzpicture}[yscale=0.7]
\draw[thick,->] (0,-1) to (0,4);
\draw[thick,->] (-1,0) to (4,0);
\draw[thick,fill=gray!40] (1,1) rectangle (3,2.5);
\node at (2,1.75) {$H$};
\node at (1,0) [label=below:$a$] {};
\node at (3,0) [label=below:$b$] {};
\node at (0,1) [label=left:$c$] {};
\node at (0,2.5) [label=left:$d$] {};
\draw[thick,dotted,shorten >=2pt,shorten <=2pt] (1,0) to (1,1);
\draw[thick,dotted,shorten >=2pt,shorten <=2pt] (3,0) to (3,1);
\draw[thick,dotted,shorten >=2pt,shorten <=2pt] (0,1) to (1,1);
\draw[thick,dotted,shorten >=2pt,shorten <=2pt] (0,2.5) to (1,2.5);
\end{tikzpicture}
\end{center}
Let $F$ be a function, and $F_x$ and $F_y$ its partial derivatives. Then
\[\int F_y(x,y)\,dx\,dy=\int_a^b\left(\int_c^dF_y(x,y)\,dy\right)dx=\int_a^b(F(x,d)-F(x,c))\,dx=-\int_{\partial H} F(x,y)\,dx\]
Similarly,
\[\int G_x(x,y)\,dx\,dy=\int_c^d\left(\int_a^bg_x(x,y)\,dx\right)dy=\int_c^d(G(b,y)-G(a,y))\,dy=\int_{\partial H}G(x,y)\,dy.\]
Putting these together, if $F$, $G$, $F_y$, and $G_x$ are continuous, then
\[\int_H (G_x-F_y)\,dx\,dy=\int_{\partial H} F\,dx+G\,dy.\]
Thus, the statement is true for all rectangles $H$, and hence true for all triangles (divide a rectangle diagonally), hence true for all polygons $H$ (triangulate the polygon). This then implies it is true for all closed rectifiable curves $H$, because we can approximate them with polygons:
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[thick,fill=gray!40] plot [smooth cycle] coordinates {(0,0) (0.22,0.4) (0.2,1) (1,1.2) (1.3,0.9) (1.7,0.8) (2,0.7) (2.1,0.4) (2,0) (1.5,-0.3) (0.5,-0.4)};
\begin{scope}[shift={(1,0.3)},scale=0.95]
\begin{scope}[shift={(-1,-0.3)}]
\draw[thick,red] plot coordinates {(0,0) (0.22,0.4) (0.2,1) (1,1.2) (1.3,0.9) (1.7,0.8) (2,0.7) (2.1,0.4) (2,0) (1.5,-0.3) (0.5,-0.4) (0,0)};
\end{scope}
\end{scope}
%\draw[thick,red] plot coordinates {(0,0) (0.13,0.47) (0.2,1) (1,1.2) (1.3,0.86) (1.7,0.8) (2,0.7) (2.1,0.4) (2,0) (1.5,-0.3) (0.5,-0.36) (0,0)};
\node at (1,0.3) {$H$};
\end{tikzpicture}
\end{center}
with
\[\int_P\to\int_H,\qquad \int_{\partial P}\to\int_{\partial H}.\]
Finally, this implies it is true for all $H$ with rectifiable boundary (rectifiable means finite length).

\begin{remark}
What exactly do we mean by $\int_\gamma f\,dg$ for a curve $\gamma$? We break up $\gamma$ into smaller and smaller segments
\begin{center}
\begin{tikzpicture}[xscale=3,yscale=1.5]
\begin{scope}[decoration={markings,mark=between positions 0.1 and 0.9 step 0.1 with {\node [yshift=0.3cm] {$y_\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}$};}}] 
\draw [postaction={decorate},smooth] plot coordinates {(-0.01,0.01) (0.5,0.3) (1,1) (1.5,0.7) (2,0.1) (2.5,-0.4) (3,0.2)};
\end{scope}
\begin{scope}[decoration={markings,mark=between positions 0.1 and 0.9 step 0.1 with {\fill (0pt,0pt) circle (2pt);}}] 
\draw [postaction={decorate},smooth] plot coordinates {(-0.01,0.01) (0.5,0.3) (1,1) (1.5,0.7) (2,0.1) (2.5,-0.4) (3,0.2)};
\end{scope}
\begin{scope}[decoration={markings,mark=between positions 0.05 and 0.95 step 0.1 with {\draw (0pt,-3pt) to (0pt,3pt);}}] 
\draw [postaction={decorate},smooth] plot coordinates {(-0.01,0.01) (0.5,0.3) (1,1) (1.5,0.7) (2,0.1) (2.5,-0.4) (3,0.2)};
\end{scope}
\begin{scope}[decoration={markings,mark=between positions 0.05 and 0.95 step 0.1 with {\node [shift={(0pt,-9pt)}] {$x_{\pgfmathparse{int(subtract(\pgfkeysvalueof{/pgf/decoration/mark info/sequence number},1))}\pgfmathresult}$};}}] 
\draw [postaction={decorate},smooth] plot coordinates {(-0.01,0.01) (0.5,0.3) (1,1) (1.5,0.7) (2,0.1) (2.5,-0.4) (3,0.2)};
\end{scope}
\end{tikzpicture}
\end{center}
and then define the integral to be the limit of the quantity
\[\sum f(y_j)(g(x_j)-g(x_{j-1})).\]
\end{remark}

Given a domain $H\subseteq\R^d$ (which may have holes), 
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[thick,fill=gray!40,postaction={decorate,decoration={markings,mark=at position 0.75 with {\arrow[>=angle 90,black,scale=1]{<}}}}] plot [smooth cycle] coordinates {(0,0) (0.1,0.5) (0,1) (1,1.2) (1.5,0.8) (1.7,0.6) (2,0.6) (2.1,0.3) (2,0) (1.5,-0.3)};
\draw[thick,fill=white,postaction={decorate,decoration={markings,mark=at position 0.75 with {\arrow[>=angle 90,black,scale=1]{<}}}}] (0.5,0.5) circle (0.2);
\draw[thick,fill=white,postaction={decorate,decoration={markings,mark=at position 0.75 with {\arrow[>=angle 90,black,scale=1]{<}}}}] (1.5,0.3) circle (0.2);
\end{tikzpicture}
\end{center}
and a function $\varphi=(\varphi_1,\ldots,\varphi_d)$ on $H$, we say that a function $u:H\to\R$ is a primitive of $\varphi$ if $u$ is differentiable on $H$ and $u'=\varphi$.

Does every function have a primitive? No. Suppose $u'=(f,g)$, and that $u$ is twice differentiable; if $f=u_x$ and $g=u_y$, then
\[f_y=u_{xy}=u_{yx}=g_x.\]
Our result above implies that for any rectifiable curves $\gamma$ and $\gamma'$ with endpoints $(x_0,y_0)$ and $(x,y)$,
\begin{center}
\begin{tikzpicture}[scale=2,rotate=90]
\draw[thick,fill=gray!40] plot [smooth cycle] coordinates {(-0.3,0) (0.05,0.6) (0.2,1) (1,1.2) (1.5,0.9) (1.7,0.8) (2,0.7) (2.1,0.4) (2,0) (1.5,-0.5) (0.3,-0.7)};
\begin{scope}[every node/.style={fill,circle,inner sep=0pt,outer sep=0pt,minimum size=5pt}]
\node  [label=below right:{$(x_0,y_0)$}] (a) at (0.4,0.4) {};
\node [label=above left:{$(x,y)$}] (b) at (1.5,0)  {};
\end{scope}
\draw[thick,red] (a.center) to[out=30,in=120] node[auto] {$\gamma$} (b.center);
\draw[thick,blue] (a.center) to[out=330,in=210] node[auto,swap] {$\gamma'$} (b.center);
\begin{scope}[every node/.style={fill,circle,inner sep=0pt,outer sep=0pt,minimum size=5pt}]
\node  [label=below right:{$(x_0,y_0)$}] (a) at (0.4,0.4) {};
\node [label=above left:{$(x,y)$}] (b) at (1.5,0)  {};
\end{scope}
\end{tikzpicture}
\end{center}
we will have
\[\int_\gamma f\,dx+g\,dy=u(x,y)-u(x_0,y_0)=\int_{\gamma'}f\,dx+g\,dy.\]
Therefore, a necessary condition is that $\int_{\gamma}=0$ for any closed curve $\gamma$. When we assume everything is nice, it turns out this is also a sufficient condition.

\begin{theorem}
Given continuous $f,g$ on $H$, there is a primitive $u$ for $\varphi=(f,g)$ if and only if $\int_\gamma f\,dx+g\,dy=0$ for any closed curve $\gamma$.
\end{theorem}
\begin{proof}
We just did the $\implies$ direction.

To see $\impliedby$, fix some $(x_0,y_0)\in H$, and define
\[u(x,y)=\int_{\gamma} f\,dx+g\,dy\]
where $\gamma$ is any curve that connects $(x_0,y_0)$ to $(x,y)$.

Because
\[\frac{u(x,y+h)-u(x,y)}{h}=\frac{\int_y^{y+h}g(t)\,dt}{h}\to g(y)\quad\text{ as }h\to 0\]
and similarly with $x$ and $f$, we are done.
\end{proof}

\begin{theorem}
If $f,g$ are differentiable on $H$, and $H$ is simply connected, then there exists a primitive $u$ for $(f,g)$ if and only if $g_x=f_y$.
\end{theorem}
\begin{proof}
We've done the $\implies$ direction.

To see $\impliedby$, note that because $H$ is simply connected, the region bounded by any curve $\gamma$ in $H$ is a domain $A$ entirely contained inside $H$, and therefore
\[\int_{\gamma}f\,dx+g\,dy=\int_A\underbrace{g_x-f_y}_{=\,0}\,dxdy=0.\qedhere\]
\end{proof}

\begin{definition}
If $u$ is twice differentiable, we say that $u$ is harmonic if 
\[\Delta u=u_{xx}+u_{yy}=0.\]
$\Delta$ is called the Laplace operator.
\end{definition}

\begin{examples}
Clearly, any linear function is harmonic. For a second order polynomial $u=ax^2+bxy+cy^2$, we have $\Delta u=2a+2c$, so that $x^2-y^2$ and $xy$ are a basis for the vector space of harmonic second order polynomials.
\end{examples}
\begin{homework}
Find a basis for the vector space of harmonic polynomials in $x$ and $y$ of degree 6.
\end{homework}

The key property of harmonic functions is that their value at a point is determined by their integral on a circle around that point, which is what we'll prove now.

We know that 
\[\int_HG_x=\int_{\partial H}G,\qquad\int_H F_y=-\int_{\partial H}F.\]
Let's choose $G=u_x v$ and $F=u_y v$, for some function $v$. We get that
\[\int_H(u_{xx}v+u_xv_x)\,dxdy=\int_{\partial H}u_x v,\qquad\int_H (u_{yy}v+u_yv_y)\,dx\,dy=-\int_{\partial H}u_y v.\]
Thus
\[\int_H(\Delta u)v+\langle u',v'\rangle\,dxdy=\int_{\partial H}v(u_x\,dy-u_y\,dx)=\int_{\partial H}v\cdot\frac{\partial u}{\partial{n}}\,ds\]
where $u_x\,dy-u_y\,dx=\langle u',(dy,-dx)\rangle=\langle u',{n}'\rangle$ (?) and $n$ is the normalized unit vector in the radial direction (see picture below). This is known as the first Green formula.

The second Green formula (or symmetric Green formula) says that
\[\int_H(\Delta u\cdot v-\Delta v\cdot u)=\int_{\partial H}v\cdot \frac{\partial u}{\partial n}-u\cdot\frac{\partial v}{\partial n}.\]
Choosing $v\equiv 1$, we have
\[\int_H\Delta u=\int_{\partial H}\frac{\partial u}{\partial n},\]
and therefore, if $u$ is harmonic, then
\[\int_{\partial H}\frac{\partial u}{\partial n}\,ds=0.\]
On a circle,
\begin{center}
\begin{tikzpicture}[scale=2]
\node (o) at (0,0) {};
\node (t) at (1,0) {};
\draw[thick] (o) circle (1);
\node (a) at (120:1) {};
\node[fill,circle,inner sep=0pt,outer sep=0pt,minimum size=5pt] (b) at (45:1) {};
\node (c) at (45:1.3) {};
\draw[thick,dotted] (o.center) to node[auto] {$\rho$} (a.center);
\draw[thick] (o.center) to (b.center);
\draw[thick] (o.center) to (t.center);
\draw[thick,->] (b.center) to node[auto,swap]{$n$} (c.center);
\draw (0.2,0)  arc  (0:45:0.2)  ;
\node at (0.3,0.12) {$\varphi$};
\end{tikzpicture}
\end{center}
we have
\[\frac{\partial u}{\partial n}=\frac{\partial u}{\partial r},\qquad ds=\rho\,d\varphi\]
so that the integrals $\int\frac{\partial f}{\partial n}\,ds$ and $\int \frac{\partial f}{\partial r}\,rd\varphi$ are equivalent for any $f$.
Thus, if $u$ is harmonic,
\begingroup
\addtolength{\jot}{1em}
\begin{align*}
\int_{\partial H}\frac{\partial u}{\partial n}\,ds&=0\\
\int_0^{2\pi}\frac{\partial u}{\partial r}\bigg|_{r=\rho}\rho\,d\varphi&=0\\
\rho\int_0^{2\pi}\frac{\partial u}{\partial r}\bigg|_{r=\rho}\,d\varphi&=0\\
\frac{\partial}{\partial r}\int_0^{2\pi }u\,d\varphi&=0.
\end{align*}
\endgroup
Therefore, $u$ has the same integral on concentric circles.


Letting $I(r)=\int_0^{2\pi}u(r\cos(\varphi),r\sin(\varphi))\,d\varphi$, this just means that $I'(r)=0$, so that $I(r)=$ a constant. In fact, it is easy to see that we must have $I(r)=2\pi u(0)$ for any $r$.

If $u$ is harmonic and $v=\frac{1}{4}(x^2+y^2)$, then $\Delta v=1$. Letting $H=B(0,\rho)$, 
\[\int_Hu=\int_0^{2\pi}\left(u\cdot\frac{1}{2}\rho-\frac{1}{4}\rho^2\frac{\partial u}{\partial r}\right)\rho\,d\varphi=\frac{\rho^2}{2}\int_0^{2\pi}u\,d\varphi.\]
Therfore
\[\frac{1}{\pi\rho^2}\int_{B(0,\rho)}u=\frac{1}{2\pi}\int_0^{2\pi}u\,d\varphi.\]
This says that the average of $u$ on the disc is equal to its average on a circle, which is equal to $u(0)$.

Let's consider harmonic functions that depend only on one variable. For example, if $u(x,y)=u(x)$, then we have $u_{xx}+u_{yy}=u_{xx}=0$, so $u=ax+b$.
\begin{homework}
If $u(x,y)$ depends only on $r$, what form must $u$ have? What if $u$ depends only on $\varphi$?
\end{homework}

Let's consider the Laplacian in polar coordinates. We will write $u(r,\varphi)=u(r\cos(\varphi),r\sin(\varphi))$. What does it mean to say $\Delta u=0$? We have
\[u_r=u_x\cos(\varphi)+u_y\sin(\varphi)\]
so
\[u_{rr}=(u_{xx}\cos(\varphi)+u_{xy}\sin(\varphi))\cos(\varphi)+(u_{yx}\cos(\varphi)+u_{yy}\sin(\varphi))\sin(\varphi).\]
We also have
\[u_{\varphi}=-u_x\cdot r\sin(\varphi)+u_y\cdot r\cos(\varphi)\]
so
\[u_{\varphi\varphi}=-r(-u_{xx}r\sin(\varphi)+u_{xy}r\cos(\varphi))\sin(\varphi)-u_x\cos(\varphi)+r\cos(\varphi)(-u_{yx}r\sin(\varphi)+u_{yy}r\cos(\varphi))-u_{y}r\sin(\varphi)\]
Taken all together, we therefore have $\Delta u=0$ implies
\[u_{\varphi\varphi}+r^2u_{rr}+ru_r=0.\]
If $u$ depends only on $r$, then $r^2\cdot u''+ru'=0$, so that $r\cdot f'+f=0$ where $u'=f$, and therefore
\[\frac{f'}{f}=-\frac{1}{r}\]
\[(\log(f))'=-\log(r)'\]
so $u=c\log(r)+d$.




