\chapter{Integrating differential forms}
\label{ch:stokes_diffgeo}
We now show how to integrate differential forms over cells,
and state Stokes' theorem in this context.
In this chapter, all vector spaces are finite-dimensional and real.

\section{Motivation: line integrals}
Given a function $g \colon [a,b] \to \RR$,
we know by the fundamental theorem of calculus that
\[
	\int_{[a,b]} g(t) \; dt = f(b) - f(a)
\]
where $f$ is a function such that $g = df/dt$.
%(You might recognize this more readily
%as the more customary $\int_a^b g(t) \; dt$.)
Equivalently, for $f \colon [a,b] \to \RR$,
\[ \int_{[a,b]} g \; dt = \int_{[a,b]} df = f(b) - f(a) \]
where $df$ is the exterior derivative we defined earlier.

Cool, so we can integrate over $[a,b]$.
Now suppose more generally, we have $U$ an open subset of our real vector space $V$
and a $1$-form $\alpha \colon U \to V^\vee$.
We consider a \vocab{parametrized curve}, which is a smooth function $c \colon [a,b] \to U$.
Picture:
\begin{center}
	\begin{asy}
		size(8.5cm);
		pair A = (-13,0);
		pair B = (-9,0);
		draw(A--B, grey);
		dot(A, grey); dot(B, grey);
		label("$[a,b]$", A--B, dir(90), grey);
		dot("$t$", 0.3*A+0.7*B, dir(-90), grey);

		draw( (-8,0) -- (-6,0) , EndArrow);
		label("$c$", (-7,0), dir(90));

		bigblob("$U$");
		pair a = (-2,-2);
		pair b = (3,0);
		pair p = (0,1);
		pair q = (2,0);
		label("$c$", q, dir(45), red);
		draw(a..p..q..b, red);
		dot("$p = c(t)$", p, dir(90), blue);
		draw(p--(p+1.5*dir(-10)), blue, EndArrow);

		draw( (0,-4)--(0,-8), EndArrow );
		label("$\alpha$", (0,-6), dir(0));
		label("$\alpha_p(v) \in \mathbb R$", (0,-9), heavygreen);

		draw( (-10,-1)--(-1,-8), EndArrow);
		label("$c^\ast \alpha$", (-5.5,-4.5), dir(225));
	\end{asy}
\end{center}

We want to define an $\int_c \alpha$ such that:
\begin{moral}
	The integral $\int_c \alpha$ should add up all the $\alpha$ along the curve $c$.
\end{moral}
Our differential form $\alpha$ first takes in a point $p$ to get $\alpha_p \in V^\vee$.
Then, it eats a tangent vector $v \in V$ to the curve $c$ to finally give a real number $\alpha_p(v) \in \RR$.
We would like to ``add all these numbers up'',
using only the notion of an integral over $[a,b]$.

