\subsection{Line Integrals}

\begin{subbox}{Integrals for $f:I \to \R^n$}
    \smalltext{$I = [a,b] \text{ closed \& bounded},\quad f: I \to \R^n \text{ cont.}$}
    $$\int_a^b f(t)\ dt = \Biggl( \int_a^b f_1(t)\ dt,\ldots, \int_a^b f_n(t)\ dt \Biggr)$$
\end{subbox}

\definition \textbf{Piecewise Continuity}\\
$\exists k \geq 1$, and a Partition $a = t_0 < \cdots < t_k = b$\\
s.t. $f_j: [t_{j-1},t_j]\to\R^n$ has $f_j \in C^1$ for all $j \leq k$\\
\subtext{For $f: I \to \R^n$}

\definition \textbf{Parametrized Curve} $\gamma: [a,b] \to \R^n$ pw.-cont.\\
\subtext{Also called \textit{Path} from $\gamma(a)$ to $\gamma(b)$}

\begin{subbox}{Line Integral}
    \smalltext{$\gamma: [a,b] \to \R^n$ is path$,\quad X \subset \R^n$ s.t. $\gamma\bigl([a,b]\bigr) \subset X\\
    f:X\to\R^n \text{ continuous}$}
    $$
        \int_\gamma f(s)\cdot\ ds := \int_a^b f\Bigl( \gamma(t) \Bigr) \cdot \gamma'(t)\ dt
    $$
\end{subbox}

\definition \textbf{Continuous integrals are linear}
$$
    \int_a^b\Bigl( f(t) + g(t) \Bigr)\ dt = \int_a^b f(t)\ dt + \int_a^b g(t)\ dt
$$
\subtext{$f,g: I \to \R^n \text{ continuous}$}

\remark $f: X \to \R^n$ is called a \textit{Vector Field}.

\definition \textbf{Oriented Reparametrization}\\
\smalltext{For $\gamma: [a,b] \to \R^n$ (param. curve), $\phi:[c,d] \to [a,b]$ continuous}
$$
    \sigma: [c,d] \to \R^n \text{ s.t. } \sigma = \gamma \circ \phi
$$
\subtext{diff.-able on $(c,d)$, strictly increasing and $\phi(c) = a, \phi(d) = b$}

\newpage % to keep the elements below together
\lemma \textbf{Oriented Reparametrizations preserve Integrals}
$$
    \int_\gamma f(s)\cdot ds = \int_\sigma f(s)\cdot ds
$$
\subtext{$\gamma: [a,b] \to \R^n$ param. curve$,\quad \sigma$ oriented reparam.$,\\ 
\gamma([a,b]) \subset X,\quad f: X \to \R^n \text{ cont.}$}

\remark Line Integrals of the form $\int_\gamma \nabla f(s) \cdot ds$ have:
$$
    \int_\gamma \nabla f(s) \cdot ds = \int_a^b \sum_{i=1}^{n}\frac{\partial g}{\partial x_i}\Bigl( \gamma(t) \Bigr) \gamma_i'(t) = f\Bigl( \gamma(b) \Bigr) - f\Bigl( \gamma(a) \Bigr)
$$
\subtext{Follows from the Chain rule for $h(t) = g(\gamma(t))$}\\
\subtext{$X \subset \R^n \text{ open},\quad f: X \to \R,\quad f \in C^1,\quad \gamma: [a,b] \to X \text{ param. curve}$}

\definition \textbf{Conservative Vector Field}\\
\smalltext{$f: X\to\R$ conservative $\iffdef \forall \gamma_1,\gamma_2$ s.t. start \& end points match:}
$$
    \int_{\gamma_1} f(s)\cdot ds = \int_{\gamma_2} f(s)\cdot ds
$$
\subtext{No matter which path, if start \& end match, the integral matches}

\remark \textbf{Closed Curves in Conservative Vector Fields}
$$
    \forall\ \gamma: [a,a] \to \R:\quad \int_\gamma f(s) \cdot ds = 0
$$
\subtext{This is actually equivalent to $f$ being conservative.}

\begin{subbox}{The Potential exists in Conservative Vector Fields}
    \smalltext{$X \subset \R^n \text{ open},\quad f \text{ conservative}$}
    \begin{align*}
        \exists g \in C^1:\quad f = \nabla g
    \end{align*}
    \smalltext{If $x_1,x_2 \in X$ are joined by a $\gamma$, $g$ is unique up to $C \in \R$}
    \begin{align*}
        \nabla g_1 = f \implies g - g_1 \text{ is constant on } X
    \end{align*}
