\newsection
\subsection{The Green Formula}
\label{sec:green-formula}
\compactdef{Simple parametrized curve} $\gamma : [a, b] \rightarrow \R^2$ is a closed parametrized curve s.t.
$\gamma(t) \neq \gamma(s)$ (if $s \neq t$ and $\{ s, t \} = \{ a, b \}$), s.t. $\gamma'(t) \neq 0$ for $a < t < b$.
If $\gamma$ only piecewise in $C^1$ in $]a, b[$, then only apply when $\gamma'(t)$ exists.

\stepLabelNumber{all}
\compacttheorem{Green's Formula} $X \subseteq \R^2$ compact set with boundary $\partial X = \gamma_1 \cup \ldots \cup y_k$
with $\gamma_i = (\gamma_{i, 1}, \gamma_{i, 2}) : [a_i, b_i] \rightarrow \R^2$ a simple closed parametrized curve, with property that $X$ lies ``to the left'' of tangent vector $\gamma_i'(t)$ based at $\gamma_i(t)$.
$f = (f_1, f_2)$ is a vector field of class $C^1$ on open set containing $X$. Then:
\drmvspace
\begin{align*}
    \int_{X} \left( \frac{\partial f_2}{\partial x} - \frac{\partial f_1}{\partial y} \right) \dx x \dx y = \sum_{i = 1}^{k} \int_{\gamma_i} f \cdot \dx \vec{s}
\end{align*}

\stepLabelNumber{all}\dhrmvspace
\inlinecorollary $X \subseteq \R^2$ compact with boundary $\partial X$ as before.
$\gamma_i$ as above, then
\drmvspace
\begin{align*}
    \text{Vol}(X) = \sum_{i = 1}^{k} \int_{\gamma_i} x \dx \vec{s} = \sum_{i = 1}^{k} \int_{a_i}^{b_i} \gamma_{i, 1}(t) \gamma_{i, 2}'(t) \dx t
\end{align*}

\drmvspace
\shade{gray}{Understanding and applying Green's Formula} The $\frac{\partial f_2}{\partial x} - \frac{\partial f_1}{\partial y} = \text{curl}(f)$, i.e. it is the 2D-curl of $f$.
Thus, the sum of all line integrals is the same thing as the Riemann-Integral of the curl.

We can use Green's Formula to compute integrals. For that we need the set of curves that define the set.
For the \bi{unit circle}, that is just one curve,
being $\gamma(t) = \begin{pmatrix}
        R \cdot \cos(t) \\
        R \cdot \sin(t)
    \end{pmatrix}$, with $t \in [0, 2\pi]$.
We then use the curve as the vector $\vec{s}$ in Green's Formula.
As a reminder, the vectors are multiplied with the dot product.
If we just have one curve, there is no sum (i.e. the sum sums up all the integral of all curves)

\numberingOff
\inlineex To compute the line integral of the vector field $f(x, y) = \begin{pmatrix}
    x + y\\
    3x + y^2
\end{pmatrix}$ over a complicated curve.
Instead of computing the line integral, we can use Green's Formula to compute the curl over the set enclosed by the curve.
This has the benefit that depending on the vector field, we won't even have to evaluate the integral:
\begin{align*}
    \int_{S} \frac{\partial f_2}{\partial x} - \frac{\partial f_1}{\partial  y} \dx x \dx y = \int_{S} (3 - 1) \dx x \dx y = \int_{S} 2\dx x \dx y
    = 2 \left( (2 \cdot 1) + \frac{1}{2} \pi \right) = 4 + \pi
\end{align*}
for the set $S = \{ (x, y) \divides x \in [0, 2], y \in [-1, 0] \} \cup \{ (x, y) \divides (x - 1)^2 + y^2 \leq 1, y \geq 0 \}$.

That set is derived from the image that is given for the line.
Be cognizant of what direction the integral goes, if the set is on the right hand side of the curve, the final result has to be negated to change the direction of the integral.
If the curve doesn't fully enclose the set, then we can simply compute the line integrals of the missing sections and subtract them from the final result.

We can also use \hl{known formulas} to compute the area of discs, etc (like $2 \cdot r \cdot \pi$ for the outline of a circle).
To calculate the area enclosed by a curve using Green's formua, if not given a vector field, we can use the vector field $F(x, y) = (0, x)$.

\shade{gray}{Center of mass}
The center of mass of an object $\cU$ is given by $\displaystyle \overline{x}_i = \frac{1}{\text{Vol}(\cU)} \int_{\cU} x_i \dx x$.

\rmvspace
\shade{gray}{Dot product} For vectors $v, w \in \R^n$, we have $\displaystyle v \cdot w = \sum_{i = 1}^{n} v_i \cdot w_i$

\rmvspace
\shade{gray}{Matrix-Vector product} Given vector $v\in \R^m$ and matrix $A \in \R^{n \times m}$,
we have $A \cdot v = u$ where $ \displaystyle u_j = \sum_{i = 1}^{m} v_i \cdot A_{j, i}$.

\hl{Important} If you can't see the set parametrization, it is likely faster to directly do line integrals.