\begin{exercise}
	Try to guess what the definition of the integral should be.
	(By type-checking, there's only one reasonable answer.)
\end{exercise}

So, the definition we give is
\[ \int_c \alpha \defeq
	\int_{[a,b]} \alpha_{c(t)} \left( c'(t) \right) \; dt.  \]
Here, $c'(t)$ is shorthand for $(Dc)_t(1)$.
It represents the \emph{tangent vector} to the curve $c$ at the point $p=c(t)$,
at time $t$.
(Here we are taking advantage of the fact that $[a,b]$ is one-dimensional.)

Now that definition was a pain to write, so we will define a differential
$1$-form $c^\ast \alpha$ on $[a,b]$ to swallow that entire thing:
specifically, in this case we define $c^\ast\alpha$ to be
\[ \left( c^\ast \alpha \right)_t (\eps) = \alpha_{c(t)} \cdot (Dc)_{t} (\eps) \]
(here $\eps$ is some displacement in time).
Thus, we can more succinctly write
\[ \int_c \alpha \defeq \int_{[a,b]} c^\ast \alpha. \]
This is a special case of a \emph{pullback}:
roughly, if $\phi \colon U \to U'$ (where $U \subseteq V$, $U' \subseteq V'$),
we can change any differential $k$-form $\alpha$ on $U'$
to a $k$-form on $U$.
In particular, if $U = [a,b]$,\footnote{OK,
	so $[a,b]$ isn't actually open, sorry.
	I ought to write $(a-\eps, b+\eps)$, or something.}
we can resort to our old definition of an integral.
Let's now do this in full generality.

\section{Pullbacks}
Let $V$ and $V'$ be finite dimensional real vector spaces (possibly different dimensions)
and suppose $U$ and $U'$ are open subsets of each;
next, consider a $k$-form $\alpha$ on $U'$.

Given a map $\phi \colon U \to U'$ we now want to define a pullback in
much the same way as before.
Picture:
\begin{center}
	\begin{asy}
		size(13cm);
		bigblob("$U$");
		pair p = (-1,0);
		dot("$p$", p, dir(90), red);
		pair p1 = p + 1.4*dir(150);
		pair p2 = p + 1.7*dir(-50);
		draw(p--p1, red, EndArrow);
		draw(p--p2, red, EndArrow);

		add(scale(0.8)*shift(14*dir(180))*CC());
		bigblob("$U'$");
		pair q = (-0.5,0.5);
		dot("$q = \phi(p)$", q, dir(90), blue);
		pair q1 = q + 1.8*dir(-100);
		pair q2 = q + 2.3*dir(-10);
		draw(q--q1, blue, EndArrow);
		draw(q--q2, blue, EndArrow);

		draw((-9,0)--(-3,0), EndArrow);
		label("$\phi$", (-6,0), dir(90));

		draw( (0,-4)--(0,-8), EndArrow );
		label("$\alpha$", (0,-6), dir(0));
		label("$\alpha_q(\dots) \in \mathbb R$", (0,-9), heavygreen);

		draw( (-11,-3)--(-1,-8), EndArrow);
		label("$\phi^\ast \alpha$", (-6,-6), dir(225));
	\end{asy}
\end{center}

Well, there's a total of about one thing we can do.
Specifically: $\alpha$ accepts a point in $U'$ and $k$ tangent vectors in $V'$,
and returns a real number.
We want $\phi^\ast \alpha$ to accept a point in $p \in U$
and $k$ tangent vectors $v_1, \dots, v_k$ in $V$,
and feed the corresponding information to $\alpha$.

Clearly we give the point $q = \phi(p)$.
As for the tangent vectors, since we are interested in volume, we take the
derivative of $\phi$ at $p$, $(D\phi)_p$, which will scale each of our vectors $v_i$
into some vector in the target $V'$.
To cut a long story short:
\begin{definition}
	Given $\phi \colon U \to U'$ and $\alpha$ a $k$-form, we define the \vocab{pullback}
	\[
		(\phi^\ast \alpha)_p(v_1, \dots, v_k)
		\defeq \alpha_{\phi(p)}
		\left( (D\phi)_p(v_1), \dots, (D\phi)_p(v_k) \right).
	\]
\end{definition}

There is a more concrete way to define the pullback using bases.
Suppose $w_1, \dots, w_n$ is a basis of $V'$
and $e_1, \dots, e_m$ is a basis of $V$.
Thus, by the projection principle (\Cref{thm:project_principle})
the map $\phi \colon V \to V'$ can be thought of as
\[ \phi(v) = \phi_1(v) w_1 + \dots + \phi_n(v) w_n \]
where each $\phi_i$ takes in a $v \in V$ and returns a real number.
We know also that $\alpha$ can be written concretely as
\[ \alpha = \sum_{I \subseteq \{1, \dots, n\}} f_I \; dw_I. \]
Then, we define
\[
	\phi^\ast\alpha
	= \sum_{I \subseteq \{1, \dots, n\}}
	(f_I \circ \phi) (D\phi_{i_1} \wedge \dots \wedge D\phi_{i_k}).
\]
A diligent reader can check these definitions are equivalent.
\begin{example}
	[Computation of a pullback]
	Let $V = \RR^2$ with basis $\ee_1$ and $\ee_2$,
	and suppose $\phi \colon V \to V'$ is given by sending
	\[ \phi(a\ee_1 + b\ee_2) = (a^2+b^2)w_1 + \log(a^2+1) w_2 + b^3 w_3 \]
	where $w_1$, $w_2$, $w_3$ is a basis for $V'$.
	Consider the form $\alpha_q = f(q) w_1^\vee \wedge w_3^\vee$, where $f \colon V' \to \RR$.
	Then
	\[ (\phi^\ast\alpha)_p = f(\phi(p)) \cdot (2a \ee_1^\vee + 2b\ee_2^\vee) \wedge (3b^2 \ee_2^\vee)
		= f(\phi(p)) \cdot 6ab^2 \cdot \ee_1^\vee \wedge \ee_2^\vee. \]
\end{example}

It turns out that the pullback basically behaves nicely as possible, e.g.\
\begin{itemize}
	\ii $\phi^\ast(c\alpha + \beta) = c\phi^\ast \alpha + \phi^\ast\beta$ (linearity)
	\ii $\phi^\ast(\alpha\wedge\beta)
	= (\phi^\ast \alpha)\wedge(\phi^\ast \beta)$
	\ii $\phi_1^\ast(\phi_2^\ast(\alpha))
	= (\phi_2 \circ \phi_1)^\ast(\alpha)$ (naturality)
\end{itemize}
but I won't take the time to check these here
(one can verify them all by expanding with a basis).

\section{Cells}
\prototype{A disk in $\RR^2$ can be thought of as the cell
	$[0,R]\times[0,2\pi] \to \RR^2$ by
	$(r,\theta) \mapsto (r\cos\theta)\ee_1 + (r\sin\theta)\ee_2$.}
Now that we have the notion of a pullback,
we can define the notion of an integral for more general spaces.
Specifically, to generalize the notion of integrals we had before:
\begin{definition}
	A \vocab{$k$-cell} is a smooth function $c \colon [a_1, b_1] \times [a_2,b_2] \times \dots [a_k, b_k] \to V$.
\end{definition}
\begin{example}
	[Examples of cells]
	Let $V = \RR^2$ for convenience.
	\begin{enumerate}[(a)]
		\ii A $0$-cell consists of a single point.
		\ii As we saw, a $1$-cell is an arbitrary curve.
		\ii A $2$-cell corresponds to a $2$-dimensional surface.
		For example, the map $c \colon [0,R] \times [0,2\pi] \to V$ by
		\[ c \colon (r,\theta) \mapsto (r\cos\theta, r\sin\theta) \]
		can be thought of as a disk of radius $R$.
	\end{enumerate}
\end{example}
So we can now give the definition.
\begin{definition}
	[How to integrate differential $k$-forms]
	Take a differential $k$-form $\alpha$ and a $k$-cell $c \colon [0,1]^k \to V$.
	Define the integral $\int_c \alpha$ using the pullback
	\[ \int_c \alpha \coloneqq \int_{[0,1]^k} c^\ast \alpha. \]
\end{definition}
Since $c^\ast \alpha$ is a $k$-form on the $k$-dimensional unit box,
it can be written as $f(x_1, \dots, x_k) \; dx_1 \wedge \dots \wedge dx_k$,
So the above integral could also be written as
\[ \int_0^1 \dots \int_0^1 f(x_1, \dots, x_k) \; dx_1 \wedge \dots \wedge dx_k. \]

\begin{example}[Area of a circle]
	Consider $V = \RR^2$ and let $c \colon (r,\theta) \mapsto (r\cos\theta)\ee_1 + (r\sin\theta)\ee_2$
	on $[0,R] \times [0,2\pi]$ as before.
	Take the $2$-form $\alpha$ which gives $\alpha_p = \ee_1^\vee \wedge \ee_2^\vee$ at every point $p$.
	Then
	\begin{align*}
		c^\ast\alpha &=
		\left( \cos\theta dr - r\sin\theta d\theta \right)
		\wedge
		\left( \sin\theta dr + r\cos\theta d\theta \right) \\
		&= r(\cos^2\theta+\sin^2\theta) (dr \wedge d\theta) \\
		&= r \; dr \wedge d\theta
	\end{align*}
	Thus,
	\[ \int_c \alpha
		= \int_0^R \int_0^{2\pi} r \; dr \wedge d\theta
		= \pi R^2 \]
	which is the area of a circle.
\end{example}

Here's some geometric intuition for what's happening.
Given a $k$-cell in $V$, a differential $k$-form $\alpha$ accepts a point $p$ and some tangent vectors $v_1$, \dots, $v_k$
and spits out a number $\alpha_p(v_1, \dots, v_k)$,
which as before we view as a signed hypervolume.
Then the integral \emph{adds up all these infinitesimals across the entire cell}.
In particular, if $V = \RR^k$ and we take the form $\alpha \colon p \mapsto \ee_1^\vee \wedge \dots \wedge \ee_k^\vee$,
then what these $\alpha$'s give is the $k$th hypervolume of the cell.
For this reason, this $\alpha$ is called the \vocab{volume form} on $\RR^k$.

You'll notice I'm starting to play loose with the term ``cell'':
while the cell $c \colon [0,R] \times [0,2\pi] \to \RR^2$ is supposed to be a function
I have been telling you to think of it as a unit disk (i.e.\ in terms of its image).
In the same vein, a curve $[0,1] \to V$ should be thought of as a curve in space,
rather than a function on time.

This error turns out to be benign.
Let $\alpha$ be a $k$-form on $U$ and $c \colon [a_1, b_1] \times \dots \times [a_k, b_k] \to U$ a $k$-cell.
Suppose $\phi \colon [a_1', b_1'] \times \dots [a_k', b_k'] \to [a_1, b_1] \times \dots \times [a_k, b_k]$;
it is a \vocab{reparametrization} if $\phi$ is bijective and $(D\phi)_p$ is always invertible
(think ``change of variables'');
thus
\[ c \circ \phi \colon [a_1', b_1'] \times \dots \times [a_k',b_k'] \to U \]
is a $k$-cell as well.
Then it is said to \vocab{preserve orientation} if $\det(D\phi)_p > 0$ for all $p$
and \vocab{reverse orientation} if $\det(D\phi)_p < 0$ for all $p$.
\begin{exercise}
	Why is it that exactly one of these cases must occur?
\end{exercise}

\begin{theorem}
	[Changing variables doesn't affect integrals]
	Let $c$ be a $k$-cell, $\alpha$ a $k$-form, and $\phi$ a reparametrization.
	Then
	\[ \int_{c \circ \phi} \alpha
		=
		\begin{cases}
			\int_c \alpha & \phi \text{ preserves orientation} \\
			- \int_c \alpha & \phi \text{ reverses orientation}.
		\end{cases}
	\]
\end{theorem}
\begin{proof}
	Use naturality of the pullback to reduce it to the corresponding
	theorem in normal calculus.
\end{proof}

So for example, if we had parametrized the unit circle as $[0,1] \times [0,1] \to \RR^2$
by $(r,t) \mapsto R\cos(2\pi t) \ee_1 + R\sin(2\pi t) \ee_2$, we would have arrived at the same result.
So we really can think of a $k$-cell just in terms of the points it specifies.

\section{Boundaries}
\prototype{The boundary of $[a,b]$ is $\{b\}-\{a\}$. The boundary of a square goes around its edge counterclockwise.}
First, I introduce a technical term that lets us consider multiple cells at once.
\begin{definition}
	A \vocab{$k$-chain} $U$ is a formal
	linear combination of $k$-cells over $U$,
	i.e.\ a sum of the form
	\[ c = a_1 c_1 + \dots + a_m c_m \]
	where each $a_i \in \RR$ and $c_i$ is a $k$-cell.
	We define $\int_c \alpha = \sum_i a_i \int_{c_i} \alpha$.
\end{definition}
In particular, a $0$-chain consists of several points, each with a given weight.

Now, how do we define the boundary?
For a $1$-cell $[a,b] \to U$, as I hinted earlier we want the answer to be the $0$-chain $\{c(b)\}-\{c(a)\}$.
Here's how we do it in general.
\begin{definition}
	Suppose $c \colon [0,1]^k \to U$ is a $k$-cell.
	Then the \vocab{boundary} of $c$, denoted $\partial c \colon [0,1]^{k-1} \to U$,
	is the $(k-1)$-chain defined as follows.
	For each $i = 1,\dots,k$ define $(k-1)$-chains by
	\begin{align*}
		c_i^{\text{start}} \colon (t_1, \dots, t_{k-1}) &\mapsto
			c(t_1, \dots, t_{i-1}, 0, t_i, \dots, t_{k-1}) \\
		c_i^{\text{stop}} \colon (t_1, \dots, t_{k-1}) & \mapsto
			c(t_1, \dots, t_{i-1}, 1, t_i, \dots, t_{k-1}).
	\end{align*}
	Then
	\[ \partial c \defeq
	\sum_{i=1}^k (-1)^{i+1} \left( c_i^{\text{stop}} - c_i^{\text{start}}  \right). \]
	Finally, the boundary of a chain is the sum of the boundaries of each cell (with the appropriate weights).
	That is, $\partial(\sum a_ic_i) = \sum a_i \partial c_i$.
\end{definition}
\begin{ques}
	Satisfy yourself that one can extend this definition to
	a $k$-cell $c$ defined on $c \colon [a_1, b_1] \times \dots \times [a_k, b_k] \to V$
	(rather than from $[0,1]^k \to V$).
\end{ques}

\begin{example}
	[Examples of boundaries]
	Consider the $2$-cell $c \colon [0,1]^2 \to \RR^2$ shown below.
	\begin{center}
		\begin{asy}
			size(7cm);
			pen e1 = heavyred;
			pen e2 = orange;
			pen e3 = olive;
			pen e4 = heavymagenta;
			draw((0,0)--(2,0), e1, EndArrow);
			draw((2,0)--(2,2), e2, EndArrow);
			draw((2,2)--(0,2), e3, EndArrow);
			draw((0,2)--(0,0), e4, EndArrow);
			label(scale(0.8)*"$[0,1]^2$", (1,1));
			draw( (3,1)--(6,1), EndArrow);
			label("$c$", (4.5,1), dir(90));
			pair p1 = (7,-1);
			pair p2 = (12,-2);
			pair p3 = (11,3);
			pair p4 = (8,2);
			fill(p1--p2--p3--p4--cycle, palecyan);
			draw(p1--p2, e1, EndArrow, Margins);
			draw(p2--p3, e2, EndArrow, Margins);
			draw(p3--p4, e3, EndArrow, Margins);
			draw(p4--p1, e4, EndArrow, Margins);
			dot("$p_1$", p1, dir(225), blue+4);
			dot("$p_2$", p2, dir(315), blue+4);
			dot("$p_3$", p3, dir( 45), blue+4);
			dot("$p_4$", p4, dir(135), blue+4);
			label("$c$", (p1+p2+p3+p4)/4);
		\end{asy}
	\end{center}
	Here $p_1$, $p_2$, $p_3$, $p_4$ are the images of $(0,0)$, $(1,0)$, $(1,1)$, $(0,1)$, respectively.
	Formally, $\partial c$ is given by
	\[ \partial c = (t \mapsto c(1,t)) - (t \mapsto c(0,t))
		- (t \mapsto c(t,1)) + (t \mapsto c(t,0)). \]
	I apologize for the eyesore notation caused by inline functions.
	Let's make amends and just write
	\[ \partial c = [p_2,p_3] - [p_1,p_4] - [p_4,p_3] + [p_1,p_2] \]
	where each ``interval'' represents the $1$-cell shown by the reddish arrows on the right,
	after accounting for the minus signs.
	We can take the boundary of this as well, and obtain an empty chain as
	\[ \partial(\partial c) = \sum_{i=1}^4 \{p_{i+1}\}-\{p_i\} = 0. \]
\end{example}

\begin{example}
	[Boundary of a unit disk]
	Consider the unit disk given by
	\[ c \colon [0,1] \times [0,1] \to \RR^2 \quad\text{by}\quad
	(r,\theta) \mapsto r\cos(2\pi \theta)\ee_1 + r\sin(2\pi \theta)\ee_2. \]
	The four parts of the boundary are shown in the picture below:
	\begin{center}
		\begin{asy}
			size(7cm);
			pen e1 = heavyred;
			pen e2 = orange;
			pen e3 = olive;
			pen e4 = heavymagenta;
			draw((0,0)--(2,0), e1, EndArrow);
			draw((2,0)--(2,2), e2, EndArrow);
			draw((2,2)--(0,2), e3, EndArrow);
			draw((0,2)--(0,0), e4, EndArrow);
			label("$r$", (2,0), dir(-45));
			label("$\theta$", (0,2), dir(135));

			label(scale(0.8)*"$[0,1]^2$", (1,1));
			draw( (3,1)--(6,1), EndArrow);
			label("$c$", (4.5,1), dir(90));

			pair O = (9,1);
			pair P = O + 2*dir(0);
			fill(CP(O,P), palecyan);
			real eps = 0.3;
			draw(shift(0,eps) * (O--P), e1, EndArrow, Margins);
			draw(shift(0,-eps) * (P--O), e3, EndArrow, Margins);
			draw(CP(O,P), e2, EndArrow, Margins);
			dot(O, e4+4);
		\end{asy}
	\end{center}
	Note that two of the arrows more or less cancel each other out when they are integrated.
	Moreover, we interestingly have a \emph{degenerate} $1$-cell at the center of the circle;
	it is a constant function $[0,1] \to \RR^2$ which always gives the origin.
\end{example}

Obligatory theorem, analogous to $d^2=0$ and left as a problem.
\begin{theorem}[The boundary of the boundary is empty]
	$\partial^2 = 0$, in the sense that for any $k$-chain $c$ we have $\partial^2(c) = 0$.
\end{theorem}

\section{Stokes' theorem}
\prototype{$\int_{[a,b]} dg = g(b) - g(a)$.}

We now have all the ingredients to state Stokes' theorem for cells.
\begin{theorem}
	[Stokes' theorem for cells]
	Take $U \subseteq V$ as usual, let $c \colon [0,1]^k \to U$ be a $k$-cell
	and let $\alpha \colon U \to \bigwedge^{k-1}(V^\vee)$ be a $(k-1)$-form.
	Then
	\[ \int_c d\alpha = \int_{\partial c} \alpha. \]
	In particular, if $d\alpha = 0$ then the left-hand side vanishes.
\end{theorem}
For example, if $c$ is the interval $[a,b]$ then $\partial c = \{b\} - \{a\}$,
and thus we obtain the fundamental theorem of calculus.

\section{Back to Earth: A comparison to what you learned in vector calculus}
Now that we've done everything abstractly,
let's compare what we've learned to what you might see in $\RR^3$
if you're doing a vector calculus course at a typical university.

In \Cref{fig:1802gradcurldiv} I've copied a picture I drew in fall 2024
for the 18.02 class at MIT,
which is the multivariable calculus class that a lot of first-year students take.
For each $0 \le d \le n \le 3$ (besides $d=n=0$),
it shows what kind of integral showed up in the class
if you were doing a $d$-dimensional integral of a function whose domain was $\RR^n$.
Note that every integral in this picture is real-valued.

I've deliberately used the notation that was actually used at MIT,
which I'll refer to as 18.02 notation,
because it's similar to what you will see on Wikipedia and other places too.
The goal of this section is to provide a translation system from 18.02 notation to Napkin notation.
(Throughout the whole section, $\RR^n$ is thought of as a normed vector space,
so the identification $\ee_1 \mapsto \ee_1^\vee$ and so on is canonical.)

\begin{figure}[ht]
\centering
\textbf{\Large An 18.02 chart.}

\begin{asy}
size(16cm);
usepackage("amsmath");
usepackage("amssymb");
usepackage("derivative");
label("$\boxed{f \colon \mathbb R^1 \to \mathbb R}$", (-0.5,8), dir(180), blue);
label("$\boxed{f \colon \mathbb R^2 \to \mathbb R}$", (-0.5,3.5), dir(180), blue);
label("$\boxed{f \colon \mathbb R^3 \to \mathbb R}$", (-0.5,0), dir(180), blue);
label("$\boxed{\mathbf F \colon \mathbb R^2 \to \mathbb R^2}$", (-0.5,6.5), dir(180), purple);
label("$\boxed{\mathbf F \colon \mathbb R^3 \to \mathbb R^3}$", (-0.5,-3), dir(180), purple);

real w = 0.7; // axis length
pair O = (0,0);
defaultpen(fontsize(11pt));
pen intfont = fontsize(9pt);

picture vector_field;
for (int i=0; i<5; ++i) {
  for (int j=0; j<4; ++j) {
    draw(vector_field,
    shift(-0.9*w,-0.6*w)*((0.4*i*w,0.45*j*w)--(0.4*i*w+0.2,0.45*j*w-0.15)),
    rgb(0.6,0.6,0.9), EndArrow(TeXHead));
  }
}

picture axis1;
picture axis2;
picture axis3;
draw(axis1, (-w,0)--(w,0), grey, Arrows(TeXHead));
draw(axis2, (-w,0)--(w,0), grey, Arrows(TeXHead));
draw(axis2, (0,-w)--(0,w), grey, Arrows(TeXHead));
draw(axis3, (-w,0)--(w,0), grey, Arrows(TeXHead));
draw(axis3, (0,-w)--(0,w), grey, Arrows(TeXHead));
draw(axis3, (-w/1.6,-w/1.6)--(w/1.6,w/1.6), grey, Arrows(TeXHead));

transform t;

/* 0-D integrals */
label("\fbox{0-D integral}", (1,9.5), deepblue);
string s = "Eval $f$ at point";

t = shift(1,8);
add(t*axis1);
dot("$f(x_0)$", t*O, dir(-90));
label(s, t*(dir(90)/2), deepgreen);

t = shift(1,3.5);
add(t*axis2);
dot("$f(x_0, y_0)$", t*(-w/2,-w/2), dir(-75));
label(s, t*dir(90), deepgreen);

t = shift(1,0);
add(t*axis3);
dot("$f(x_0, y_0, z_0)$", t*(-w/3,-2*w/3), dir(-75));
label(s, t*dir(90), deepgreen);

/* 1-D integrals */
label("\fbox{1-D integral}", (4,9.5), deepblue);

t = shift(4,8);
add(t*axis1);
draw(t*((-0.3,0)--(0.3,0)), black+1.4);
dot(t*(-0.3,0), black);
dot(t*( 0.3,0), black);
label("$\int\limits_a^b f(x) \odif x$", t*O, dir(-90));
label("1-var integral", t*(dir(90)/2), deepgreen);

t = shift(4,3.5);
add(t*axis2);
draw("$\int\limits_{t_0}^{t_1} f(\mathbf r(t)) |\mathbf r'(t)| \odif t$", t*(0,-w), dir(-90), intfont);
draw(t*((-0.7*w,-0.4*w)..(-0.2*w,0.5*w)..(0.6*w,0.55*w)), black+1.4);
dot(t*(-0.7*w, -0.4*w));
dot(t*(0.6*w, 0.55*w));
label("Line integral", t*dir(90), deepgreen);

t = shift(4,0);
add(t*axis3);
draw("$\int\limits_{t_0}^{t_1} f(\mathbf r(t)) |\mathbf r'(t)| \odif t$", t*(0,-w), dir(-90), intfont);
draw(t*((-0.8*w,-0.3*w)..(0.2*w,-0.1*w)..(0.6*w,0.3*w)), black+1.4);
dot(t*(-0.8*w, -0.3*w));
dot(t*(0.6*w, 0.3*w));
label("Line integral", t*dir(90), deepgreen);

/* 2-D integrals */
label("\fbox{2-D integral}", (8,9.5), deepblue);

t = shift(8,3.5);
path square = box((-0.6*w,-0.6*w), (0.6*w,0.6*w));
filldraw(t*square, lightgrey, black+1.4);
draw("$\int\limits_{a_1}^{b_1} \int\limits_{a_2}^{b_2} f(x,y) \odif x \odif y$", t*(0,-w), dir(-90), intfont);
label("Area integral", t*dir(90), deepgreen);
add(t*axis2);

t = shift(8,0);
path surface = (-0.8*w,-0.1*w)..(-0.2*w,-0.3*w)..(0.6*w,-0.6*w)..(0.7*w,-0.1*w)..(0.3*w,0.4*w)..(-0.5*w,0.3*w)..cycle;
filldraw(t*surface, lightgrey, black+1.4);
draw("$\int\limits_{u_0}^{u_1} \int\limits_{v_0}^{v_1} f(\mathbf r(u,v)) |\pdv{\mathbf{r}}{u} \times \pdv{\mathbf{r}}{v}| \odif u \odif v$", t*(0,-w), dir(-90), intfont);
label("Surface integral", t*dir(90), deepgreen);
add(t*axis3);

/* 3-D integrals */
label("\fbox{3-D integral}", (12.5,9.5), deepblue);

t = shift(12.5,0);
pair A = (-0.4, -0.25);
pair C = (0.1, 0.25);
pair B = (A.x, C.y);
pair D = (C.x, A.y);
transform s = shift(0.17,0.13);
fill(t*(A--B--s*B--s*C--s*D--D--cycle), lightgrey);
draw(t*s*(A--B--C--D--cycle), black+1.4);
draw(t*(A--B--C--D--cycle), black+1.4);
draw(t*(A--s*A), black+1.4);
draw(t*(B--s*B), black+1.4);
draw(t*(C--s*C), black+1.4);
draw(t*(D--s*D), black+1.4);
draw("$\int\limits_{a_1}^{b_1} \int\limits_{a_2}^{b_2} \int\limits_{a_3}^{b_3} f(x,y,z) \odif x \odif y \odif z$", t*(0,-w), dir(-90), intfont);
label("Volume integral", t*dir(90), deepgreen);
add(t*axis3);

/* Work */
t = shift(4,5.5);
add(t*axis2);
draw("$\int\limits_{t_0}^{t_1} \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \odif{t}$", t*(-w,w), dir(180), intfont+purple);
add(t*vector_field);
draw(t*((-0.7*w,-0.4*w)..(-0.2*w,0.5*w)..(0.6*w,0.55*w)), purple+1.4);
dot(t*(-0.7*w, -0.4*w), purple);
dot(t*(0.6*w, 0.55*w), purple);
label("Work", t*dir(90), purple);

t = shift(4,-3);
add(t*axis3);
draw("$\int\limits_{t_0}^{t_1} \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \odif{t}$", t*(-w,-w), dir(180), intfont+purple);
add(t*vector_field);
draw(t*((-0.8*w,-0.3*w)..(0.2*w,-0.1*w)..(0.6*w,0.3*w)), purple+1.4);
dot(t*(-0.8*w, -0.3*w), purple);
dot(t*(0.6*w, 0.3*w), purple);
label("Work", t*dir(90), purple);

/* Flux */
t = shift(8,-3);
draw("$\int\limits_{u_0}^{u_1} \int\limits_{v_0}^{v_1} \mathbf{F}(\mathbf{r}(u,v)) \cdot \left( \pdv{\mathbf{r}}{u} \times \pdv{\mathbf{r}}{v} \right) \odif{u} \odif{v}$", t*(w,-w), dir(0), intfont+purple);
filldraw(t*surface, pink, purple+1.4);
add(t*axis3);
add(t*vector_field);
label("Flux", t*dir(90), purple);

/* Arrows */
draw("$\frac{df}{dx}$", (2,8)--(3,8), red, EndArrow);

draw((1,5)--(1,5.5)--(3,5.5), red, EndArrow);
label("$\nabla f$ (grad)", (1,5.5), dir(180), red);
draw((5,5.5)--(8,5.5)--(8,5), red, EndArrow);
label("$\pdv{g}{x}-\pdv{f}{y}$ (2d scalar curl)", (8,5.5), dir(0), red);

draw((1,-1.5)--(1,-3)--(3,-3), red, EndArrow);
label("$\nabla f$ (grad)", (1,-2.25), dir(180), red);
draw((5,-3)--(7,-3), red, EndArrow);
label("$\nabla \times \mathbf{F}$ (curl)", (6,-3), dir(270), red);
draw((9,-3)--(12.5,-3)--(12.5,-1.5), red, EndArrow);
label("$\nabla \cdot \mathbf{F}$ (div)", (12.5,-2.25), dir(0), red);
\end{asy}
\caption{Throwback to first year of college?
  High-resolution version at \url{https://web.evanchen.cc/textbooks/poster-stokes.pdf}.}
\label{fig:1802gradcurldiv}
\end{figure}

There is a lot going on in \Cref{fig:1802gradcurldiv}, so let's break it down piece by piece.

\paragraph{$0$-forms.}
A $0$-form is the same as just a function,
so the column of 0-D integrals should be easy to understand:
it's just evaluation at a point, or a sum of points.

\paragraph{$n$-forms.} The case $n=d$ is also easy:
we know it's possible to integrate an $n$-form in $\RR^n$ and get a number. That is:
\begin{itemize}
	\ii A normal integral $\int_a^b \odif x$ is the integral across a $1$-cell $[a,b]$
	across the $1$-form $f \cdot \ee_1^\vee$.

	\ii An area integral $\int_{a_1}^{b_1} \int_{a_2}^{b_2} f(x,y) \odif x \odif y$
	corresponds to integrating the $2$-form $f \cdot \ee_1^\vee \wedge \ee_2^\vee$.

	\ii A volume integral $\int_{a_1}^{b_1} \int_{a_2}^{b_2} \int_{a_3}^{b_3} f(x,y,z) \odif x \odif y \odif z$
	corresponds to integrating the $3$-form $f \cdot \ee_1^\vee \wedge \ee_2^\vee \wedge \ee_3^\vee$.
\end{itemize}
So this takes care of the green-labeled things on the diagonal.

\paragraph{We can't interpret the remaining three green pictures!}
The tricky part is the situations where $0 < d < n < 3$.
There are three such things, the two line integrals when $d=1$ and $n \in \{2,3\}$
and the surface integral when $d=2$ and $n=3$.

In fact, these are \emph{not} covered by our theory of differential forms!
Indeed, even in the special case where $f = 1$ is a constant function,
the line integrals are actually arc length,
and as we mentioned in \Cref{sec:arc_length_not_one_form},
that integral cannot be viewed as the integral of any differential form.
Similarly, surface area isn't a differential form either.

\paragraph{$1$-forms and $2$-forms.}
However, the three purplish integrals (over vector fields) can be viewed in our framework.
\begin{itemize}
	\ii Consider $d = 1$ and $n = 3$, i.e.\ the 3-D line integral.
	We have as input a vector-valued function $\mathbf{F} \colon \RR^3 \to \RR^3$.
	By projection principle (\Cref{thm:project_principle}), it's the same as the data of
	\[ \mathbf{F}(p) = F_1(p) \ee_1 + F_2(p) \ee_2 + F_3(p) \ee_3 \]
	for three functions $F_i \colon \RR^3 \to \RR$ for $i = 1, 2, 3$.

	To convert the 18.02 notation $\mathbf{F}(p)$ into Napkin notation,
	we identify $\mathbf{F}$ with the differential form
	\[ \alpha_p = F_1(p) \ee_1^\vee + F_2(p) \ee_2^\vee + F_3(p) \ee_3^\vee. \]
	Meanwhile, the path $\mathbf{r}(t)$ parametrized by time $t \in [t_0, t_1]$
	matches the concept of a $1$-form $c : [t_0, t_1] \to \RR^3$.
	The ``work'' in the integral is written as
	\[ \mathbf F(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \]
	but that dot product is exactly the pullback $c^\ast\alpha$.

	\ii The case $d = 1$ and $n = 2$ is exactly the same, with $3$ replaced by $2$.

	\ii The weirdest case is the flux integral, for $d = 2$ and $n = 3$.
	The parametrization $\mathbf{r}(u,v)$ is fine, and it corresponds to a $2$-cell $c$.
	But $\mathbf{F}(p)$ seems to have the wrong type.

	But let's again write
	\[ \mathbf{F}(p) = F_1(p) \ee_1 + F_2(p) \ee_2 + F_3(p) \ee_3. \]
	There is a fairly weird hack used to convert this into Napkin notation: the form desired is
	\[ \alpha_p = F_1(p) \ee_2^\vee \wedge \ee_3^\vee
		+ F_2(p) \ee_3^\vee \wedge \ee_1^\vee
		+ F_3(p) \ee_1^\vee \wedge \ee_2^\vee. \]
	Yes, that's really the identification!
	For this definition to be possible, we had to exploit the fact that
	\[ \binom 31 = \binom 32. \]
	That is the three-dimensional space $\bigwedge^2(\RR^3)$
	happens to have the same number of basis elements as $\bigwedge^1(\RR^3) \cong \RR^3$, so the map
	\begin{align*}
		\star \colon \bigwedge^2(\RR^3) &\to \RR^3 \\
		\ee_1 \wedge \ee_2 &\mapsto \ee_3 \\
		\ee_2 \wedge \ee_3 &\mapsto \ee_1 \\
		\ee_3 \wedge \ee_1 &\mapsto \ee_2
	\end{align*}
	is really an isomorphism, because it maps basis elements to basis elements.
	We denote this map by $\star$,
	because it turns out this map generalizes to the so-called Hodge star operator in higher dimensions.

	This is where I talk about cross products, which I've deliberately avoided until now.
	The cross product is a weird operation that takes two vectors in $\RR^3$
	and outputs a vector in $\RR^3$.
	Specifically, if $\mathbf{v} = x \ee_1 + y \ee_2 + z \ee_3$
	and $\mathbf{w} = x' \ee_1 + y' \ee_2 + z' \ee_3$,
	the definition of cross products taught in school is
	\[ \mathbf{v} \times \mathbf{w} \coloneqq (yz'-y'z) \ee_1 + (zx'-xz') \ee_2 + (xy'-x'y) \ee_3. \]
	Where does this come from?
	The answer is that $\star(\mathbf{v} \wedge \mathbf{w})$:
	\begin{align*}
		\mathbf{v} \wedge \mathbf{w} &=
		(x \ee_1 + y \ee_2 + z \ee_3) \wedge (x' \ee_1 + y' \ee_2 + z' \ee_3) \\
		&= (xy'-x'y) \ee_1 \wedge \ee_2
		+ (yz'-y'z) \ee_2 \wedge \ee_3
		+ (zx'-xz') \ee_3 \wedge \ee_1 \\
		\star(\mathbf{v} \wedge \mathbf{w})
		&\mapsto (xy'-x'y) \ee_3
		+ (yz'-y'z) \ee_1
		+ (zx'-xz') \ee_2.
	\end{align*}
	With that out of the way, the weird dot-cross product
	\[ \mathbf{F}(\mathbf{r}(u,v)) \cdot \left( \mathbf{r}_u \times \mathbf{r}_v \right) \odif{u} \odif{v} \]
	is now rigged to correspond to the pullback $c^\ast\alpha$.
	So using this Hodge star, we find that flux is actually the integration of a $2$-form.
\end{itemize}

\paragraph{Exterior derivatives}
Every red arrow in \Cref{fig:1802gradcurldiv} corresponds to the exterior derivative
of the corresponding form.
That is:
\begin{itemize}
	\ii The ``grad'' operation takes a $0$-form $f$ and outputs a vector field
	corresponding to the $1$-form $df$.

	\ii The ``curl'' operation takes a $1$-form $\alpha$ and outputs a vector field
	corresponding to the $2$-form $d\alpha$.
	When $n = 3$, this checks out because the space of $1$-forms is $\binom 31$ dimensional,
	and the space of $2$-forms is $\binom 32$, and thankfully $\binom 31 = 3 = \binom 32$.

	The weird notation $\nabla \times \mathbf{F}$
	can be checked to correspond to the exterior derivative.
	On the 18.02 side, if we have
	\[ \mathbf{F} = F_1 \ee_1 + F_2 \ee_2 + F_3 \ee_3 \]
	then the 18.02 definition of curl is that
	\[ \opname{curl}(\mathbf{F}) \coloneqq \nabla \times \mathbf{F} \coloneqq
		\left( \pdv{F_3}{y} - \pdv{F_2}{z} \right) \ee_1
		+ \left( \pdv{F_1}{z} - \pdv{F_3}{x} \right) \ee_2
		+ \left( \pdv{F_2}{x} - \pdv{F_1}{y} \right) \ee_3
	\]
	The reason for the nonsensical $\nabla \times$ notation
	is that if you \emph{really} abuse notation you can almost think of this as
	the cross product of a vector $\nabla = \left< \pdv{}x, \pdv{}y, \pdv{}z \right>$
	and the vector $\mathbf{F} = \left< F_1, F_2, F_3 \right>$.

	Now to convert $\mathbf{F}$ into Napkin notation,
	remember we identified $\mathbf{F}$ with the differential form
	\[ \alpha = F_1 \ee_1^\vee + F_2 \ee_2^\vee + F_3 \ee_3^\vee. \]
	If we follow our formula for exterior derivative in \Cref{def:exterior_derivative}, we get
	\begin{align*}
		d\alpha &= dF_1 \wedge \ee_1^\vee + dF_2 \wedge \ee_2^\vee + dF_3 \wedge \ee_3^\vee \\
		&= \left( \pdv{F_1}{x} \ee_1^\vee + \pdv{F_1}{y} \ee_2^\vee + \pdv{F_1}{z} \ee_3^\vee \right) \wedge \ee_1^\vee \\
		&+ \left( \pdv{F_2}{x} \ee_1^\vee + \pdv{F_2}{y} \ee_2^\vee + \pdv{F_2}{z} \ee_3^\vee \right) \wedge \ee_2^\vee \\
		&+ \left( \pdv{F_3}{x} \ee_1^\vee + \pdv{F_3}{y} \ee_2^\vee + \pdv{F_3}{z} \ee_3^\vee \right) \wedge \ee_3^\vee \\
		&=
		\left( \pdv{F_3}{y} - \pdv{F_2}{z} \right) \ee_2^\vee \wedge \ee_3^\vee
		+ \left( \pdv{F_1}{z} - \pdv{F_3}{x} \right) \ee_3^\vee \wedge \ee_1^\vee
		+ \left( \pdv{F_2}{x} - \pdv{F_1}{y} \right) \ee_1^\vee \wedge \ee_2^\vee.
	\end{align*}
	Taking the Hodge star and then dropping all the $\vee$'s
	gives the same thing as $\nabla \times \mathbf{F}$,
	so this completes the correspondence between the 18.02 notation and the Napkin notation.

	\ii In 18.02 terminology, the divergence $\opname{div}$ is defined by
	\[ \opname{div}(\mathbf{F}) \coloneqq \nabla \cdot \mathbf{F} \coloneqq
		\pdv{F_1}{x} + \pdv{F_2}{y} + \pdv{F_3}{z} \]
	which is a scalar-valued function for input points $p \in \RR^3$.
	We let you do this one in \Cref{prob:div1802}.

	The reason for the nonsensical $\nabla \cdot$ notation
	is that if you \emph{really} abuse notation you can almost think of this as
	the dot product of a vector $\nabla = \left< \pdv{}x, \pdv{}y, \pdv{}z \right>$
	and the vector $\mathbf{F} = \left< F_1, F_2, F_3 \right>$.
\end{itemize}

\paragraph{Double derivative}
We know that $d^2=0$,
which in \Cref{fig:1802gradcurldiv} means composing two arrows gives zero.
You'll see this in 18.02 as
\begin{itemize}
	\ii The curl of a gradient is zero.
	\ii The flux of a curl is zero.
\end{itemize}
but really they're the same theorem.

\paragraph{Stokes' theorem}
Each red arrow also gives an instance of Stokes' theorem for cells.
So Stokes' theorem even for cells is really great,
because we get six 18.02 theorems as special cases!
\begin{itemize}
	\ii The three arrows from 0-D integrals to 1-D integrals are all called
	``Fundamental Theorem of Calculus''.
	Some authors will say ``Fundamental Theorem of Calculus for line integrals''
	instead for $n > 1$.

	\ii For $n=2$, the other red arrow is called ``Green's theorem'';
	we let you work it out as \Cref{sec:green_theorem}.

	\ii For $n=3$, the arrow from work to flux is confusingly also called
	``Stokes' theorem''; it says the flux of a 2-D surface equals the work on the 1-D boundary.

	\ii The rightmost red arrow for $n = 3$
	is called the ``divergence theorem'';
	it says the divergence of a 3-D volume equals the flux of the 2-D boundary surface.
\end{itemize}



\section\problemhead
\begin{dproblem}[Green's theorem]
	Let $f,g \colon \RR^2 \to \RR$ be smooth functions and $c$ a $2$-cell.
	Prove that
	\[ \int_c \left( \fpartial gx - \fpartial fy \right) \; dx \wedge dy
	= \int_{\partial c} (f \; dx + g \; dy). \]
	\label{sec:green_theorem}
	\begin{hint}
		Direct application of Stokes' theorem to $\alpha = f \; dx + g \; dy$.
	\end{hint}
\end{dproblem}

\begin{problem}
	Show that $\partial^2 = 0$.
	\label{prob:partial_zero}
	\begin{hint}
		This is just an exercise in sigma notation.
	\end{hint}
\end{problem}

\begin{problem}
	Finish the correspondence of the 18.02 notation with Napkin notation.
	That is, let $\mathbf{F} \colon \RR^3 \to \RR^3$ be a vector field,
	and let $\alpha$ be the $2$-form corresponding to it in Napkin version.
	Show that the scalar-valued function defined by
	\[ \opname{div}(\mathbf{F}) \coloneqq \nabla \cdot \mathbf{F} \coloneqq
		\pdv{F_1}{x} + \pdv{F_2}{y} + \pdv{F_3}{z} \]
	coincides with evaluation at the $3$-form $d\alpha$.
	\label{prob:div1802}
\end{problem}

\begin{problem}[Pullback and $d$ commute]
	Let $U$ and $U'$ be open sets of vector spaces $V$ and $V'$
	and let $\phi \colon U \to U'$ be a smooth map between them.
	Prove that for any differential form $\alpha$ on $U'$ we have
	\[ \phi^\ast(d\alpha) = d(\phi^\ast\alpha). \]
	\begin{hint}
		This is a straightforward (but annoying) computation.
	\end{hint}
\end{problem}

\begin{problem}[Arc length isn't a form]
	\label{prob:ds_not_a_form}
	Show that there does \emph{not} exist a $1$-form $\alpha$ on $\RR^2$ such that
	for a curve $c \colon [0,1] \to \RR^2$,
	the integral $\int_c \alpha$ gives the arc length of $c$.
	\begin{hint}
		We would want $\alpha_p(v) = \norm{v}$.
	\end{hint}
\end{problem}

\begin{problem}
	An \vocab{exact} $k$-form $\alpha$ is one satisfying $\alpha = d\beta$ for some $\beta$.
	Prove that
	\[ \int_{C_1} \alpha = \int_{C_2} \alpha \]
	where $C_1$ and $C_2$ are any concentric circles in the plane
	and $\alpha$ is some exact $1$-form.
	\begin{hint}
		Show that $d^2=0$ implies $\int_{\partial c} \alpha = 0$ for exact $\alpha$.
		Draw an annulus.
	\end{hint}
\end{problem}