\end{subbox}

\definition \textbf{Path-Connected Set}\\
$\forall x_1,x_2 \in X: \exists \gamma: [a,b] \to X$ s.t. $\gamma(a) = x_1, \gamma(b) = x_2$

\newpage

\lemma \textbf{Property of Conservative Vector Fields}\\
\smalltext{Easy way to e.g. disprove $f$ being conservative:}
$$
    \forall 1 \leq i \neq j \leq n:\quad \frac{\partial f_i}{\partial x_j} = \frac{\partial f_j}{\partial x_i}
$$
\smalltext{Equivalently:}
$$
    \textbf{J}_f(x) = \textbf{J}_f(x)^\top
$$

\subtext{$X \subset \R^n \text{ open},\quad f: X\to\R^n,\quad f \in C^1,\quad f \text{ conserv.}$}\\
\subtext{Only this way: This being true (alone) does not imply $f$ is conservative!}

\definition \textbf{Star Shaped Set}\\
$\exists x_0 \in X: \forall x \in X$ Line seg. $x_0 \to x$ is in $X$

\definition \textbf{Convex Set}\\
$\forall x_1,x_2 \in X:$ Line seg. $x_1 \to x_2$ is in $X$\\
\subtext{Convex implies star shaped.}

\theorem \textbf{Some Star Shaped Sets are conservative}\\
\smalltext{In open star-shaped sets $X \subset \R^n$:} \subtext{$f \in C^1$}
$$
    \forall 1 \leq i \neq j \leq n: \frac{\partial f_i}{\partial x_j} = \frac{\partial f_j}{\partial x_i} \implies f \text{ conservative}
$$
\subtext{This is the most common way to prove/disprove $f$ being conservative.}

\definition $\text{curl}(f) := \begin{bmatrix}
    \partial_y f_3 - \partial_z f_2 \\
    \partial_z f_1 - \partial_x f_3 \\
    \partial_x f_2 - \partial_y f_1
\end{bmatrix}$ \subtext{$f: X \to \R^3,\quad f \in C^1$}

\remark $\text{curl}(f) = 0 \iff \forall 1 \leq i \neq j \leq 3: \displaystyle\frac{\partial f_i}{\partial x_j} = \displaystyle\frac{\partial f_j}{\partial x_i}$

\remark $\text{curl}(\nabla f) = 0$ if $f: \R^n \to \R$ is in $C^2$.\\
\subtext{i.e. if $f$ has a potential.}

\method \textbf{Finding the Potential}

\smalltext{
    We want $g$ s.t. $\nabla g = f$ for some conservative $f$
    \begin{enumerate}
        \item Find $\displaystyle\int f_i\ dx_i$ for all $i \leq n$
        \item Define $g$ as the union of terms in $\displaystyle\int f_i\ dx_i$
        \item $g$ now has $\partial x_i g_i = f_i$ thus $\nabla g = f$ 
    \end{enumerate} 
    Note that the union step \textit{only works} if $f$ is conservative.
}


\newpage
\subsection{The Riemann Integral in $\R^n$}

\smalltext{For $f: X \to \R$ ($X \subset \R^n$ bounded \& closed), $\displaystyle\int_X f(x)\ dx$ fulfills:}

\begin{enumerate}
    \item \textbf{Composability}\\
    \smalltext{$\displaystyle\int_X f(x)\ dx = \int_a^b f(x)\ dx$} \subtext{$n=1, X=[a,b]$}
    \item \textbf{Linearity}\\
    \smalltext{$\displaystyle\int_X \Bigl( af_1(x) + bf_2(x) \Bigr)\ dx = a \int_X f_1(x)\ dx + b \int_X f_2(x)\ dx$}\\
    \subtext{$f,g$ cont. on $X$, $a,b \in \R$}
    \item \textbf{Positivity}\\
    \smalltext{$f \leq g \implies \displaystyle\int_X f(x)\ dx \leq \int_X g(x)\ dx$}
    \item \textbf{Upper Bound}\\
    \smalltext{$\left\lvert \displaystyle\int_X f(x)\ dx \right\rvert \leq \int_X |f(x)|\ dx$}
    \item \textbf{Triangle Inequality}\\
    \smalltext{$\left\lvert \displaystyle\int_X \Bigl( f(x) + g(x) \Bigr)\ dx \right\rvert \leq \displaystyle\int_X |f(x)|\ dx + \displaystyle\int_X |g(x)|\ dx$}
    \item \textbf{Volume}\\
    \smalltext{$\displaystyle\int_X f(x)\ dx}$ is the volume of $\Bigl\{ (x,y) \in X \times \R \ \Big\vert\ 0 \leq y \leq f(x) \Bigr\}$\\
    \subtext{So the intuitive idea of $\int_a^b f(x)\ dx$ being the area carries over.}
    \item \textbf{Domain Additivity}\\
    \smalltext{$\displaystyle\int_{X_1 \cup X_2} f(x)\ dx + \int_{X_1 \cap X_2} f(x)\ dx = \int_{X_1} f(x)\ dx + \int_{X_2} f(x)\ dx$}\\
    \subtext{If $X_1,X_2$ are compact, $f$ is cont. on $X_1 \cup X_2$}
\end{enumerate}

\begin{subbox}{Fubini's Theorem: Multiple Integrals}
    \smalltext{$f: X \to \R,\quad n = n_1 + n_2,\quad n_1,n_2 \geq 1$}
    \begin{align*}
        & X_{x_1} &:=\quad& \Bigl\{ x_2 \in \R^{n_2} \ \Big\vert\ (x_1,x_2) \in X \Bigr\} \subset \R^{n_2} \\
        & X_{1}  &:=\quad& \Bigl\{ x_1 \in \R^{n_1} \ \Big\vert\ X_{x_1} \neq \emptyset \Bigr\} \subset \R^{n_1} 
    \end{align*}
    If $g(x_1) := \displaystyle\int_{X_{x_1}}f\Bigl( (x_1,x_2) \Bigr)\ dx_2$ is continuous on $X_1$:
    $$
        \int_X f(x)\ dx = \int_{X_1}\Biggl( \int_{X_{x_1}} f\Bigl( (x_1,x_2) \Bigr)\ dx_2 \Biggr)\ dx_1
    $$
    \smalltext{The role of $x_1,x_2$ can be swapped, if $f$ is continuous.}
\end{subbox}
\newpage

\definition \textbf{Parametrized $m$-Set in $\R^n$}\\
$f: [a_1,b_1]\times\cdots\times[a_m,b_m] \to \R$\\ 
s.t. $f \in C^1$ on $(a_1,b_1)\times\cdots\times(a_m,b_m)$\\
\subtext{A param. $1$-set in $\R^n$ is just a param. curve}

\definition \textbf{Negligible Subset}\\
$B \subset \R^n$ s.t. $\exists k \geq 0$ param. $m_i$-sets: $f_i:X_i\to\R^n$ s.t.
$$
    B \subset f_1(X_1) \cup \cdots \cup f_k(X_k)
$$
\subtext{$1 \leq i \leq k,\quad m_i < n$}\\

\begin{footnotesize}
    \remark For an affine subspace $H \subset \R^n$ with $\dim(H) < n$, any $X \subset \R^n$ contained in $H$ is Negligible

    \remark The image of a param. curve $\gamma: [a,b] \to \R^n$ is negligible.\\
    \color{gray} $\gamma$ is a $1$-set in $\R^n$ \color{black}
\end{footnotesize}

\lemma \textbf{Integral of Negligible Sets}\\
\smalltext{For continuous $f: X \subset \R^n \to \R$}:
$$
    X \text{ negligible } \implies \int_X f(x)\ dx = 0
$$

\subsection{Improper Integrals}
\smalltext{$I \subset \R$ bounded,$\quad J = [a,+\infty]$ for $a \in \R,\quad f$ cont. on $X = J \times I$}
$$
    \underset{x \to \infty}{\lim}\int_{[a,x]\times I}f(x,y)\ dxdy = \underbrace{\int_a^\infty \Biggl( \int_I f(x,y)\ dy \Biggr) dx}_\text{Order of Integration may change}
$$
\subtext{The improper integral on the right is simply a regular improper integral.}

\smalltext{If this Limit is equal for both orders of Integration:}

\definition \textbf{Improper Integral in $\R^2$}
$$
    \int_{J \times I} f(x,y)\ dxdy := \underset{x \to \infty}{\lim}\int_{[a,x]\times I}f(x,y)\ dxdy
$$

\definition \textbf{Integral over $\R^2$}
$$
    \int_{\R^2} f(x,y)\ dxdy := \underset{R \to \infty}{\lim}\int_{[-R,R]^2} f(x,y)\ dxdy
$$

\begin{footnotesize}
    \remark if $|f| \leq g$, and an impr. Integr. exists on g, it exists on $f$.
\end{footnotesize}

\newpage
\subsection{Change of Variable}

\begin{footnotesize}
    $\bar{X},\bar{Y} \subset \R^n$ compact, $\varphi: \bar{X} \to \bar{Y}$ cont.\\
    We have: $\bar{X} = X \cup B,\quad \bar{Y} = Y \cup C$ s.t.
    \begin{enumerate}
        \item $X,Y$ are open
        \item $B,C$ are negligible
        \item $\varphi$ on $X$ is a $C^1$ map $\varphi: X \to Y$
    \end{enumerate}
\end{footnotesize}

\begin{subbox}{Change of Variable in $\R^n$}
    \smalltext{$\bar{X},\bar{Y}$ as above, $\quad f$ cont. on $\bar{Y}$ arbitrary}
    $$
        \int_{\bar{X}} f\Bigr( \varphi(x) \Bigl) \cdot \left\vert \det(\textbf{J}_\varphi(x)) \right\vert\ dx = \int_{\bar{Y}} f(y)\ dy
    $$
\end{subbox}

\begin{footnotesize}
    \remark Translations: $\varphi(x) = x + x_0$ have $\textbf{J}_\varphi(x) = \textbf{I}_n$\\
    so the volume is preserved: $\displaystyle\int_{\bar{X}}f(x+x_0)\ dx = \int_{x_0 + \bar{X}} f(x)\ dx$    

    \remark Linear maps: $\varphi(x) = \textbf{A}x$ have $\textbf{J}_\varphi(x) = \textbf{A}$\\
    The change of variable is: $\displaystyle\int_{\bar{X}} f\Bigl( \varphi(x) \Bigr)\ dx = \frac{1}{\left\vert \det(\textbf{A}) \right\vert} \int_{\bar{Y}}f(y)\ dy$
\end{footnotesize}

\subsection{Green's Theorem}

\definition \textbf{Simple Closed Parametrized Curve}\\
$\gamma: [a,b] \to \R^2$ closed param. curve s.t.
\begin{enumerate}
    \item $\gamma(t) \neq \gamma(s)\quad$ unless $s = t$, or $\{s,t\} = \{a,b\}$
    \item $\gamma'(t) \neq 0\quad \forall a < t < b$
\end{enumerate}
\subtext{Example: $\varphi(t) = \Bigl( x_0 + r\cos(t),\ y_0 + r\sin(t) \Bigr)$}

\begin{subbox}{Green's Theorem}
    \smalltext{$X \subset \R^2 \text{ compact with Boundary } \partial X = \displaystyle\underset{1 \leq i \leq n}{\bigcup} \gamma_i$ as above}\\
    \smalltext{Assume: $\gamma_i: [a_i,b_i] \to \R^2$ s.t. $X$ is always \textit{left} of $\gamma_i'(t)$ at $\gamma_i(t)$}
    $$
    \int_X \Biggl( \underbrace{\frac{\partial f_2}{\partial x} - \frac{\partial f_1}{\partial y}}_{\text{curl}(f)} \Biggr)\ dxdy = \sum_{i=1}^{k} \int_{\gamma_i} f \cdot ds
    $$
    \smalltext{For a $C^1$ Vector field $f=(f_1,f_2)$ containing $X$}
\end{subbox}
\subtext{So, a sum of line integrals can be written as the Integral of the curl.\\ This is very useful for computing complex line integrals.}

\lemma \textbf{Volume using Green}
$$
    \text{Vol}(X) = \sum_{i=1}^{k} \int_{\gamma_i} x \cdot ds = \sum_{i=1}^{k} \int_{a_i}^{b_i} \gamma_{i,1}(t)\cdot \gamma_{i,2}'(t)\ dt
$$
\subtext{Same assumptions as above.}

\footnotesize
\remark The \textit{Gauss-Ostrogradski} Formula exists for $\R^3$.
\normalsize

\begin{footnotesize}
    \textbf{Example:} Finding an Area using Green:
    $$
        \text{Area}(X) = \int_X 1\ dxdy
    $$
    To use Green, we want $f$ s.t. $(\partial_x f_y - \partial_y f_x) = 1$. Common Choices:
    \begin{enumerate}
        \item $f(x,y) = (0, x)$
        \item $f(x,y) = (-y, 0)$
    \end{enumerate}
    We can then use Green, assuming we have a $\gamma$ for the Boundary of $X$:
    $$
        \text{Area}(X) = \int_X 1\ dxdy = \int_X \bigg(\partial_x f_y - \partial_y f_x \bigg) \ dxdy = \int_\gamma f(s)\ ds
    $$
\end{footnotesize}

\subsection{Useful Parametrizations}

\begin{footnotesize}
   \textbf{Circle:} $x^2 + y^2 = r^2$
    $$
        \gamma: [0, 2\pi] \mapsto \begin{pmatrix}
            r\cos(t) \\
            r\sin(t)
        \end{pmatrix} 
        \qquad
        \gamma: [0, 2\pi] \mapsto \begin{pmatrix}
            r\cos(t) \\
            -r\sin(t)
        \end{pmatrix}
    $$
    \color{gray} Clockwise \& Counterclockwise \color{black}

    \textbf{Ellipsoid:} $\displaystyle\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$
    $$
        \gamma: [0, 2\pi] \mapsto \begin{pmatrix}
            a\cos(t) \\
            b\sin(t)
        \end{pmatrix}
        \qquad
        \gamma: [0, 2\pi] \mapsto \begin{pmatrix}
            a\cos(t) \\
            -b\sin(t)
        \end{pmatrix}
    $$
    \color{gray} Clockwise \& Counterclockwise \color{black}

    \textbf{Piecewise Continuous function:} $f(x)$
    $$
        \gamma: [a, b] \mapsto \bigl(t, f(t) \bigr)
    $$

    \textbf{Line Segment:} $(x_0,y_0,z_0) \to (x_1,y_1,z_1)$
    $$
        \gamma: [0, 1] \mapsto (1-t)
        \begin{pmatrix}
            x_0 \\
            y_0 \\
            z_0
        \end{pmatrix}
        + t
        \begin{pmatrix}
            x_1 \\
            y_1 \\
            z_1
        \end{pmatrix}
    $$
    \color{gray} This is simply linear interpolation in $\R^3$ \color{black} 
\end{footnotesize}
\subsection{Common Changes}
\begin{footnotesize}

    \textbf{Polar Coordinates} ($\R^2$)\\ 
    $$
        \varphi(r, \theta) = \begin{pmatrix}
        r\cos(\theta)\\
        r\sin(\theta)
        \end{pmatrix} \qquad \color{gray} \theta \in [0, 2\pi) 
    $$
    $dxdy = r\ dr\ d\theta$

    \textbf{Elliptic Coordinates} ($\R^2$)\\
    $$
        \varphi(r, \theta) = \begin{pmatrix}
            ra\cos(\theta) \\
            rb\sin(\theta)
        \end{pmatrix} \qquad \color{gray} \theta \in [0, 2\pi) 
    $$
    $dxdy = a\cdot b\cdot r\ dr\ d\varphi$

    \textbf{Cylindrical Coordinates} ($\R^3$)\\
    $$
        \varphi(r, \theta, z) = \begin{pmatrix}
        r\cos(\theta) \\
        r\sin(\theta) \\
        z
        \end{pmatrix} 
        \qquad \color{gray} \theta \in [0, \pi), \phi \in [0, 2\pi)
    $$
    $dxdydz = r\ dr\ d\theta\ dz$

    \textbf{Spherical Coordinates} ($\R^3$)\\
    $$
        \varphi(r, \theta, \phi) = \begin{pmatrix}
        r\sin(\phi)\cos(\theta) \\
        r\sin(\phi)\sin(\theta) \\
        r\cos(\phi)
        \end{pmatrix}
        \qquad \color{gray} \theta \in [0, \pi), \phi \in [0, 2\pi)
    $$
    $dxdydz = r^2\cdot\sin(\phi)\ dr\ d\theta\ d\phi$

    \textbf{Corresponding Jacobians}:
    $$
    \textbf{J}_1 = \begin{bmatrix}
        \cos(\theta) & -r\sin(\theta) \\
        \sin(\theta) & r\cos(\theta)  \\
    \end{bmatrix}
    \qquad
    \textbf{J}_2 = \begin{bmatrix}
        \cos(\theta) & -r\sin(\theta) & 0 \\
        \sin(\theta) & r\cos(\theta)  & 0 \\
        0            & 0              & z
    \end{bmatrix}
    $$
    $$
    \textbf{J}_3 = \begin{bmatrix}
        \cos(\phi)\sin(\theta) & -r\sin(\phi)\sin(\theta) & r\cos(\phi)\cos(\theta) \\
        \sin(\phi)\sin(\theta) & r\cos(\phi)\sin(\theta)  & r\sin(\phi)\cos(\theta) \\
        \cos(\theta)           & 0                        & -r\sin(\theta)
    \end{bmatrix}
    $$

    % https://en.wikipedia.org/wiki/Spherical_coordinate_system#/media/File:3D_Spherical.svg
    % \begin{center}
    %     \includegraphics[width=0.3\linewidth]{res/spherical-coords.png}
    % \end{center}
\end{footnotesize}
