\newpage
\chapter[Cauchy's Integral Formula]{Cauchy's Integral Formula and its Applications}
\section{Cauchy's Integral Formula}
We have seen so far that if $f:\mathcal{R} \to \C$ is holomorphic on a starlit region $\mathcal{R}$ then
\[
\int_{\mathcal{C}} f = 0
\]
for any closed contour $\mathcal{C}$ in $\mathcal{R}$. What happens when $\mathcal{R}$ is not starlit?

It may happen that while $\mathcal{R}$ itself is not starlit, the contour $\mathcal{C}$ is contained in a starlit subregion $\mathcal{S}$ of $\mathcal{R}$.

\begin{figure}[H]
\begin{tabular}{ccc}
\includegraphics[scale=1]{ch5_notsc3} & \quad \includegraphics[scale=1]{ch5_notsc1} \quad & \includegraphics[scale=1]{ch5_notsc2}
\end{tabular}
\caption{The region $\mathcal{R}$ consists of the complex plane with a disc centred at the origin removed.  This region is not starlit, but there are starlit subregions of $\mathcal{R}$ containing the contour $\mathcal{C}$.}
\end{figure}

Thus if $f$ is holomorphic on $\mathcal{R}$, then $f$ is also holomorphic on $\mathcal{S}$ and so Cauchy's Theorem for Starlit Regions (Theorem~\ref{t:cauchyst}) gives
\[
\int_{\mathcal{C}} f=0.
\]

If $\mathcal{R}$ is not simply connected, then it may not be possible to do this; in particular, when $\mathcal{C}$ encloses a point $z_0$ at which $f$ is not holomorphic.  For example, suppose $f:\C \backslash \set{0} \to \C$ is defined by $f(z) = \dfrac{1}{z}$, and $\mathcal{C}$ is the contour shown in Figure~\ref{f:notsc}.
\begin{figure}[H]
\centering
\includegraphics[scale=0.75]{ch5_notsc}
\caption{A contour $\mathcal{C}$ contained in the non-simply connected region $\C\backslash \set{0}$.}
\label{f:notsc}
\end{figure}

Here $\C \backslash \set{0}$ is not starlit, and there is no starlit subregion of $\C \backslash \set{0}$ containing $\mathcal{C}$.  Nonetheless, in certain circumstances, it is at least possible to replace $\mathcal{C}$ something easier in order to calculate the integral.

\begin{definition}
A contour $\mathcal{C}$, that is not closed, is said to be \emph{simple} if $\mathcal{C}$ does not intersect itself.  A \emph{simple closed contour $\mathcal{C}$} is one that does not intersect itself except that its start point is the same as its end point.
\end{definition}

\begin{figure}[H]
\centering
\includegraphics[scale=0.3]{ch5_simple_full}
\caption{Simple contours.}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[scale=0.3]{ch5_nonsimple_full}
\caption{Non-simple contours.  Note that the closed, non-simple contour on the right has no obvious orientation - it is neither clockwise nor anticlockwise.}
\end{figure}

For a simple closed contour $\mathcal{C}$, when we speak of $\mathcal{C}$ being clockwise or anticlockwise, we mean relative to the points enclosed by $\mathcal{C}$.  In other words, a contour $\mathcal{C}$ is anticlockwise if, as we travel along $\mathcal{C}$, the region enclosed by $\mathcal{C}$ always lies to our left.  Again, we shall avoid giving a precise definition, and treat this notion informally.

The following Theorem shows us how in some cases, a potentially complicated contour integral may be reduced to an easier one.
\begin{theorem}[Shrinking Contour Theorem/Deformation Theorem]
\label{t:sc}
Let $\mathcal{R}$ be a simply connected region, $\mathcal{C}$ an anticlockwise, simple closed contour in $\mathcal{R}$, $z_0$ a point enclosed by $\mathcal{C}$ and $g$ a function which is holomorphic on $\mathcal{R} \backslash \set{z_0}$.  Then
\[
\int_{\mathcal{C}} g = \int_{\mathcal{C}_r} g
\]
where $\mathcal{C}_r$ is an anticlockwise circular contour with centre $z_0$ and radius $r$, which is small enough so that $\mathcal{C}_r$ is contained in $\mathcal{R}$.
\end{theorem}
\begin{center}
\includegraphics[scale=0.75]{ch5_scnotstarlit4}
\end{center}
{\bf Sketch of Proof}

Let us first consider the case where $\mathcal{R} = \C$ as shown:
\begin{center}
\altgraphics[scale=1]{ch5_shrinking_cont_full}{ch5_shrinking_cont}
\end{center}
\begin{blankbox}
Draw a straight line through $z_0$ to get two starlit subregions $\mathcal{R}_1$ and $\mathcal{R}_2$, with $g$ holomorphic on both $\mathcal{R}_1$ and $\mathcal{R}_2$. Join $\mathcal{C}$ and $\mathcal{C}_r$ along this straight line to get two new (simple, closed, anticlockwise) contours $\mathcal{C}_1$ and $\mathcal{C}_2$ contained in $\mathcal{R}_1$ and $\mathcal{R}_2$ respectively.

By Cauchy's Theorem for Starlit Regions,
\[
\int_{\mathcal{C}_1} g = \int_{\mathcal{C}_2} g = 0.
\]
Moreover,
\[
0= \int_{\mathcal{C}_1} f + \int_{\mathcal{C}_2} f = \int_{\mathcal{C}} f - \int_{\mathcal{C}_r} f,
\]
as the integrals along the straight line segments cancel, leaving us with
\begin{itemize}
\item an anticlockwise copy of $\mathcal{C}$, and
\item a clockwise copy of $\mathcal{C}_r$, i.e., the reverse of $\mathcal{C}_r$.
\end{itemize}
Thus
\[
\int_{\mathcal{C}} f = \int_{\mathcal{C}_r} f.
\]
\end{blankbox}

For more general simply connected regions $\mathcal{R}$, we may need to partition $\mathcal{R}$ into starlit subregions $\mathcal{R}_1,\mathcal{R}_2,\ldots, \mathcal{R}_n$, numbered so that $z_0 \in \mathcal{R}_n$. By joining points on $\mathcal{C}$, we get anticlockwise closed contours $\mathcal{C}^{(1)},\mathcal{C}^{(2)},\ldots,\mathcal{C}^{(n)}$, with $\mathcal{C}^{(j)}$ contained in $\mathcal{R}_j$ for each $j$.  Label the regions $\mathcal{R}_j$ so that $z_0 \in \mathcal{R}_n$.

\begin{center}
\altgraphics[scale=0.3]{ch5_deformation1_full}{ch5_deformation2}
\end{center}

\begin{blankbox}
%\vspace*{12cm}
As before,
\[
\int_{\mathcal{C}} g = \int_{\mathcal{C}^{(1)}} g + \int_{\mathcal{C}^{(2)}} g + \ldots + \int_{\mathcal{C}^{(n)}} g,
\]
as the integrals along the connecting edges cancel in pairs.
\begin{comment}
\leftimage{
\includegraphics[scale=0.3]{ch5_deformation2_full}
}
{
The edge where $\mathcal{C}^{(j)}$ and $\mathcal{C}^{(j+1)}$ intersect is traversed in one direction along $\mathcal{C}^{(j)}$ and in the opposite direction along $\mathcal{C}^{(j+1)}$.  Thus when we compute the sum of the integral of $g$ along $\mathcal{C}^{(j)}$ and along $\mathcal{C}^{(j+1)}$, the contributions made by this connecting edge cancel.
}
\end{comment}

For each $j \neq n$, $g$ is holomorphic on $\mathcal{R}_j$, and $\mathcal{C}^{(j)}$ is a closed contour contained in the starlit region $\mathcal{R}_j$.  Thus by Cauchy's Theorem for Starlit regions, we have
\[
\int_{\mathcal{C}^{(j)}} g = 0\quad \text{ for } j=1,2,\ldots,n-1.
\]

Combining these two observations it follows that
\[
\int_{\mathcal{C}} g = \int_{\mathcal{C}^{(n)}} g,
\]
and thus we need to show that
\[
\int_{\mathcal{C}^{(n)}}g = \int_{\mathcal{C}_r} g.
\]
The proof of this is almost identical to the case $\mathcal{R}=\C$.
\end{blankbox}
\begin{comment}

While $\mathcal{R}_n$ is starlit, $\mathcal{R}_n \backslash \set{z_0}$ is not.  Thus we split $\mathcal{R}_n \backslash \set{z_0}$ into two starlit subregions, and construct contours $S_1$ and $S_2$ by connecting $\mathcal{C}^{(n)}$ and $\mathcal{C}_r$ as shown.
\begin{center}
\includegraphics[scale=0.25]{ch5_shrinking}
\end{center}

By Cauchy's Theorem for Starlit Regions, we again have
\[
\int_{S_1} g = \int_{S_2} g = 0.
\]

Notice that if we join $S_1$ and $S_2$ we get a contour consisting of
\begin{itemize}
\item An anticlockwise copy of the circular contour $\mathcal{C}_r$,
\item A clockwise copy of $\mathcal{C}^{(n)}$, i.e. the reverse of $\mathcal{C}^{(n)}$, and
\item two copies of each of the new edges connecting $\mathcal{C}^{(n)}$ and $\mathcal{C}_r$, one in each direction.
\end{itemize}
Thus we get
\[
\int_{S_1} g + \int_{S_2} g = \int_{\mathcal{C}_r} g - \int_{\mathcal{C}^{(n)}} g
\]
as the integrals along the new edges connecting $\mathcal{C}^{(n)}$ and $\mathcal{C}_r$ cancel, and we are left with $\mathcal{C}_r$ and the reverse of $\mathcal{C}^{(n)}$.

Hence
\[
0 = \int_{S_1} g + \int_{S_2} g = \int_{\mathcal{C}_r} g - \int_{\mathcal{C}^{(n)}} g
\]
and so
\[
\int_{\mathcal{C}_r} g = \int_{\mathcal{C}^{(n)}} g = \int_{\mathcal{C}} g.
\]
\blanksoff
%\vspace*{9cm}
\end{comment}

\qed

A very similar argument is used to prove Cauchy's Theorem for Simply Connected Regions.

\begin{theorem}[Cauchy's Theorem for Simply Connected Regions]
Let $f$ be a function that is holomorphic in a simply connected region $\mathcal{R}$, and let $\mathcal{C}$ be a closed contour in $\mathcal{R}$. Then
\[
\int_{\mathcal{C}} f = 0.
\]
\end{theorem}
{\bf Proof}
This is identical to the Proof of Theorem~\ref{t:sc}, except that now, $f$ is holomorphic on the starlit region $\mathcal{R}_n$, so that
\[
\int_{\mathcal{C}} f = \int_{\mathcal{C}_r} f =0.
\]
\qed

%\vspace*{7cm}

\begin{theorem}[Cauchy's Integral Formula]
\label{t:cauchyformula}
Let $\mathcal{R}$ be a simply connected region, $\mathcal{C}$ an anticlockwise simple closed contour in $\mathcal{R}$, $z_0$ a point enclosed by $\mathcal{C}$ and $f$ a function that is holomorphic on $\mathcal{R}$.  Then
\[
\int_{\mathcal{C}} \frac{f(z)}{z-z_0} \ dz = 2 \pi i f( z_0).
\]
\end{theorem}
\begin{proof}
Define a new function $g$ by the formula
\[
g(z) = \frac{f(z)}{z-z_0}
\]
so that $g$ is holomorphic on $\mathcal{R} \backslash \set{z_0}$, i.e., where $f$ is holomorphic and $z-z_0 \neq 0$.  Thus we are trying to show that
\[
\int_{\mathcal{C}} g = 2\pi i f(z_0).
\]
Using the Shrinking Contour Theorem~\ref{t:sc}, we may replace $\mathcal{C}$ with an anticlockwise circular contour $\mathcal{C}_r$ with centre $z_0$ and radius $r$ to get
\[
\int_{\mathcal{C}} g = \int_{\mathcal{C}_r} g
\]
whenever $r>0$ is small enough so that $\mathcal{C}_r$ is contained in $\mathcal{R}$.

If we define $I$ by
\[
I = \left(\int_{\mathcal{C}_r} \frac{f(z)}{z-z_0}\ dz \right) - 2 \pi i f(z_0),
\]
then we want to show that $I=0$.  To do this, we will write $I$ as a single integral along $\mathcal{C}_r$ and use the Estimation Lemma (together with the fact that our definition of $I$ does not depend on our choice of sufficiently small $r$).

Parametrising $\mathcal{C}_r$ with $\gamma:[0,2\pi] \to \C$, $\gamma(t) = z_0 + r \exp (it)$, we have
\[
\int_{\mathcal{C}_r} \frac{1}{z-z_0}\ dz = \int_0^{2\pi} \frac{1}{z_0+r\exp(it)-z_0} \cdot i r\exp (it) \ dt = \int_0^{2\pi} i \ dt = 2 \pi i
\]
(which we saw in Exercise Sheet 2). Therefore, since $f(z_0)$ is a constant, we get
\[
2\pi i f(z_0) = \int_{\mathcal{C}_r} \frac{f(z_0)}{z-z_0}\ dz.
\]
Thus
\begin{align*}
I &= \int_{\mathcal{C}_r} \frac{f(z)}{z-z_0}\ dz - \int_{\mathcal{C}_r} \frac{f(z_0)}{z-z_0}\ dz \\
& = \int_{\mathcal{C}_r} \frac{f(z)-f(z_0)}{z-z_0}\ dz.
\end{align*}
To apply the Estimation Lemma, we need to find an upper bound for
\[
\abs{ \frac{f(z)-f(z_0)}{z-z_0} } \quad \text{ where } z \in \mathcal{C}_r.
\]
Since $\mathcal{C}_r$ is a circle with centre $z_0$ and radius $r$, it is clear that $\abs{z-z_0} = r$ for all $z \in \mathcal{C}_r$, and thus we look at $\abs{f(z)-f(z_0)}$.

Since $f$ is holomorphic on $\mathcal{R}$, it is continuous on $\mathcal{R}$ and in particular, continuous at $z_0$.  Thus given any $\epsilon>0$ there exists $\delta>0$ such that
\[
0 < \abs{z-z_0} < \delta \Rightarrow \abs{ f(z)-f(z_0) } < \epsilon.
\]
In other words, given any $\epsilon >0$, if we choose $r$ so that $0<r < \delta$, we have
\[
z \in \mathcal{C}_r \Rightarrow \abs{z-z_0} = r < \delta \Rightarrow \abs{f(z)-f(z_0)} < \epsilon.
\]
For any such $r$ we thus have
\[
z \in \mathcal{C}_r \Rightarrow \abs{\frac{f(z)-f(z_0)}{z-z_0}} = \frac{\abs{f(z)-f(z_0)}}{\abs{z-z_0}} < \frac{\epsilon}{r}.
\]
By the Estimation Lemma (using the fact that $\ell ( \mathcal{C}_r ) = 2 \pi r$), we see that
\[
\abs{\int_{\mathcal{C}_r} \frac{f(z)-f(z_0)}{z-z_0}\ dz} \leq \frac{\epsilon}{r} 2 \pi r = 2\pi \epsilon.
\]
However, since the definition of $I$ does not depend on our choice of (small) $r$, it follows that
\[
\abs{I} < 2 \pi \epsilon
\]
for all $\epsilon>0$.  Hence $\abs{I}=0$ which implies $I=0$, or in other words,
\[
\int_{\mathcal{C}} \frac{f(z)}{z-z_0}\ dz = 2 \pi i f(z_0).
\]
\end{proof}

\begin{note}
Cauchy's Integral Formula, and its proof, can be easily remembered using the following approximation: if $r$ is small and $z \in \mathcal{C}_r$ then $f(z) \approx f(z_0)$, hence
\[
\int_{\mathcal{C}_r} \frac{f(z)}{z-z_0}\ dz \approx \int_{\mathcal{C}_r} \frac{f(z_0)}{z-z_0}\ dz = f(z_0) \int_{\mathcal{C}_r} \frac{1}{z-z_0}\ dz = f(z_0) (2\pi i).
\]
\end{note}
Suppose we wish to evaluate the integral $\int_{\mathcal{C}} g$ of a continuous function $g$ along some closed contour $\mathcal{C}$.  If we can find some point $z_0$ enclosed by $\mathcal{C}$ and a function $f$ holomorphic on $\mathcal{R}$ with
\[
g(z) = \frac{f(z)}{z-z_0} \quad \text{ for all }z \in \mathcal{C}
\]
then our integral may be evaluated using
\[
\int_{\mathcal{C}} g = \int_{\mathcal{C}} \frac{f(z)}{z-z_0}\ dz =  2\pi i f(z_0).
\]
In other words, it is enough to know the value of $f(z_0)$ in order to calculate $\int_{\mathcal{C}}g$.
\begin{example}
Evaluate the integral
\[
\int_{\mathcal{C}} \frac{\Log (z)}{z^2+9}
\]
where $\Log$ is the Principal Logarithm function and $\mathcal{C}$ is the anticlockwise circle with centre $4i$ and radius $3$.
\end{example}
%\vspace*{5cm}
\begin{solution}
We know that $\Log$ is holomorphic on $\C_{\pi}$, and moreover, we have
\[
z^2+9 = (z+3i)(z-3i).
\]
If we write
\[
\frac{\Log (z)}{z^2+9} = \frac{\Log (z)}{(z+3i)(z-3i)} = \frac{f(z)}{z-z_0}
\]
where $z_0=3i$ and
\[
f(z) = \frac{\Log (z)}{z+3i}
\]
then $z_0$ is enclosed by $\mathcal{C}$ and $f$ is holomorphic on $\C_{\pi} \backslash \set{-3i}$, which is a region containing $\mathcal{C}$.  However, it is clear that the region $\C_{\pi} \backslash \set{-3i}$ is not simply connected, so the hypotheses of Cauchy's Integral Formula are not fully satisfied.  We deal with this by replacing $\C_{\pi} \backslash \set{-3i}$ with a subregion that is simply connected.

\leftimage{
\altgraphics[scale=1]{ch5_cpi5}{ch5_cpi4}
}{
Indeed, if we consider the region $\mathcal{R} = \set{ z \in \C: \Im (z)>0}$, then we see that
\begin{itemize}
\item $\mathcal{R}$ is simply connected,
\item $f$ is holomorphic on $\mathcal{R}$, and
\item $\mathcal{C}$ is a simple, closed anticlockwise contour that is contained in $\mathcal{R}$ and encloses the point $z_0=3i$.
\end{itemize}
}

Therefore, we can apply Cauchy's Integral Formula, which gives
\begin{align*}
\int_{\mathcal{C}} \frac{\Log(z)}{z^2+9}\ dz &= \int_{\mathcal{C}} \frac{f(z)}{z-z_0}\ dz \\
& = 2 \pi i f(z_0) \\
& = 2 \pi i \left( \frac{\Log(3i)}{3i+3i} \right) \\
& = \frac{\pi}{6} \left( \log (3) + i \frac{\pi}{2} \right).
\end{align*}
\end{solution}
%\vspace*{5cm}

%\vspace*{8cm}

\begin{theorem}[Cauchy's Integral Formula for Derivatives; proof non examinable]
\label{t:cauchyd}
Let $\mathcal{R}$ be a simply connected region, $\mathcal{C}$ a simple, closed anticlockwise contour contained in $\mathcal{R}$ and $f$ a function that is holomorphic on $\mathcal{R}$. Then
\begin{enumerate}
\item $f$ is infinitely differentiable on $\mathcal{R}$, and
\item At every point $z$ in the region enclosed by $\mathcal{C}$, the $k^{th}$ derivative $f^{(k)}$ of $f$ satisfies
\[
f^{(k)}(z) = \frac{k!}{2\pi i} \int_{\mathcal{C}} \frac{f(\zeta)}{(\zeta-z)^{k+1}}\ d \zeta.
\]
\end{enumerate}
\end{theorem}

\begin{theorem}[Liouville's Theorem]
Let $f:\C \to \C$ be holomorphic (i.e. $f$ is holomorphic on the entire complex plane) and suppose that $f$ is bounded, i.e., there exists $M>0$ with $\abs{f(z)}\leq M$ for all $z \in \C$.  Then $f$ is constant.
\end{theorem}
{\bf Proof: } Exercise Sheet 4.

\section{Evaluating Real Integrals Using Cauchy's Integral Formula}
An important application of Cauchy's Integral Formula (Theorem~\ref{t:cauchyformula}) is that it allows us to evaluate certain \emph{real} integrals that would be difficult, if not impossible, to evaluate otherwise.  The following example illustrates the general method for doing so, which we shall develop in the next few sections.
\begin{example}
\label{e:realint1}
Let $R>1$, and define a contour $\cont_R$ by joining the line segment $[-R,R]$ and the upper semicircle $\mathcal{S}_R$ from $R$ to $-R$ via $iR$.  Use Cauchy's Integral Formula to evaluate
\[
\int_{\cont_R} \frac{1}{1+z^2}\ dz.
\]
\begin{center}
\includegraphics[scale=1.5]{ch5_cr1}
\end{center}
\end{example}
\begin{solution}
The function $f$ is holomorphic on $\C \backslash \set{i,-i}$.  Write
\[
\frac{1}{1+z^2} = \frac{1}{(z+i)(z-i)} = \frac{g(z)}{z-z_0}
\]
where
\[
g(z) = \frac{1}{z+i}\quad \text{ and } z_0=i.
\]
Then $g$ is holomorphic on $\C \backslash \set{-i}$ and in particular, on the simply connected region $\mathcal{R} = \set{ z \in \C: \Im (z) > - \frac{1}{2}}$.  Moreover, $\mathcal{C}_R$ is a closed, simple anticlockwise contour in $\mathcal{R}$ and $z_0=i$ is a point enclosed by $\mathcal{C}_R$.
\begin{comment}
\begin{center}
\includegraphics[scale=1]{ch5_cr1}
\end{center}
\end{comment}
Hence by Cauchy's Integral Formula,
\begin{align*}
\int_{\mathcal{C}_R} \frac{1}{1+z^2}\ dz &= \int_{\mathcal{C}_R} \frac{g(z)}{z-i}\ dz \\
&= 2 \pi i g(i) \\
& = 2\pi i \frac{1}{i+i} = \pi.
\end{align*}
(Note that  this integral does not depend on the value of $R$ once $R>1$).

\end{solution}

\begin{example}
Now, let's use Example~\ref{e:realint1} to evaluate the real integral
\[
\int_{-\infty}^{+\infty} \frac{1}{1+x^2}\ dx.
\]
\end{example}
\begin{solution}
Having evaluated the integral using Cauchy's Integral Formula, we now look at the integrals along the two paths $L_R$ and $S_R$;
\[
\int_{\mathcal{C}_R} \frac{1}{z^2+1}\ dz = \int_{L_R} \frac{1}{z^2+1}\ dz + \int_{S_R} \frac{1}{z^2+1}\ dz.
\]
parametrise $L_R$ with $\gamma_L:[-R,R] \to \C$, $\gamma(t)=t$, so that $\gamma'(t)=1$ and
\[
\int_{L_R} \frac{1}{1+z^2}\ dz = \int_{-R}^R \frac{1}{1+t^2}\ dt.
\]
We have seen already (Example~\ref{e:estimation}) that
\[
\lim_{R \to \infty} \int_{S_R} \frac{1}{1+z^2}\ dz = 0.
\]
Hence
\begin{align*}
\pi & = \lim_{R \to \infty} \int_{\mathcal{C}_R} \frac{1}{1+z^2}\ dz \\
& = \left( \lim_{R \to \infty} \int_{L_R} \frac{1}{1+z^2}\ dz \right) +  \left( \lim_{R \to \infty} \int_{S_R} \frac{1}{1+z^2}\ dz \right)  \\
& = \lim_{R \to \infty} \int_{-R}^R \frac{1}{1+t^2}\ dt + 0 \\
& = \int_{-\infty}^{\infty} \frac{1}{1+t^2}\ dt.
\end{align*}
So we have used contour integration to show that
\[
\int_{-\infty}^{\infty} \frac{1}{1+x^2}\ dx = \pi.
\]
\end{solution}

\begin{example}
\label{e:trig1}
We shall evaluate the integral
\[
\int_{\Gamma} \frac{2i}{3z^2-10z+3}\ dz,
\]
where $\Gamma$ is the anticlockwise unit circle $\set{z: \abs{z}=1}$, and use it to evaluate the real integral
\[
\int_0^{2\pi} \frac{1}{5-3\cos(t)}\ dt.
\]
\end{example}
\begin{solution}
If we factorise the denominator, we can write
\[
\frac{2i}{3z^2-10z+3} = \frac{2i}{(3z-1)(z-\frac{1}{3}}.
\]

The point $z_0=\frac{1}{3}$ is the only point enclosed by $\Gamma$ at which this function is not holomorphic.  If we let
\[
g(z) = \frac{2i}{3(z-3)}
\]
we have
\[
\frac{g(z)}{z-\frac{1}{3}} = \frac{2i}{(3z-1)(z-3)}
\]
and $g$ is holomorphic on the simply connected region $\set{z \in \C: \Re (z) < 2}$, which contains $\mathcal{C}$.  Thus
\begin{align*}
\int_{\Gamma} \frac{2i}{(3z-1)(z-3)}\ dz & = \int_{\Gamma} \frac{g(z)}{z-\frac{1}{3}}\ dz \\
& = 2\pi i g(\tfrac{1}{3}) \\
& = 2\pi i \left( - \frac{i}{4} \right) = \frac{\pi}{2}.
\end{align*}

For the second part, we parametrise $\Gamma$ using $\gamma:[0,2\pi]\to \C$, $\gamma(t)=e^{it}$ and use
\begin{align*}
\int_{\Gamma} f &= \int_0^{2\pi} f ( \gamma(t) ) \gamma'(t)\ dt \\
& = \int_0^{2\pi} \frac{2i}{3e^{2it}-10e^{it}+3}\cdot i e^{it}\ dt \\
& = \int_0^{2\pi} \frac{-2}{-10+3(e^{it}-e^{-it})}\ dt.
\end{align*}
Since $\cos(t) = \frac{1}{2}\brac{e^{it}-e^{-it}}$, it follows that
\[
\frac{-2}{-10+3(e^{it}+e^{-it})} = \frac{-2}{-10+6\cos(t)} = \frac{1}{5-3\cos(t)}.
\]
Hence
\[
\int_0^{2\pi} \frac{1}{5-3\cos(t)}\ dt = \int_{\Gamma} \frac{2i}{3z^2-10z+3} = \frac{\pi}{2}.
\]
\end{solution}

We can generalise the method of Example~\ref{e:trig1} to evaluate other real trigonometric integrals.
\begin{definition}
A \emph{Rational Function} $R:U \to \R$, where $U \subseteq \R^2$, is a function of the form
\[
R(x,y) = \frac{f(x,y)}{g(x,y)},
\]
where $f,g: \mathbb{R}^2 \to \R$ are two polynomials in $x$ and $y$ with real coefficients.
\end{definition}
We will now describe how to use contour integration to evaluate integrals of the form
\[
\int_0^{2\pi} R( \cos (t), \sin (t) )\ dt,
\]
where $R$ is a rational function of two real variables. For example, if $R$ is defined by
$
\displaystyle R(x,y) = \frac{1}{16x^2+25y^2},
$
then we are looking at the integral
\[
\int_0^{2\pi} R(\cos (t) , \sin (t) )\ dt = \int_0^{2\pi} \frac{1}{16 \left( \cos (t) \right)^2+25 \left( \sin (t) \right)^2}\ dt.
\]
Note that $\cos$ and $\sin$ are periodic with period $2\pi$, and that the above integral has limits $0$ and $2\pi$.

\begin{example}
\label{e:trig2}
For any rational function $R$ of two real variables, with $R(\cos(t),\sin(t))$ defined for every $t \in [0,2\pi]$, we can find a suitable closed contour $\mathcal{C}$ and complex function $f$ so that
\[
\int_0^{2\pi} R ( \cos(t), \sin (t) ) = \int_{\mathcal{C}} f.
\]
\begin{blankbox}
Let $\mathcal{C}$ be the anticlockwise circle $\set{z \in \C: \abs{z}=1}$, parametrised using $\gamma:[0,2\pi] \to \C,\ \gamma(t) = \exp(it)$. Let $f$ denote the complex function we are looking for, so we want
\[
\int_0^{2\pi} R ( \cos(t),\sin(t) ) \ dt = \int_{\mathcal{C}} f = \int_0^{2\pi} f \left( \gamma (t) \right) \gamma' (t)\ dt,
\]
or in other words,
\begin{equation}
\tag{R1}\label{e:r1}
f( \gamma(t) ) = \frac{1}{\gamma'(t)} \cdot R( \cos(t), \sin (t) ).
\end{equation}
For each $z \in \mathcal{C}$, $z= \exp(it)$ for some $t \in [0,2\pi]$ and so
\begin{align*}
\cos(t) & = \frac{\exp(it)+\exp(-it)}{2}  = \frac{z+z^{-1}}{2} \\
\sin(t) & = \frac{\exp(it)-\exp(-it)}{2i} =  \frac{z-z^{-1}}{2i} \\
\end{align*}
Hence for $z=\exp (it) \in \mathcal{C}$, we have
\begin{equation}
\tag{R2}\label{e:r2}
 R ( \cos (t), \sin (t) )  = R \left( \frac{z+z^{-1}}{2}, \frac{z-z^{-1}}{2i} \right),
 \end{equation}
(this is not true for all $z$, only for $z$ lying on the contour $\mathcal{C}$). Moreover, $\gamma'(t) = i \exp (it) = iz$; so combining~\eqref{e:r1} and~\eqref{e:r2}, we define
\[
f(z) = R \left( \frac{z+z^{-1}}{2}, \frac{z-z^{-1}}{2i} \right) \cdot \frac{1}{iz}.
\]
Then
\begin{align*}
\int_{\mathcal{C}} f & = \int_0^{2\pi} f( \gamma(t)) \gamma'(t) \\
& = \int_0^{2\pi} R \left( \tfrac{1}{2}(\exp(it)+\exp(-it)),\tfrac{1}{2i}(\exp(it)-\exp(-it)) \right) \cdot \frac{1}{i\exp(it)} \cdot i\exp(it)\ dt \\
&= \int_0^{2\pi} R( \cos (t) , \sin (t))\ dt.
\end{align*}
\end{blankbox}
\end{example}
\begin{example}
Use a suitable contour integral to evaluate
\[
\int_0^{2\pi} \frac{1}{2+\sin \theta}\ d \theta.
\]
\begin{solution}
With $\mathcal{C}$ the anticlockwise unit circle, we have
\begin{align*}
\int_0^{2\pi} \frac{1}{2+\sin \theta}\ d \theta & = \int_{\mathcal{C}} \frac{1}{2+\frac{z-z^{-1}}{2i}} \cdot \frac{1}{iz}\ dz \\
& = \int_{\mathcal{C}} \frac{2}{z^2+4iz-1}\ dz \\
& = \int_{\mathcal{C}} \frac{2}{(z-(-2+\sqrt{3})i)(z-(-2-\sqrt{3})i)}\ dz.
\end{align*}
By Cauchy's Integral Formula, this integral has the value
\[
2\pi i \cdot \frac{2}{(-2+\sqrt{3})i-(-2-\sqrt{3})i} = \frac{2\pi}{\sqrt{3}}.
\]
\end{solution}
\end{example}

\begin{example}
Set up a contour integral that could be used to evaluate
\[
\int_0^{2\pi} \frac{1}{16 \cos^2 (t) + 25 \sin^2 (t)}\ dt.
\]
\begin{solution}
Here $R(x,y) = \dfrac{1}{16x^2+25y^2}$, so the required integral (with $\mathcal{C}$ the anticlockwise circle $\set{z \in \C : \abs{z}=1 }$) is
\begin{align*}
\int_{\mathcal{C}} R \left( \frac{z+z^{-1}}{2}, \frac{z-z^{-1}}{2i} \right) \cdot \frac{1}{iz}\ dz & = \int_{\mathcal{C}} \frac{1}{16\left(\frac{1}{2}(z+z^{-1})\right)^2+25\left(\frac{1}{2i}(z-z^{-1}) \right)^2} \cdot \frac{1}{iz}\ dz \\
& = \int_{\mathcal{C}} \frac{1}{4(z+2+z^{-2})-\frac{25}{4}(z^2-2+z^{-2})} \cdot \frac{1}{iz}\ dz \\
& = \int_{\mathcal{C}} \frac{4i}{9z^4-82z^2+9}\ dz.
\end{align*}
We do not yet know how to evaluate this integral, we shall do this in Chapter 6.
\end{solution}
\end{example}

\section{Series Representations of Holomorphic Functions}
\begin{definition}
A sequence $z_n$ of complex numbers is said to converge to a complex number $z$ if, for all $\epsilon>0$ there is a natural number $N$ such that $n \geq N$ implies that $\abs{z_n-z}<\epsilon$.

An infinite series $\sum_{k=1}^{\infty} a_k$ is said to converge to a complex number $s$ if the sequence of partial sums $s_n:= \sum_{k=1}^n a_k$ converges to $s$.  When this occurs we write $\sum_{k=1}^{\infty} a_k = s$.
\end{definition}

For a fixed $z_0 \in \C$, a \emph{power series} (centred at $z_0$) is a series of the form $\displaystyle \sum_{n=0}^{\infty} a_n (z-z_0)^n$, where $a_n$ are complex numbers.  As with power series in $\mathbb{R}$, a complex power series may converge for some values of $z$ and diverge for others.  Note that if $\mathcal{S}$ denotes the subset
\[
\mathcal{S} = \set{ z \in \C: \sum_{n=0}^{\infty} a_n(z-z_0)^n \text{ converges } },
\]
then we get a function $f:\mathcal{S} \to \C$ defined by
\[
f(z) = \sum_{n=0}^{\infty} a_n (z-z_0)^n.
\]

\begin{theorem}[Taylor's Theorem]
\label{t:taylor}
Let $\mathcal{R}$ be a region, $f:\mathcal{R} \to \C$ holomorphic and $z_0$ a point in $\mathcal{R}$.  Then $f$ can be represented by the power series
\[
f(z) = \sum_{n=0}^{\infty} \frac{f^{(n)}(z_0)}{n!} (z-z_0)^n
\]
for all $z \in D(z_0;R)$, whenever $R>0$ is small enough so that $D(z_0;R) \subseteq \mathcal{R}$.
\end{theorem}
\begin{center}
\includegraphics[scale=1]{ch5_taylordisc_full}
\end{center}
Before proving Taylor's Theorem, we need the following lemma:
\begin{lemma}
\label{l:taylor}
Let $f:\mathcal{R} \to \C$ be a function, $z_0 \in \mathcal{R}$ and $R>0$ be such that $D(z_0,R) \subseteq \mathcal{R}$.  Then for any $0<r<R$, $z \in D(z_0,r)$ and $\zeta \in \mathcal{C}_r$ we have
\[
\frac{f(\zeta)}{\zeta-z} = \left( \sum_{j=0}^n \frac{(z-z_0)^jf(\zeta)}{(\zeta-z_0)^{j+1}} \right) + \frac{(z-z_0)^{n+1} f ( \zeta)}{(\zeta-z_0)^{n+1}(\zeta-z)},
\]
where $\mathcal{C}_r$ is the anticlockwise circular contour with centre $z_0$ and radius $r$.
\begin{center}
\includegraphics[scale=1]{ch5_taylordisclemma}
\end{center}
\end{lemma}

\begin{proof}
Note that we can write
\begin{equation}
\label{e:taylor1}\tag{T1}
\frac{1}{\zeta-z} = \frac{1}{\zeta-z_0}\cdot \frac{1}{\brac{1-\frac{z-z_0}{\zeta-z_0}}}.
\end{equation}
Rearranging the formula for a finite geometric sum,
\[
\sum_{j=0}^n w^j = \left( \frac{1-w^{n+1}}{1-w} \right),\quad\text{gives}\quad \frac{1}{1-w} = \left( \sum_{j=0}^n w^j \right) + \frac{w^{n+1}}{1-w},
\]

and so substituting $w = \dfrac{z-z_0}{\zeta-z_0}$ we get
\begin{align*}
\frac{1}{\brac{1-\frac{z-z_0}{\zeta-z_0}}} & = \left(\sum_{j=0}^n \left(\frac{z-z_0}{\zeta-z_0}\right)^j \right) + \frac{(z-z_0)^{n+1}}{\brac{\zeta-z_0}^{n+1}\brac{1-\frac{z-z_0}{\zeta-z_0}}} \\
& = \left(\sum_{j=0}^n \left(\frac{z-z_0}{\zeta-z_0}\right)^j \right) + \frac{\brac{z-z_0}^{n+1}}{\brac{\zeta-z_0}^n \brac{\zeta-z}}.
\end{align*}
Combining this with~\eqref{e:taylor1}, and multiplying both sides by $f(\zeta)$ we get
\[
\frac{f(\zeta)}{\zeta-z} = \left( \sum_{j=0}^n (z-z_0)^j \frac{f(\zeta)}{(\zeta-z_0)^{j+1}} \right) + \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}
\]
\end{proof}

\begin{exercise}
Use the following steps to prove this Theorem (for now, you should assume the result of Lemma~\ref{l:taylor}).  Fix $r$ with $0<r<R$ and let $\mathcal{C}_r$ be the anticlockwise circular contour with centre $z_0$ and radius $R$.
\begin{enumerate}
\item[(i)]  Explain why
\[
f(z) = \frac{1}{2\pi i} \int_{\mathcal{C}_r} \frac{f(\zeta)}{\zeta-z}\ d\zeta
\]
for all $z \in D(z_0,r)$.

\item[(ii)] Use Lemma~\ref{l:taylor} to show that
\[
2\pi i f( z) = \left( \sum_{j=0}^n (z-z_0)^j  \int_{\mathcal{C}_r} \frac{f(\zeta)}{(\zeta-z_0)^{j+1}}\ d\zeta \right) + \int_{\mathcal{C}_r} \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta
\]

\item[(iii)] Use Cauchy's Integral Formula for Derivatives to show that
\[
f(z) = f(z_0)+(z-z_0)f'(z_0)+\frac{(z-z_0)^2f''(z_0)}{2!}+\ldots+ \frac{(z-z_0)^n f^{(n)}(z_0)}{n!} + I_n,
\]
where $I_n = \displaystyle \frac{1}{2\pi i}\int_{\mathcal{C}_r}  \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta.$.
\item[(iv)] Show that
\begin{itemize}
\item $\abs{\zeta-z} \geq r - \abs{z-z_0}$ for all $\zeta \in \mathcal{C}_r$ and $z \in D(z_0,r)$, and that
\item there exists $K \geq 0$ with $\abs{f(\zeta)} \leq K$ for all $\zeta \in \mathcal{C}_r$.
\end{itemize}
\item[(v)] Use part (iv) and the Estimation Lemma to show that
\[
\abs{I_n} \leq \frac{1}{2\pi} \cdot \abs{\frac{z-z_0}{\zeta-z_0}}^{n+1} \cdot \frac{K}{r-\abs{z-z_0}}
\]
\item[(vi) ] Use part (v) to show that $\abs{I_n} \to 0$ and $n \to \infty$, and explain why this completes the proof.
\end{enumerate}
\end{exercise}

\begin{proof}[of Taylor's Theorem~\ref{t:taylor}]
Choose $r>0$ with $0 < r < R$ and let $\mathcal{C}_r$ be the anticlockwise circle with centre $z_0$ and radius $r$.  Then by Cauchy's Integral Formula,
\[
f(z) = \frac{1}{2\pi i} \int_{\mathcal{C}_r} \frac{f(\zeta)}{\zeta-z}\ d\zeta
\]
for all $z$ with $\abs{z-z_0}<r$.
\begin{center}
\includegraphics[scale=1]{ch5_taylordiscproof_full}
\end{center}

Together with Lemma~\ref{l:taylor} we see that
\[
2\pi i f(z) = \int_{\mathcal{C}_r} \left[ \left( \sum_{j=0}^n (z-z_0)^j \frac{f(\zeta)}{(\zeta-z_0)^{j+1}} \right) + \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}  \right]\ d \zeta.
\]
Using linearity of contour integrals, we first get
\[
2\pi i f(z) = \left( \sum_{j=0}^n \int_{\mathcal{C}_r} (z-z_0)^j \frac{f(\zeta)}{(\zeta-z_0)^{j+1}}\ d\zeta \right) + \int_{\mathcal{C}_r} \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta.
\]
and noting that since we are integrating with respect to $\zeta$, the $(z-z_0)$ terms are constant, this becomes
\[
2\pi i f( z) = \left( \sum_{j=0}^n (z-z_0)^j  \int_{\mathcal{C}_r} \frac{f(\zeta)}{(\zeta-z_0)^{j+1}}\ d\zeta \right) + \int_{\mathcal{C}_r} \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta
\]
(we leave the last term as it is for now).

Using Cauchy's Integral Formula For Derivatives (Theorem~\ref{t:cauchyd}), and dividing both sides by $2\pi i$, this becomes
\[
f(z) = f(z_0)+(z-z_0)f'(z_0)+\frac{(z-z_0)^2f''(z_0)}{2!}+\ldots+ \frac{(z-z_0)^n f^{(n)}(z_0)}{n!} + I_n,
\]
where
\[
I_n = \frac{1}{2\pi i}\int_{\mathcal{C}_r}  \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta.
\]
To complete the proof, we must show that $I_n \to 0$ as $n \to \infty$.  We shall use the Estimation Lemma to do this.

\begin{itemize}
\item For $\zeta \in \mathcal{C}_r$, we have $\abs{\zeta-z_0}=r$, and since $z$ is enclosed by $\mathcal{C}_r$, $\abs{z-z_0}<r$.
\item Since $f$ is continuous on $\mathcal{C}_r$, there is some real number $K \geq 0$ such that $\abs{f(\zeta)} \leq K$ for all $\zeta$ in $\mathcal{C}_r$.  To see this, note that if $\mathcal{C}_r$ is parametrised by the continuous function $\gamma:[0,2\pi] \to \C$, $\gamma (t) = z_0+r e^{it}$, then $t \mapsto \abs{f(\gamma(t))}$ is a continuous, real-valued function on a closed interval, hence is bounded by the Extreme Value Theorem.
\item By the backwards triangle inequality,
\[
\abs{\zeta-z} = \abs{\zeta-z_0+z_0-z} \geq \abs{\abs{\zeta-z_0}-\abs{z_0-z}} = r - \abs{z_0-z},
\]
a strictly positive constant since $z$ is fixed and $\abs{z_0-z}<r$.
\end{itemize}
Hence for all $\zeta \in \mathcal{C}_r$ we have
\[
\abs{\frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}} } = \abs{\frac{z-z_0}{\zeta-z_0}}^{n+1}\cdot \frac{\abs{f(\zeta)}}{\abs{\zeta-z}} \leq \abs{\frac{z-z_0}{\zeta-z_0}}^{n+1} \cdot \frac{K}{r-\abs{z-z_0}}
\]
Thus by the Estimation Lemma,
\[
\abs{I_n} = \abs{\frac{1}{2\pi i}\int_{\mathcal{C}_r}  \frac{\brac{z-z_0}^{n+1}f(\zeta)}{\brac{\zeta-z_0}^{n+1} \brac{\zeta-z}}\ d\zeta} \leq \frac{1}{2\pi} \cdot \abs{\frac{z-z_0}{\zeta-z_0}}^{n+1} \cdot \frac{K}{r-\abs{z-z_0}},
\]
Since $\abs{z-z_0}<\abs{\zeta-z_0}$, $\abs{\dfrac{z-z_0}{\zeta-z_0}}<1$ and so
$\displaystyle \abs{\frac{z-z_0}{\zeta-z_0}}^{n+1} \to 0 $ as  $n \to \infty$.

Since all other terms in the estimate are constant, this shows that $I_n \to 0$ as $n \to \infty$.

\end{proof}

Many familiar examples of Taylor Series from the real case are also valid for the corresponding complex functions:
\begin{center}
\includegraphics[scale=0.5]{ch5_taylor_examples}
\end{center}
These examples can be computed in exactly the same way as the corresponding real series.  In fact, we could say a lot more about complex Taylor Series, but we will not have time to do so in this module.
\begin{example}
The Taylor Series expansion of a function $f:\mathcal{R} \to \C$ at a point $z_0 \in \mathcal{R}$ may not be valid everywhere in the domain of $f$.  For example, let us examine the Taylor series at $z=0$ of the function $f:\C \backslash \set{-i,i} \to \C$ defined by
\[
f(z) = \frac{1}{1+z^2}.
\]
\end{example}
\begin{blankbox}
This function is holomorphic on $\C \backslash \set{-i,i}$, and by differentiation we can show that its Taylor series at $z=0$ is
\[
\sum_{n=0}^{\infty} (-1)^{n} z^{2n}.
\]
The largest disc centred at $0$ that is contained in $\C \backslash \set{-i,i}$ is $D(0,1)$, hence this Taylor Series is valid (i.e. converges to $f(z)$) at every point of this disc by Theorem~\ref{t:taylor}.  However, Theorem~\ref{t:taylor} tells us nothing about convergence of this series at points of $\C \backslash \set{-i,i}$ that lie outside of this disc (in fact the series diverges at these points).
\begin{center}
\begin{tabular}{cc}
\altgraphics[scale=1]{ch5_taylorexample2_full}{ch5_taylorexample2} & \altgraphics[scale=1]{ch5_taylorexample3_full}{ch5_taylorexample3}
\end{tabular}
\end{center}

Similarly, if we compute the Taylor Series for $f$ at $z=2+i$ (which we won't do, but we know it exists), Theorem~\ref{t:taylor} tells us that this series converges for all $z$ inside the disc $D(2+i,2)$.
\end{blankbox}

\begin{remark}
It is worth pointing out some of the differences between the real and complex versions of Taylor's Theorem.
\begin{enumerate}
\item[(i)]  In the complex case, once we know that $f$ is differentiable everywhere on an open set $\mathcal{R}$ (i.e. holomorphic on $\mathcal{R}$), we know that $f$ can be represented by a Taylor series.  For real functions it is not enough to know that $f$ is differentiable on an open interval; $f$ must be infinitely differentiable.
\item[(ii)] There are examples of real functions that are infinitely differentiable, but whose Taylor series have radius on convergence $0$, e.g., the function $f$ defined by $f(x) = e^{-1/x^2}$ for $x \neq 0$ and $f(0)=0$.  This cannot happen in the complex case; the radius of convergence is always positive.
\end{enumerate}
\end{remark}


\section{Combinations}

    \subsection{What are Combinations?}
     A Combination is a way of selecting objects (permuting) from a group, without the order being important.
     In essence, it is orderless permutations. Let $ABC$ be a permutation.
     With permutations we asserted that $ABC$ and $BAC$ are different, as they are ordered differently.
     In combinations, we assert that $ABC$ and $BAC$ are the same, as they contain the same objects, just in a different order.

    \subsection{Set Theory}
    Set Theory involves the creation and manipulation of sets and their properties.
    A set is a collection of distinct objects in which their order does not matter.
    The objects in this set are called elements.
    If a set does not have any elements in it, we refer to it as a \emph{null set}, which is shown as $\emptyset$ or $(\emptyset)$.
    This null set is a subset of everything.
    If we want to describe a set containing elements, we must follow the example below.
    \begin{equation*}
        X = \{a,b,c,d,e,f,\cdots,y,z\}
    \end{equation*}
    If we wish to describe the number of elements in the set, we can use $n(X)$, where X represents the set, and n returns the number of elements in that set.
    In this case $n(X) = 26$, as set X contains all the letters of the alphabet.
    Sets are referred to differently when compared to other sets, as defined below.
    \begin{definition}
    Special Properties of Sets when Compared to Other Sets
    \begin{enumerate}
        \item If two sets have no elements in common they are called disjoint sets.
        \item If two sets have all elements in common they are equal.
        \item If all of elements of A are also in B then A is a subset of B $(A\subseteq B)$
    \end{enumerate}
    \end{definition}

        \subsubsection{Universal Set and Complement Sets}
        The set of all elements being considered is called the\emph{universal set} and is always denoted by $S$.
        When referring to a set of all elements that are in the universal set, but\textbf{ not in set A}, we call this the complement of $A$ or $A`$. For example:
        \begin{equation*}
            S = \{1,2,3,4\}, A = \{1,3\}, A`=\{2,4\}
        \end{equation*}

        \subsubsection{Unions and Intersections}
        For two sets of A and B, the \textbf{union} of A and B or $A\cup B$, is the set of all elements in A or B, not including duplicates.
        \begin{equation*}
            S = \{1,2,3,4\}, A = \{1,3\}, B =\{1,2\}, A\cup B=\{1,2,3\}
        \end{equation*}
        For two sets of A and B the \textbf{intersection} of A and B, $A\cap B$, is the set of all the elements that are in both set A and set B.
        \begin{equation*}
            S = \{1,2,3,4\}, A = \{1,3\}, B =\{1,2\}, A\cap B=\{1\}
        \end{equation*}
        If you are ever having trouble remembering the difference between the symbols representing the union and the intersection, remember that a union looks like a cup, and intersection looks like a cap.

        \subsubsection{Subsets}
        Subsets, are sets that are also in another set. To find every possible subset (including null set) we need to use the equation:
        \begin{equation*}
            2^{n(X)}
        \end{equation*}
        In this case, n(X) is the number of elements in Set X. If a question comes up, where we need the number of subsets of a given set with the length $y$, of set $x$, we'd simply use $\binom{n(x)}{y}$

    \subsection{Introduction to Combinations}
    A combination is a selection of r objects, from n distinct objects \emph{without regard for order}.
    The equation for solving combinations is written below.
    \begin{equation*}
        C(n,r) = \frac{n!}{(n-r)!\cdot r!}
    \end{equation*}
    This equations finds all combinations by dividing number of objects, by the unused objects $(n-r)!$ and the order of the selected objects.
    This can be further simplified to:
    \begin{equation*}
        C(n,r) = \frac{P(n,r)}{r!}
    \end{equation*}
    If order does not matter, the process is called a \emph{Combination}, whereas when order does matter, it is called a \emph{Permutation}.
    On your calculator, the formulae for combinations will be shown as \textbf{nCr}.
    If written out by hand, we will use the form:
    \begin{equation*}
        \binom{n}{r} = \frac{n!}{(n-r)!\cdot n!}
    \end{equation*}
    Or simply \(\binom{n}{r}\).

    \subsection{Inclusion\textemdash Exclusion Principle}
    The Inclusion-exclusion principle is a method of obtaining the number of elements in finite sets.
    Typically used when asked for the number of combinations of two things, where there is overlap between the two.\\
    Let A represent Set A, and let B represent Set B.
    \begin{center}
        %% Thank you http://tex.stackexchange.com/questions/9681/how-to-draw-venn-diagrams-especially-complements-in-latex
        \begin{tikzpicture}[fill=gray]
            % left hand
            \scope
            \clip (-2,-2) rectangle (2,2)
                  (1,0) circle (1);
            \fill (0,0) circle (1);
            \endscope
            % right hand
            \scope
            \clip (-2,-2) rectangle (2,2)
                  (0,0) circle (1);
            \fill (1,0) circle (1);
            \endscope
            % outline
            \draw (0,0) circle (1) (0,1)  node [text=black,above] {$A$}
                  (1,0) circle (1) (1,1)  node [text=black,above] {$B$}
                  (-2,-2) rectangle (3,2) node [text=black,above] {$H$};
        \end{tikzpicture}
    \end{center}
    This diagram perfectly represents the overlap between the two sets.
    If you caught it earlier, what we're actually finding is $A\cup B$.
    The Inclusion\textemdash Exclusion Principle is merely a way of finding it algebraically.
    The image above represents the equation below.
    \begin{equation*}
        |A\cup B| = |A| + |B| - |A\cap B|
    \end{equation*}
    What happens if we have have three events we need to find the union of though?
    To do that, we'll follow the same principles, and use the equation below.
    \begin{equation*}
        |A\cup B\cup C| = |A| + |B| + |C| - |A\cap B| - |A\cap C| - |B\cap C| + |A\cap B\cap C|
    \end{equation*}
    %%TODO: Include a Venn Diagram for this equation above.


\label{appendix:equations}

This appendix describes the most important equations used in this thesis.

\section{Neutron flux equations}
\label{appendix:equations-n}

Equations \ref{eq:diffusion} and \ref{eq:precursors} describe the time dependent behavior of the neutron flux and the concentration of the delayed neutron precursors
duded
\begin{align}
  % diffusion
  & \frac{1}{v_g}\frac{\partial}{\partial t} \phi_g = \nabla \cdot D_g \nabla \phi_g - \Sigma_g^r \phi_g +
  \sum_{g' \ne g}^G \Sigma_{g'\rightarrow g}^s \phi_{g'} + \chi_g^p \sum_{g' = 1}^G (1 - \beta) \nu \Sigma_{g'}^f \phi_{g'} +
  \chi_g^d \sum_i^I \lambda_i C_i \label{eq:diffusion} \\
  % precursors
  & \frac{\partial}{\partial t} C_i = \sum_{g'= 1}^G \beta_i \nu \Sigma_{g'}^f \phi_{g'} - \lambda_i C_i \label{eq:precursors}
  \intertext{where}
  & v_g = \mbox{group $g$ neutron speed } [cm \cdot s^{-1}] \notag \\
  & \phi_g = \mbox{group $g$ neutron flux } [n \cdot cm^{-2} \cdot s^{-1}] \notag \\
  & t = \mbox{time } [s] \notag \\
  & D_g = \mbox{group $g$ diffusion coefficient } [cm] \notag \\
  & \Sigma_g^r = \mbox{group $g$ macroscopic removal cross-section } [cm^{-1}] \notag \\
  & \Sigma_{g'\rightarrow g}^s = \mbox{group $g'$ to group $g$ macroscopic scattering cross-section } [cm^{-1}] \notag \\
  & \chi_g^p = \mbox{group $g$ prompt fission spectrum } [-] \notag\\
  & G = \mbox{number of discrete energy groups } [-] \notag \\
  & \nu = \mbox{number of neutrons produced per fission } [-] \notag \\
  & \Sigma_g^f = \mbox{group $g$ macroscopic fission cross-section } [cm^{-1}] \notag \\
  & \chi_g^d = \mbox{group $g$ delayed fission spectrum } [-] \notag \\
  & I = \mbox{number of delayed neutron precursor groups } [-] \notag \\
  & \beta = \mbox{delayed neutron fraction } [-] \notag \\
  & \lambda_i = \mbox{average decay constant of delayed neutron precursors in precursor group $i$ } [s^{-1}] \notag \\
  & C_i = \mbox{concentration of delayed neutron precursors in precursor group $i$ } [cm^{-3}]. \notag
\end{align}

The following equation relates $\chi_g^t$ to $\chi_g^p$ and $\chi_g^d$ \cite{hetrick_dynamics_1993}
\begin{align}
  & \chi_g^t = \chi_g^p (1 - \beta) + \chi_g^d \sum_i^I \beta_i  \label{eq:chit} \\
  \intertext{where}
  & \chi_g^t = \mbox{group $g$ total fission spectrum } [-]. \notag
\end{align}

The combination of the steady-state of equations \ref{eq:diffusion}, \ref{eq:precursors}, \ref{eq:chit}, and replacing $\nu\Sigma_g^f$ by $\frac{\nu\Sigma_g^f}{k_{eff}}$ yields the eigenvalue equation \cite{duderstadt_nuclear_1976}
\begin{align}
  \nabla \cdot D_g \nabla \phi_g - \Sigma_g^r \phi_g & + \sum_{g \ne g'}^G \Sigma_{g'\rightarrow g}^s \phi_{g'} +
  \chi_g^t \sum_{g' = 1}^G \frac{1}{k_{eff}}\nu \Sigma_{g'}^f \phi_{g'} = 0 \label{eq:app-eigenvalue}
  \intertext{where}
  k_{eff} = \mbox{multiplication factor } [-]. \notag
\end{align}

\section{Thermal-fluids equations}
\label{appendix:equations-th}

% solids
The three-dimensional heat conduction equation \cite{melese_thermal_1984} allows for solving the temperature in the fuel, helium gap, moderator, coolant film, and reflector.
\begin{align}
  & \rho_i c_{p,i} \frac{\partial}{\partial t} T_i = k_i \nabla^2 T_i + Q_i \label{eq:app-solid} \\
  \intertext{where}
  & i = \mbox{f (fuel), g (helium gap), m (moderator), cf (coolant film), r (reflector)} \notag \\
  & \rho_i = \mbox{material $i$ density } [kg \cdot cm^{-3}] \notag \\
  & c_{p,i} = \mbox{material $i$ heat capacity } [J \cdot kg^{-1} \cdot K^{-1}] \notag \\
  & k_i = \mbox{material $i$ thermal conductivity  } [W \cdot cm^{-1} \cdot K^{-1}] \notag \\
  & T_i = \mbox{material $i$ temperature } [^{\circ}C] \notag \\
  & Q_i = \mbox{material $i$ volumetric heat source } [W \cdot cm^{-3}]. \notag
\end{align}

Equations \ref{eq:app-heatsource1} and \ref{eq:app-heatsource2} define the fuel heat source in the stand-alone and coupled calculations
\begin{align}
  & Q_f = Q_0 \label{eq:app-heatsource1} \\
  & Q_f = \sum_{g = 1}^{G} \epsilon_g^f \Sigma_g^f \phi_g \label{eq:app-heatsource2} \\
  & Q_g = Q_m = Q_{cf} = Q_r = 0 \label{eq:app-heatsource3}
  \intertext{where}
  & Q_i = \mbox{material $i$ volumetric heat source } [W \cdot cm^{-3}] \notag \\
  & \epsilon_g^f = \mbox{energy released per fission } [J] \notag \\
  & \Sigma_g^f = \mbox{group $g$ macroscopic fission cross-section } [cm^{-1}] \notag \\
  & \phi_g = \mbox{group $g$ neutron flux } [n \cdot cm^{-2} \cdot s^{-1}]. \notag
\end{align}

% coolant
The governing equation of the coolant is the one-dimensional form of the continuity, momentum, and energy conservation equations \cite{white_viscous_2006}

\begin{align}
  & \frac{\partial}{\partial t} \rho_c + \nabla \cdot (\rho_c u) = 0 \label{eq:app-continuity} \\
  & \rho_c \left(\frac{\partial}{\partial t} u + u\frac{\partial}{\partial z}u \right) = - \frac{\partial}{\partial z}p - \tau \frac{\varepsilon}{A} - \rho_c g \label{eq:app-momentum} \\
  & \rho_c \left( \frac{\partial}{\partial t} (c_{p,c} T_c) + u\frac{\partial}{\partial z} (c_{p,c} T_c) \right) = \frac{\partial}{\partial t} p + u\frac{\partial}{\partial z} p +  q'''_{conv}  \label{eq:app-tempcool} \\
  & \tau = \frac{f}{2} \rho_c u^2 \label{eq:app-friction} \\
  & q'''_{conv} = h\frac{\varepsilon}{A} (T_i-T_c) \label{eq:app-convection}
  \intertext{where}
  & \rho_c = \mbox{coolant density } [kg \cdot cm^{-3}] \notag \\
  & u = \mbox{coolant velocity } [cm \cdot s^{-1}] \notag \\
  & p = \mbox{coolant pressure } [\times 10^{-2} Pa] \notag \\
  & \tau = \mbox{shear stress } [\times 10^{-2} Pa] \notag \\
  & \varepsilon = \mbox{wetted perimeter } [cm] \notag \\
  & A = \mbox{cross-sectional area } [cm^2] \notag \\
  & g = \mbox{gravity } [m \cdot s^{-2}] \notag \\
  & c_{p,c} = \mbox{coolant specific heat capacity } [J \cdot kg^{-1} \cdot K^{-1}] \notag \\
  & T_c = \mbox{coolant temperature } [^{\circ}C] \notag \\
  & k_c = \mbox{coolant thermal conductivity } [W \cdot cm^{-1} \cdot K^{-1}] \notag \\
  & q'''_{conv} = \mbox{convective heat transfer } [W \cdot cm^{-3}] \notag \\
  & f = \mbox{friction factor } [-] \notag \\
  & h = \mbox{heat transfer coefficient } [W \cdot cm^{-2} \cdot K^{-1}] \notag \\
  & T_i = \mbox{solid temperature } [^{\circ}C]. \notag
\end{align}

Equation \ref{eq:app-churchill} \cite{churchill_friction-factor_1977} determines the friction factor $f$

\begin{align}
  & f = 8\left[ \left( \frac{8}{Re} \right)^{12} + \frac{1}{(A+B)^{3/2}} \right]^{1/12} \notag \\
  & A = \left\{ 2.457 \quad ln \left( \frac{1}{\left(\frac{7}{Re_{D_h}}\right)^{0.9}+0.27\frac{\varepsilon}{D_h}} \right) \right\}^{16} \label{eq:app-churchill} \\
  & B = \left\{ \frac{37530}{Re} \right\}^{16} \notag
  \intertext{where}
  & \varepsilon = \mbox{surface roughness } [-] \notag \\
  & Re = \mbox{Reynolds number } [-] \notag \\
  & D_h = \mbox{hydraulic diameter } [cm]. \notag
\end{align}

Equation \ref{eq:app-film-conduc} calculates the film thermal conductivity $k_f$ \cite{melese_thermal_1984}

\begin{align}
  & Nu = 0.023 Re^{0.8} Pr^{0.4} \label{eq:app-dittus} \\
  & h = \frac{Nu \cdot k_c}{D_h}  \\
  & k_f = h R_{cf} ln(R_{cf}/R_c) \label{eq:app-film-conduc}
  \intertext{where}
  & Nu = \mbox{Nusselt number } [-] \notag \\
  & Pr = \mbox{Prandtl number } [-] \notag \\
  & h = \mbox{heat transfer coefficient } [W \cdot cm^{-2} \cdot s^{-1}] \notag \\
  & D_h = \mbox{hydraulic diameter } [cm] \notag \\
  & k_c = \mbox{coolant thermal conductivity } [W \cdot cm^{-1} \cdot K^{-1}] \notag \\
  & k_{cf} = \mbox{coolant film thermal conductivity } [W \cdot cm^{-1} \cdot K^{-1}] \notag \\
  & R_{cf} = \mbox{coolant film radius } [cm] \notag \\
  & R_c = \mbox{coolant channel radius } [cm]. \notag
\end{align}

In the steady-state limit, equation \ref{eq:app-continuity} becomes
\begin{align}
  & \nabla \cdot (\rho_c u) = 0
  \intertext{wich leads to }
  & \rho_c u (z) = \rho_{c,i} u_i
  \intertext{where}
  & \rho_{c,i} = \mbox{inlet coolant density} \notag \\
  & u_i = \mbox{inlet coolant velocity.} \notag
\end{align}

In the steady-state limit, the temperature equations (equations \ref{eq:app-solid} and \ref{eq:app-tempcool}) become \cite{tak_practical_2012}
\begin{align}
  & k_i \nabla^2 T_i + Q_i = 0 \\
  & \rho_{c,i} u_i\frac{\partial}{\partial z} (c_{p,c} T_c) = q'''_{conv}.
\end{align}

\section{Coolant distribution equation}
\label{appendix:equations-fluid}

The pressure drop in a coolant channel is proportinal to the mass flow squared
\begin{align}
  & \Delta P = B_i \dot{m}_i^2 \label{eq:app-itersolver1}
  \intertext{where}
  & \Delta P = \mbox{pressure drop } [Pa] \notag \\
  & \dot{m}_i = \mbox{channel $i$ mass flow rate } [kg \cdot s^{-1}] \notag \\
  & B_i = \mbox{constant specified by the chosen model, value that depends on $\dot{m}_i$} [kg \cdot m^{-1}] \notag
\end{align}
which is equivalent to
\begin{align}
  & \dot{m}_i = \sqrt{\frac{\Delta P}{B_i}}. \label{eq:app-itersolver2}
\end{align}

Assuming constant $\Delta P$ across all coolant paths, and using equation \ref{eq:app-itersolver2}, it is possible to calculate the total mass flow rate $\dot{m}_T$
\begin{align}
  & \dot{m}_T = \sum_i \dot{m}_i = \sum_i \sqrt{\frac{\Delta P}{B_i}} = \Delta P \frac{1}{\sum_i \sqrt{B_i}}.
\end{align}

Finally, equation \ref{eq:app-itersolver3} gives $\Delta P$
\begin{align}
  & \Delta P = \frac{\dot{m}_T}{\sum_i \frac{1}{\sqrt{B_i}}}. \label{eq:app-itersolver3}
\end{align}

These equations solve $\dot{m}_i$ using an iterative scheme as $B_i$ depends on $\dot{m}_i$ \cite{melese_thermal_1984}
\begin{align}
  & B_i^{(n)} = f(\dot{m}_i^{(n)}) \\
  & \Delta P^{(n)} = \frac{\dot{m}_T}{\sum_i \frac{1}{\sqrt{B_i^{(n)}}}} \\
  & \dot{m}_i^{(n+1)} = \sqrt{\frac{\Delta P^{(n)}}{B_i^{(n)}}}.
\end{align}


\section{Appendix}

\subsection{Input-output analysis}
\label{app:input_ouput}

For a 2x2 economy, the $\pmb{A^d}$ matrix is equal to:
$$ \pmb{A^d} =
\begin{pmatrix}
	\frac{Z11}{P1}  & \frac{Z12}{P2} \\
	\frac{Z21}{P1} & \frac{Z22}{P2}
\end{pmatrix}
=
\begin{pmatrix}
a  & b \\
c & d
\end{pmatrix}
$$
so:
$$\pmb{\pmb{I} - \pmb{A^d}} =
\begin{pmatrix}
1 - d  & b \\
c & 1 - a
\end{pmatrix}
$$

We define $\Delta$ as $\Delta = det(\pmb{I} - \pmb{A^d})$. Then
$\pmb{Q} = (\pmb{I} - \pmb{A^d})^{-1}$ is equal to
$$\pmb{Q} = \frac{1}{\Delta}
\begin{pmatrix}
1 - d  & b \\
c & 1 - a
\end{pmatrix}
$$

To get a better intuition of the mechanism, we introduce the value added per unit of production: $(va)_i = (VA_i/Pi)$.
Then, the value added per unit of final demand is equal to:
$$<va> \cdot Q =
\begin{pmatrix}
va_1 & 0 \\
0 & va_2
\end{pmatrix}
\cdot Q
= \frac{1}{\Delta}
\begin{pmatrix}
va_1 \cdot (1-d) & va_1 \cdot b \\
va_2 \cdot c & va_2 \cdot (1-a)
\end{pmatrix}
$$

$$<va> \cdot Q
= \frac{1}{\Delta}
\begin{pmatrix}
(1- a-c)\cdot (1-d) & (1-a-c) \cdot b \\
(1-b-d) \cdot c & (1-b-d) \cdot (1-a)
\end{pmatrix}
$$

which simplifies by noting that the sum of the column are equal to 1 :
$$<va> \cdot Q
=
\begin{pmatrix}
1-\theta_1 & \theta_2 \\
\theta_1  & 1-\theta_2
\end{pmatrix}
$$

with $\theta_1 =  \frac{(1-b-d) \cdot c}{(1-a)(1-d)-bc}$ and $\theta_2 = \frac{(1-a-c) \cdot b}{(1-a)(1-d)-bc}$.
This formula reveals that the Leontief matrix allocates demand between the various sector to generate a value added. For example, an increase of $\delta$ in the demand adressed to sector S1 would generated a value added in sector S1 equal to $(1-\theta_1) \cdot \delta$, and a value added in sector S2 equal to $\theta_1 \cdot \delta$.

We can now estimate the number of job per unit of final demand. To that end, we define the vector $e$ of job per unit of value added by :
$(e_i) = (E_i/VA_i)$, where $E_i$ is the number of jobs in sector i and $VA_i$ the value added in sector i.
The number of job per unit of domestic demand - which we call domestic employment content $\pmb{ce}^d$ - is equal to:
$$(\pmb{ce^d})^t =
\pmb{e}^t \cdot <va> \cdot Q
=
\begin{pmatrix}
e_1 (1-\theta_1) + e_2 \theta_1 ;&
e_1 \theta_2  + e_2 (1-\theta_2)
\end{pmatrix}
$$

This domestic employment content must now be linked to final demand.
A shift of $\delta$ in final demand from S1 to S2 leads to a change in domestic demand equals to:
$$\pmb{d^d} =
\pmb{<1-\tau_m>} \cdot
\begin{pmatrix}
-\delta  \\
\delta
\end{pmatrix}
=
\begin{pmatrix}
- (1 - \tau_1) \\
1 - \tau_2
\end{pmatrix} \cdot \delta
$$

\subsubsection{Impacts of shifting investment}
An increase of one million euros in final demand addressed to S2 leads to an increase in jobs equal to:
$$(1-\tau_2) \cdot \left( (1-\theta_2) e_2+ \theta_2 e_1 \right)$$.

An decrease of one million euros in final demand addressed to S1 leads to an increase in jobs equal to:
$$(1-\tau_1) \cdot \left( (1-\theta_1) e_1+ \theta_1 e_2 \right)$$.

A shift in final demand of one million euros from S1 to S2 leads to an increase in employment if and only if:
$$(1-\tau_2) \cdot \left( (1-\theta_2) e_2+ \theta_2 e_1 \right) > (1-\tau_1) \cdot \left( (1-\theta_1) e_1+ \theta_1 e_2 \right)$$

It then useful to note that the right parenthesis in each side is the domestic employment content, a weighted average of direct employment intensity. The above equation can be re-written as:
$$(1-\tau_2) \cdot ce^d_2> (1-\tau_1) \cdot ce^d_1 $$
so a shift in final demand generates jobs if an only if the product of the employment content and the import rate is higher.
But the computation of the employment content shows that the domestic employment content is high if demand generates value added in sector with a high number of jobs per value added.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage

\subsection{Closed economy}
\label{app:closed_economy}

\subsubsection{Overview of the closed model}
\begin{figure}[!ht]
	\centering
	\includegraphics[height=7cm]{figures/overview_closed.pdf}
	\caption{Overview of the closed economy model for the S2 sector}
	\label{fig:overview_closed}
\end{figure}

\subsubsection{Index of sets}
\begin{itemize}
	\item $u$: S1, S2, CAP, LAB, HOH, INV
	\item $i(u)$: S1, S2. Alias: $j(u)$.
	\item $h(u)$: CAP, LAB.
\end{itemize}

\subsubsection{Index of variables}
\begin{itemize}

	\item $Z_j$: output of the j-th good
	\item $F_{h,j}$: the h-th factor input by the j-th firm
	\item $FF_h$: the h-th factor supply
	\item $Inc$: Household income
	\item $C_i$: household consumption of the i-th good
	\item $p^x_i$: demand price of the i-th good
	\item $p^z_i$ supply price of the i-th good
	\item $p^f_h$ the h-th factor price
	\item $pc$ consumption price index
	\item $S^p$: private savings
	\item $U$: unemployment rate
	\item $UU$: utility (Cobb-Douglas)
\end{itemize}

\subsubsection{Index of parameters}
\begin{itemize}
	\item $\alpha_i$: share parameter in utility function
	\item $\sigma^z$: elasticity in CES production function
	\item $\rho^z = \frac{\sigma^z - 1}{\sigma^z}$: param. in CES production function
	\item $\delta_{h,j}$ share parameter in CES production function
	\item $scZ_j$: scale parameter in CES production function
	\item $\beta_{h,j}$: share parameter in Cobb-Douglas production function
	\item $b_j$: scale parameter in Cobb-Douglas production function
	\item $a_{h,j}$: Leontief coefficient in production function
	\item $\gamma$: wage curve elasticity
	\item $U^0$: initial unemployment rate
\end{itemize}

\subsubsection{Tests}

\paragraph{Walras' law}
Walras' law allows to take off one equation.
In our numerical application, we remove the market clearing of good for the first sector.
Then, we check after the run that Walras' law is satisfied.

\paragraph{Numéraire}
In our numerical application, we use the price index of consumption goods as the numéraire.
We check that the model is not sensitive to this assumption. We increase the numéraire by 10\% and rerun the model.
With this assumption, we check that all prices have increased by 10\%, and volumes remain the same.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\clearpage

\subsection{Simple CGE with two labor skills}
\label{app:two_labour_model}

\subsubsection{Overview of the simple CGE with two labor skills}
\begin{figure}[!ht]
	\centering
	\includegraphics[height=8cm]{figures/overview_twoLabors.pdf}
	\caption{Overview of the open economy model for the S2 sector}
	\label{fig:overview_twoLabors}
\end{figure}

\subsubsection{Index of sets}
\begin{itemize}
	\item $u$: S1, S2, CAP, LAB, HOH, INV
	\item $i(u)$: S1, S2. Alias: $j(u)$
	\item $h(u)$: CAP, LAB
	\item $s$: LABL, LABH
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\clearpage

\subsection{Open economy}
\label{app:open_economy_model}

\subsubsection{Overview of the open economy}
\begin{figure}[!ht]
	\centering
	\includegraphics[height=8cm]{figures/overview_open.pdf}
	\caption{Overview of the open economy model for the S2 sector}
	\label{fig:overview_open}
\end{figure}

\subsubsection{Index of sets}
\begin{itemize}
	\item $u$: S1, S2, CAP, LAB, HOH, INV, EXT
	\item $i(u)$: S1, S2
	\item $h(u)$: CAP, LAB
\end{itemize}

\subsubsection{Index of variables}
\begin{itemize}
	\item $Z_j$: output of the j-th good
	\item $FF_h$: factor supply
	\item $F_{h,j}$: the h-th factor input by the j-th firm
	\item $Inc$: Household income
	\item $C_i$: household consumption of the i-th good
	\item $E_i$:  exports
	\item $M_i$:  imports
	\item $Q_i$:  Armingtons composite good
	\item $D_i$:  domestic good

	\item $pf_h$: the h-th factor price
	\item $p^x_i$: consumption price
	\item $p^z_j$: supply price of the i-th good
	\item $p^q_i$: Armingtons composite good price
	\item $p^e_i$: export price in local currency
	\item $p^m_i$: import price in local currency
	\item $p^d_i$: the i-th domestic good price
	\item $\epsilon$: exchange rate
	\item $p^c$: price index

	\item $S^p$: private savings
	\item $S^f$: foreign savings
	\item $U$: unemployment rate
	\item $UU$: utility (Cobb-Douglas)
\end{itemize}

\subsubsection{Index of parameters}
\begin{itemize}
	\item $\alpha^u_i$: share parameter in utility func.
	\item $\sigma^z$: elasticity in CES production function
	\item $\rho^z = \frac{\sigma^z - 1}{\sigma^z}$: param. in CES production function
	\item $\delta_{h,j}$ share parameter in CES production function
	\item $scZ_j$: scale parameter in CES production function
	\item $\sigma^q$: elasticity of Armington substitution
	\item $\rho^q = \frac{\sigma^q-1}{\sigma^q}$: substitution elasticity parameter for Armington
	\item $\alpha^m_i$: share par. in Armington func.
	\item $\alpha^d_i$: share par. in Armington func.
	\item $scq_i$: scale par. in Armington func.
	\item $\gamma$: wage curve elasticity
	\item $U^0$: initial unemployment rate
\end{itemize}

\subsubsection{Results for IO and CGE}
\label{subsec:open_economy_results}

\begin{table}[!ht]
	\centering
	\caption{SAM results in an open economy with our IO model}
	\label{tab:SAM_IO_openEconomy}
	\begin{tabular}{llllllll}
		\toprule
		& S1 & S2 &  HOH & INV & EXT \\
		\midrule
		S1 &  &   & 8 & 5 & 3 \\
		S2 &  &    & 12 & 3 & 3 \\
		LAB & 9.60 & 8.53 &   &  &  \\
		CAP & 5.33 & 4.74 &   &  &  \\
		EXT & 1.06 & 4.74 &   &  &  \\
		\bottomrule
	\end{tabular}
\end{table}

\begin{table}[!ht]
	\centering
	\caption{Open economy with fixed exchange rate $\epsilon$ and endogenous imports}
	\label{tab:SAM_IO_OpenEconomy_noBudget}
	\begin{tabular}{llllll}
		\toprule
		& S1 & S2 & HOH & INV & EXT \\
		\midrule
		S1 &  &  & 10.96 & 5.00 & 0.00 \\
		S2 &  &  & 16.44 & 3.00 & 0.00 \\
		LAB & 9.41 & 8.59 &  &  &  \\
		CAP & 5.23 & 4.77 &  &  &  \\
		EXT & 1.33 & 6.08 &  &  &  \\
		\bottomrule
	\end{tabular}
\end{table}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\clearpage

\subsection{Full model}
\label{sec:full_model}

\subsubsection{Data}
\label{app:full_model_data}

At the 64-sector level of disaggregation, we encounter some issues to calibrate the CGE model:
\begin{itemize}
	\item Postal services (CPA\_H53) have negative capital revenues in 2013. Standard production functions with constant elasticity of substitution cannot account for a negative capital revenue.
	Since this sector is not crucial for our analysis of green jobs, we aggregate it with the other transportation service (CPA\_H50, CPA\_H51 and CPA\_H52).
	\item The "Manufacture of textiles, wearing apparel and leather products" sector (CPA\_C13-15) and "Computer, electronic and optical products" sector (CPA\_C26) export more than they produce. To avoid issues with negative values in the calibration of trade within the constant elasticity of transformation (CET) function, we aggregate the textile and leather products with "Manufacture of wood and of products of wood" (CPA\_C16) and computers with electrical equipment (CPA\_C27)
	\item The "imputed rent" sector (CPA\_L68A) indicates a low but positive remuneration for employees, but no employee. This would lead to an infinite salary. We aggregate this sector with the other real estate services (CPA\_L68B)
\end{itemize}

\subsubsection{Overview of the full CGE model}

\begin{figure}[!ht]
	\centering
	\includegraphics[width=14cm]{figures/overview_full.pdf}
	\caption{Overview of the fully-fledged model for the S2 sector}
	\label{fig:overview_full}
\end{figure}

\subsubsection{Index of sets}
\begin{itemize}
	\item u: SAM entry     /S1*S58, CAP, LAB, IDT, TRF, HOH, GOV,
	\item i(u): goods         /S1*S58/
	\item h(u): factor        /CAP, LAB/
	\item s: labor skill   / highSkill, lowSkill /
\end{itemize}

\subsubsection{Index of variables}
\begin{itemize}
	\item $Y_j$: composite factor
	\item $Inc$: household income
	\item $N(s,j)$: worker input by skill
	\item $K_j$: capital factor input by the j-th firm
	\item $L_j$: labor input
	\item $KK$: capital supply
	\item $NN(s)$: worker supply
	\item $X(i,j)$: intermediate input
	\item $Z_j$: output of the j-th good
	\item $C_i$: household consumption of the i-th good
	\item $G_i$: government consumption
	\item $I_i$: investment
	\item $E_i$: exports
	\item $M_i$: imports
	\item $Q_i$: Armington composite good
	\item $D_i$: domestic good

	\item $p^k$: capital factor price
	\item $p^l_j$: labor price
	\item $p^n_s$: workers price
	\item $p^y_j$: composite factor price
	\item $p^z_j$: supply price of the i-th good
	\item $p^q_i$: Armingtons composite good price
	\item $p^e_i$: export price in local currency
	\item $p^m_i$: import price in local currency
	\item $p^d_i$: the i-th domestic good price
	\item $\epsilon$: exchange rate

	\item $S^p$: private saving
	\item $S^g$: government saving
	\item $S^f$: foreign saving
	\item $T^d$: direct tax
	\item $T^z_j$: production tax
	\item $T^p$: private consumption tax
	\item $T^v$: investment tax

	\item $KK$: capital supply
	\item $NN_s$: labor supply
	\item $pc$: consumption price

	\item $UU$: utility (Cobb-Douglas)
\end{itemize}

\subsubsection{Index of parameters}
\begin{itemize}
	\item $\sigma^Y$: elasticity of substitution in composite factor production
	\item $\rho^Y = \frac{\sigma^Y - 1}{\sigma^Y}$: substitution elasticity parameter for capital-labor composite
	\item $\sigma_i$: elasticity of Armington substitution
	\item $\eta_i = \frac{\sigma^z - 1}{\sigma^z}$: substitution elasticity parameter for Armington
	\item $\psi_i$: elasticity of transformation
	\item $\phi_i= \frac{\psi^z - 1}{\psi^z}$: transformation elasticity parameter
	\item $\alpha_i$: share parameter in utility func.
	\item $\delta^l_j$: labor share   in CES prod. func.
	\item $\delta^k_j$: capital share in CES prod. func.
	\item $scY$: scale param.  in CES prod. func.
	\item $\beta\_N(s,j)$: share parameter in labor function
	\item $scL_j$: scale parameter in labor function
	\item $ax(i,j)$: intermediate input requirement coeff.
	\item $ay_j$:  composite fact. input req. coeff.
	\item $\mu_i$:  government consumption share
	\item $\lambda_i$: investment demand share
	\item $\delta^m_i$: share par. in Armington func.
	\item $\delta^d_i$: share par. in Armington func.
	\item $scQ_i$: scale par. in Armington func.
	\item $\xi^d_i$: share par. in transformation func.
	\item $\xi^e_i$: share par. in transformation func.
	\item $\theta_i$: scale par. in transformation func.
	\item $ssg$: average propensity for gov. saving
	\item $\tau^d$: direct tax rate
	\item $Pop$: population (labor force)
	\item $U^0_s$: initial unemployment
	\item $p^{We}_i$: export price in US dollars
	\item $p^{Wm}_i$: import price in US dollars
	\item $\tau^z_i$: production tax rate
	\item $\tau^p$: private consumption tax rate
	\item $\tau^v$: investment tax
	\item $Pop$: population (labor force)
	\item $\gamma$: wage curve elasticity
\end{itemize}

\begin{table}[!ht]
	\centering
	\caption{Comparative equations of IO and CGE models. Identical equations are not repeated to facilitate reading. The main differences with the closed version shown in table \ref{tab:closedModel} have their equations labeled in bold.}
	\label{tab:fullModel}
	\begin{tabular}{llll}
		\toprule
		Num & Description & Standard CGE  \\
		\midrule
		eq1 & Production function & $Y_j    = scY_j \cdot  ( \delta^k_j \cdot K_j^{\rho_Y} + \delta^l_j \cdot L_j^{\rho_Y} )^{1/\rho_Y}$ \\
		eq2 & Capital demand & $ K_j = (scY_j^{\rho_Y} \cdot  \delta^k_j \cdot  p^y_j / p^k )^{\sigma_Y} \cdot  Y_j $ \\
		eq3 & Labor demand  & $L_j = (scY_j^{\rho_Y} \cdot \delta^l_j \cdot  p^y_j / p^l_j )^{\sigma_Y} \cdot Y_j $ \\
		eq4 & Demand of intermediate goods & $X_{i,j}  = ax_{i,j} \cdot Z_j$ \\
		eq5 & Demand of composite factor & $Y_j    = ay_j \cdot Z_j$ \\
		eq6 & Condition of zero profit & $p^z_j   = ay_j \cdot p^y_j + \sum_i ax_{i,j} \cdot p^q_i$ \\
		eq7 & Production of labor composite & $L_j    = scL_j \cdot  \prod_s N_{s,j}^{\beta^N_{s,j}}$  \\
		eq8 & Demand of labor by skill & $N_{s,j}  = \beta^N_{s,j} \cdot p^l_j \cdot  L_j / p^n_s$ \\
		eq9 & Unemployment & $ U_s =  1 - NN_s/Pop_s $\\
		eq10 & Labor supply & $\log( p^n_s / p^c ) = - \gamma \cdot  log(\frac{U_s}{U^0_s}) $  \\
		eq11 & Capital supply & $KK = \overline{KK} $  \\
		\midrule
		eq12 & Direct tax on household & $T^d = \tau^d \cdot Inc $\\
		eq13 & Tax on production & $T^z_j = \tau^z_j \cdot p^z_j \cdot Z_j$ \\
		eq14 & Tax on household consumption & $T^p = \tau^p \cdot \sum_j  p^q_j \cdot C_j $ \\
		eq15 & Tax on investment & $T^v = \tau^v \cdot \sum_j p^q_j\cdot I_j $ \\
		eq16 & Government consumption & $G_i = \mu_i ~ ( T^d + \sum_j T^z_j + T^p + T^v - S^g ) / p^q_i$ \\
		\midrule
		eq17 & Private savings & $S^p = \sum_i (1+\tau^v) \cdot p^q_i \cdot I_i - S^g - \epsilon \cdot S^f$ \\
		eq18 & Government savings & $S^g = ssg \cdot  (T^d + \sum_j T^z_j + T^p + T^v)$ \\
		\midrule
		eq19 & Household income &  $Inc = p^k \cdot KK + \sum_s p^n_s \cdot NN_s $ \\
		eq20 & Houshold consumption & $C_i = \alpha_i \cdot  (Inc -S^p - T^d) / ((1+\tau^p) ~ p^q_i) $ \\
		\midrule
		eq21 & Export demand & $p^e_i = \epsilon \cdot pWe_i$ \\
		eq22 & Import supply & $p^m_i =\epsilon \cdot p^{Wm}_i$ \\
		eq23 & Balance of trade & $\sum_i p^{We}_i \cdot E_i +S^f = \sum_i p^{Wm}_i \cdot M_i$ \\
		eq24 & Trade closure & $S^f = \overline{S^f}$  \quad OR \quad $\epsilon = \overline{\epsilon}$  \\
		\midrule
		eq25 & Armington function & $Q_i = scQ_i \cdot (\alpha^m_i M_i^{\rho_Q} + \alpha^d_i D_i^{\rho_Q}  )^{1/\rho_Q} $ \\
		eq26 & Imports demand & $M_i = \left( scQ_i^{\rho_Q} \cdot \alpha_i^m \cdot \frac{p_i^q}{p_i^m} \right)^{\sigma_Q} Q_i$ \\
		eq27& Domestic demand & $D_i = \left( scQ_i^{\rho_Q} \cdot \alpha_i^d \cdot \frac{p_i^q}{p_i^d} \right)^{\sigma_Q} Q_i$ \\
		eq28 & CET function & $Z_i  = \theta_i \cdot  (\xi^e_i \cdot E_i^{\phi_i} + \xi^d_i \cdot D_i^{\phi_i} )^{(1/\phi_i)} $  \\
		eq29 & Demand of E & $  E_i = (\theta_i^{\phi_i} \cdot \xi^e_i\cdot (1+\tau^z_i) ~ p^z_i/p^e_i)^{(1/(1-\phi_i))} ~Z_i $ \\
		eq30 & Demand of D & $ D_i = (\theta_i^{\phi_i} \cdot \xi^d_i \cdot (1+\tau^z_i) ~ p^z_i/p^d_i)^{(1/(1-\phi_i))} ~ Z_i $ \\
		\midrule
		eq31 &  Balance of domestic good & $Q_i = C_i + I_i$ &  \\
		eq32 & Balance of labor & $NN_s = \sum_j N_{s,j}$ &   \\
		eq33 & Balance of capital & $KK  = \sum_j K_j $ &   \\
		eq34 & Price equality & $p^c_i = p^z_i$ & \\
		\bottomrule
	\end{tabular}
\end{table}

\clearpage

\subsubsection{Cobb-Douglas elasticity vs Empirical estimates}

\begin{table}[!ht]
	\centering
	\caption{Comparing job creation using CES vs Cobb-Douglas \\\hspace{\textwidth} (for a wage curve elasticity $\gamma$=0.1, $\sigma_{Armington}$ =2  and $\psi_{CET}$=2)}
	\label{tab:CobbDouglasError}
	\begin{tabular}{lcccc}
		\toprule
		Techno & Elasticité  &  Value & Value & Error (\%) \\
	    & $\sigma_{KL}$ &  with CES & with Cobb-Douglas& Cobb-Douglas vs CES \\
		\midrule
		Solar & 0.2 &  5858 & 3542 & -40 \\
Solar & 0.3 &5394 & 3542 & -34 \\
Solar & 0.4 & 5003 & 3542 & -29 \\
Solar & 0.5 & 4670 & 3542 & -24 \\
Solar & 0.6 & 4382 & 3542 & -19 \\
Weatherization & 0.2 & 6589 & 4135 & -37 \\
Weatherization & 0.3 & 6097 & 4135 & -32 \\
Weatherization & 0.4 & 5683 & 4135 & -27 \\
Weatherization & 0.5 & 5331 & 4135 & -22 \\
Weatherization & 0.6 & 5026 & 4135 & -18 \\
		\bottomrule
	\end{tabular}
\end{table}

\clearpage

\subsubsection{Trade}

\begin{figure}[!ht]
	\centering
	\includegraphics[height=4cm]{figures/Armington.pdf}
	\caption{Impact of the Armington elasticity (with CET elasticity equal to two)}
	\label{fig:armington}
\end{figure}

\begin{figure}[!ht]
	\centering
	\includegraphics[height=4cm]{figures/CET.pdf}
	\caption{Impact of the CET elasticity (with Armington elasticity equal to two)}
	\label{fig:cet}
\end{figure}

\begin{figure}[!ht]
	\centering
	\includegraphics[height=4cm]{figures/closure.pdf}
	\caption{Impact of the trade closure rule}
	\label{fig:closure}
\end{figure}

\subsubsection{Full sensitivity analysis}
\label{sec:full_sensitivity}

\begin{table}
	\small
	\centering
	\caption{Full sensitivity analysis for solar }
	\begin{tabular}{cccccccc}
		\toprule
		Techno & $\gamma$ & $\sigma_{KL}$ & $\sigma_{\text{Armington}}$ & $\psi_{\text{CET}}$ & Jobs in CGE &Jobs in IO & Ratio \\
		\midrule
		Solar & 0.1 & 0.2 & 1.5 & 1.5 & 6035 & 5010 & 0.83 \\
		Solar & 0.1 & 0.2 & 1.5 & 2 & 5945 & 5010 & 0.84 \\
		Solar & 0.1 & 0.2 & 1.5 & 4 & 5612 & 5010 & 0.89 \\
		Solar & 0.1 & 0.2 & 1.5 & 6 & 5314 & 5010 & 0.94 \\
		Solar & 0.1 & 0.2 & 2 & 1.5 & 5945 & 5010 & 0.84 \\
		Solar & 0.1 & 0.2 & 2 & 2 & 5858 & 5010 & 0.86 \\
		Solar & 0.1 & 0.2 & 2 & 4 & 5534 & 5010 & 0.91 \\
		Solar & 0.1 & 0.2 & 2 & 6 & 5244 & 5010 & 0.96 \\
		Solar & 0.1 & 0.2 & 4 & 1.5 & 5613 & 5010 & 0.89 \\
		Solar & 0.1 & 0.2 & 4 & 2 & 5535 & 5010 & 0.91 \\
		Solar & 0.1 & 0.2 & 4 & 4 & 5245 & 5010 & 0.96 \\
		Solar & 0.1 & 0.2 & 4 & 6 & 4984 & 5010 & 1.01 \\
		Solar & 0.1 & 0.2 & 6 & 1.5 & 5316 & 5010 & 0.94 \\
		Solar & 0.1 & 0.2 & 6 & 2 & 5247 & 5010 & 0.95 \\
		Solar & 0.1 & 0.2 & 6 & 4 & 4985 & 5010 & 1.00 \\
		Solar & 0.1 & 0.2 & 6 & 6 & 4748 & 5010 & 1.06 \\
		Solar & 0.1 & 0.4 & 1.5 & 1.5 & 5130 & 5010 & 0.98 \\
		Solar & 0.1 & 0.4 & 1.5 & 2 & 5066 & 5010 & 0.99 \\
		Solar & 0.1 & 0.4 & 1.5 & 4 & 4823 & 5010 & 1.04 \\
		Solar & 0.1 & 0.4 & 1.5 & 6 & 4603 & 5010 & 1.09 \\
		Solar & 0.1 & 0.4 & 2 & 1.5 & 5066 & 5010 & 0.99 \\
		Solar & 0.1 & 0.4 & 2 & 2 & 5003 & 5010 & 1.00 \\
		Solar & 0.1 & 0.4 & 2 & 4 & 4766 & 5010 & 1.05 \\
		Solar & 0.1 & 0.4 & 2 & 6 & 4551 & 5010 & 1.10 \\
		Solar & 0.1 & 0.4 & 4 & 1.5 & 4824 & 5010 & 1.04 \\
		Solar & 0.1 & 0.4 & 4 & 2 & 4767 & 5010 & 1.05 \\
		Solar & 0.1 & 0.4 & 4 & 4 & 4552 & 5010 & 1.10 \\
		Solar & 0.1 & 0.4 & 4 & 6 & 4355 & 5010 & 1.15 \\
		Solar & 0.1 & 0.4 & 6 & 1.5 & 4605 & 5010 & 1.09 \\
		Solar & 0.1 & 0.4 & 6 & 2 & 4553 & 5010 & 1.10 \\
		Solar & 0.1 & 0.4 & 6 & 4 & 4356 & 5010 & 1.15 \\
		Solar & 0.1 & 0.4 & 6 & 6 & 4175 & 5010 & 1.20 \\
		Solar & 0.1 & 0.6 & 1.5 & 1.5 & 4480 & 5010 & 1.12 \\
		Solar & 0.1 & 0.6 & 1.5 & 2 & 4430 & 5010 & 1.13 \\
		Solar & 0.1 & 0.6 & 1.5 & 4 & 4244 & 5010 & 1.18 \\
		Solar & 0.1 & 0.6 & 1.5 & 6 & 4073 & 5010 & 1.23 \\
		Solar & 0.1 & 0.6 & 2 & 1.5 & 4431 & 5010 & 1.13 \\
		Solar & 0.1 & 0.6 & 2 & 2 & 4382 & 5010 & 1.14 \\
		Solar & 0.1 & 0.6 & 2 & 4 & 4200 & 5010 & 1.19 \\
		Solar & 0.1 & 0.6 & 2 & 6 & 4033 & 5010 & 1.24 \\
		Solar & 0.1 & 0.6 & 4 & 1.5 & 4245 & 5010 & 1.18 \\
		Solar & 0.1 & 0.6 & 4 & 2 & 4201 & 5010 & 1.19 \\
		Solar & 0.1 & 0.6 & 4 & 4 & 4034 & 5010 & 1.24 \\
		Solar & 0.1 & 0.6 & 4 & 6 & 3879 & 5010 & 1.29 \\
		Solar & 0.1 & 0.6 & 6 & 1.5 & 4075 & 5010 & 1.23 \\
		Solar & 0.1 & 0.6 & 6 & 2 & 4035 & 5010 & 1.24 \\
		Solar & 0.1 & 0.6 & 6 & 4 & 3880 & 5010 & 1.29 \\
		Solar & 0.1 & 0.6 & 6 & 6 & 3737 & 5010 & 1.34 \\
		\bottomrule
		\end{tabular}
\end{table}

\begin{table}
	\small
		\centering
		\caption{Full sensitivity analysis for weatherization}
		\begin{tabular}{cccccccc}
		\toprule
			Techno & $\gamma$ & $\sigma_{KL}$ & $\sigma_{\text{Armington}}$ & $\psi_{\text{CET}}$ & Jobs in CGE &Jobs in IO & Ratio \\
		\midrule
		Weatherization & 0.1 & 0.2 & 1.5 & 1.5 & 6782 & 8050 & 1.19 \\
		Weatherization & 0.1 & 0.2 & 1.5 & 2 & 6684 & 8050 & 1.20 \\
		Weatherization & 0.1 & 0.2 & 1.5 & 4 & 6321 & 8050 & 1.27 \\
		Weatherization & 0.1 & 0.2 & 1.5 & 6 & 5997 & 8050 & 1.34 \\
		Weatherization & 0.1 & 0.2 & 2 & 1.5 & 6683 & 8050 & 1.20 \\
		Weatherization & 0.1 & 0.2 & 2 & 2 & 6589 & 8050 & 1.22 \\
		Weatherization & 0.1 & 0.2 & 2 & 4 & 6237 & 8050 & 1.29 \\
		Weatherization & 0.1 & 0.2 & 2 & 6 & 5921 & 8050 & 1.36 \\
		Weatherization & 0.1 & 0.2 & 4 & 1.5 & 6321 & 8050 & 1.27 \\
		Weatherization & 0.1 & 0.2 & 4 & 2 & 6236 & 8050 & 1.29 \\
		Weatherization & 0.1 & 0.2 & 4 & 4 & 5921 & 8050 & 1.36 \\
		Weatherization & 0.1 & 0.2 & 4 & 6 & 5637 & 8050 & 1.43 \\
		Weatherization & 0.1 & 0.2 & 6 & 1.5 & 5998 & 8050 & 1.34 \\
		Weatherization & 0.1 & 0.2 & 6 & 2 & 5922 & 8050 & 1.36 \\
		Weatherization & 0.1 & 0.2 & 6 & 4 & 5638 & 8050 & 1.43 \\
		Weatherization & 0.1 & 0.2 & 6 & 6 & 5380 & 8050 & 1.50 \\
		Weatherization & 0.1 & 0.4 & 1.5 & 1.5 & 5824 & 8050 & 1.38 \\
		Weatherization & 0.1 & 0.4 & 1.5 & 2 & 5753 & 8050 & 1.40 \\
		Weatherization & 0.1 & 0.4 & 1.5 & 4 & 5486 & 8050 & 1.47 \\
		Weatherization & 0.1 & 0.4 & 1.5 & 6 & 5244 & 8050 & 1.54 \\
		Weatherization & 0.1 & 0.4 & 2 & 1.5 & 5753 & 8050 & 1.40 \\
		Weatherization & 0.1 & 0.4 & 2 & 2 & 5683 & 8050 & 1.42 \\
		Weatherization & 0.1 & 0.4 & 2 & 4 & 5423 & 8050 & 1.48 \\
		Weatherization & 0.1 & 0.4 & 2 & 6 & 5187 & 8050 & 1.55 \\
		Weatherization & 0.1 & 0.4 & 4 & 1.5 & 5486 & 8050 & 1.47 \\
		Weatherization & 0.1 & 0.4 & 4 & 2 & 5423 & 8050 & 1.48 \\
		Weatherization & 0.1 & 0.4 & 4 & 4 & 5187 & 8050 & 1.55 \\
		Weatherization & 0.1 & 0.4 & 4 & 6 & 4971 & 8050 & 1.62 \\
		Weatherization & 0.1 & 0.4 & 6 & 1.5 & 5245 & 8050 & 1.53 \\
		Weatherization & 0.1 & 0.4 & 6 & 2 & 5188 & 8050 & 1.55 \\
		Weatherization & 0.1 & 0.4 & 6 & 4 & 4972 & 8050 & 1.62 \\
		Weatherization & 0.1 & 0.4 & 6 & 6 & 4774 & 8050 & 1.69 \\
		Weatherization & 0.1 & 0.6 & 1.5 & 1.5 & 5135 & 8050 & 1.57 \\
		Weatherization & 0.1 & 0.6 & 1.5 & 2 & 5080 & 8050 & 1.58 \\
		Weatherization & 0.1 & 0.6 & 1.5 & 4 & 4873 & 8050 & 1.65 \\
		Weatherization & 0.1 & 0.6 & 1.5 & 6 & 4684 & 8050 & 1.72 \\
		Weatherization & 0.1 & 0.6 & 2 & 1.5 & 5080 & 8050 & 1.58 \\
		Weatherization & 0.1 & 0.6 & 2 & 2 & 5026 & 8050 & 1.60 \\
		Weatherization & 0.1 & 0.6 & 2 & 4 & 4824 & 8050 & 1.67 \\
		Weatherization & 0.1 & 0.6 & 2 & 6 & 4639 & 8050 & 1.74 \\
		Weatherization & 0.1 & 0.6 & 4 & 1.5 & 4873 & 8050 & 1.65 \\
		Weatherization & 0.1 & 0.6 & 4 & 2 & 4824 & 8050 & 1.67 \\
		Weatherization & 0.1 & 0.6 & 4 & 4 & 4639 & 8050 & 1.74 \\
		Weatherization & 0.1 & 0.6 & 4 & 6 & 4468 & 8050 & 1.80 \\
		Weatherization & 0.1 & 0.6 & 6 & 1.5 & 4684 & 8050 & 1.72 \\
		Weatherization & 0.1 & 0.6 & 6 & 2 & 4640 & 8050 & 1.74 \\
		Weatherization & 0.1 & 0.6 & 6 & 4 & 4469 & 8050 & 1.80 \\
		Weatherization & 0.1 & 0.6 & 6 & 6 & 4310 & 8050 & 1.87 \\
		\bottomrule
	\end{tabular}
\end{table}


%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
\section{Discussion}
\label{sec:Discussion}
%%%%%%%%%%%%%%%%%%%%%%

We have addressed the problem of characterizing the loss surface of neural networks from the perspective
of gradient descent algorithms. We explored two angles -- topological and geometrical aspects -- that build on top of each other.

On the one hand, we have presented new theoretical results that quantify
the amount of uphill climbing that is required in order to progress to lower energy configurations in
single hidden-layer ReLU networks, and proved that this amount converges to zero with overparametrization under mild conditions. On the other hand, we have introduced a dynamic programming algorithm that efficiently approximates geodesics within each level set, providing a tool that not only verifies the connectedness of level sets, but also estimates the geometric regularity of these sets. Thanks to this information, we can quantify how `non-convex' an optimization problem is, and verify that the optimization of quintessential deep learning tasks -- CIFAR-10 and MNIST classification using CNNs, and next word prediction using LSTMs -- behaves in a nearly convex fashion up until they reach high accuracy levels.

That said, there are some limitations to our framework. In particular, we do not address saddle-point issues that can greatly affect the actual convergence of gradient descent methods. There are also a number of open questions; amongst those, in the near future we shall concentrate on:
\begin{itemize}
\item \emph{Extending Theorem \ref{maintheo} to the multilayer case}. We believe this is within reach, since the main analytic tool we use is that small changes in the parameters result in small changes in the covariance structure of the features. That remains the case in the multilayer case.
\item \emph{Empirical versus Oracle Risk}. A big limitation of our theory is that right now it does not inform us on the differences between optimizing the empirical risk versus the oracle risk. Understanding the impact of generalization error and stochastic gradient in the ability to do small uphill climbs is an open line of research.
\item \emph{Influence of symmetry groups}.  Under appropriate conditions, the presence of discrete symmetry groups does not prevent the loss from being connected, but at the expense of increasing the capacity. An important open question is whether one can improve the asymptotic properties by relaxing connectedness to being connected up to discrete symmetry.
\item \emph{Improving numerics with Hyperplane method}. Our current numerical experiments employ a greedy (albeit faster) algorithm to discover connected components and estimate geodesics. We plan to perform experiments using the less greedy algorithm described in Appendix \ref{sec:ConstrainedAlg}.
\end{itemize}

%\begin{itemize}
%\item Future: Generalization Error Question.
%
%\end{itemize}


\section{Flow over a smooth downward step}

This is a standard textbook energy conservation type problem. Water flows over a flat bedded channel, then through a smooth downward step, and continues over a flat bottomed channel with lower bed elevation.

The bed is represented with a one dimensional domain over $[0,25]$ m, with topography
\begin{equation}
z(x)= \left\{ \begin{array}{ll}
 0.2 & ~\textrm{if}\quad x \leq 9 ,,\\
 0.2-0.1(x-9) & ~\textrm{if}\quad 9 \leq x \leq 11\,,\\
 0 & ~\textrm{otherwise}\,,\\
\end{array} \right.
\end{equation}
The stage is imposed at the downstream boundary, and the discharge is imposed at the upstream boundary.

The analytical height is found by solving the Bernoulli equation. The simplified Bernoulli equation is the following cubic equation
\begin{equation}
h^3 + \left(z - \frac{q^2}{2 g H^2} - H \right) h^2 + \frac{q^2}{2 g} = 0\,,
\end{equation}
where $H$ is the upstream height and $q=uh$ is the discharge or $x$-momentum. When the height $h$ has been found, the velocity is computed as $u=q/h$\,.

\subsection{Results}
For our test we impose a discharge-per-unit-width of 1m$^2$/s, and a downstream stage boundary condition of 1.0m.

Representatives of the simulation results are given in the following three figures. The boundary regions are excluded from the plot because the inflow boundary takes some time to adapt to the analytical solution (which is to be expected as we don't enforce the depth or velocity directly there). There should be excellent agreement between the numerical and analytical solutions.

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{stage_plot.png}
\end{center}
\caption{Stage results}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{xmom_plot.png}
\end{center}
\caption{Xmomentum results}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[width=0.9\textwidth]{xvel_plot.png}
\end{center}
\caption{Xvelocity results}
\end{figure}

\endinput


% Created 2021-07-14 Wed 11:54
% Intended LaTeX compiler: pdflatex
\documentclass[presentation,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{khpreamble}
\usepackage{amssymb}
\usepackage{pgfplotstable}
\DeclareMathOperator{\shift}{q}
\DeclareMathOperator{\diff}{p}
\usetheme{default}
\author{Kjartan Halvorsen}
\date{\today}
\title{System identification}
\hypersetup{
 pdfauthor={Kjartan Halvorsen},
 pdftitle={System identification},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.3 (Org mode 9.4.6)},
 pdflang={English}}
\begin{document}

\maketitle

\section{Intro}
\label{sec:org2f040f4}
\begin{frame}[label={sec:org0fdcf79}]{A complicated process}
\begin{columns}
\begin{column}{0.6\columnwidth}
From Wikipedia "Cyclonic separation"
\end{column}
\begin{column}{0.4\columnwidth}
\begin{center}
\includegraphics[height=1.0\textheight]{../../figures/Vertical-cyclone.jpg}
\end{center}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org5066307}]{System identification}
\begin{center}
  \begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm, inner sep=10pt}, sumnode/.style={circle, draw, inner sep=2pt},]

    \node[coordinate] (input) {};
    \node[coordinate, right of=input] (copy) {};
    \node[coordinate, right of=copy] (midp) {};
    \node[block, above of=midp, node distance=10mm] (sys)  {System};
    \node[block, below of=midp, node distance=10mm] (mod)  {Model};
    \node[sumnode, right of=midp, node distance=26mm] (sum) {\tiny $\Sigma$};
    \node[coordinate, right of=sum, node distance=22mm] (output) {};

    \draw[-] (input) -- node[above, pos=0.2] {Measured input} (copy);
    \draw[->] (copy) |- node[above] {} (sys);
    \draw[->] (copy) |- node[above] {} (mod);
    \draw[->] (sys) -| node[left, pos=0.9] {$+$} (sum);
    \draw[->] (mod) -| node[left, pos=0.9] {$-$} (sum);
    \draw[->] (sum) -- node[above, near end] {Error} (output);

    \draw[thick, red!70!black, ->] (2.7,-2) -- (3.3,-2) -- (5.3, 0);
  \end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}[label={sec:orgbf66964}]{The Auto-Regressive with eXogenous input (ARX) model}
\begin{center}
\includegraphics[width=0.7\linewidth]{../../figures/block-arx}
\end{center}
\[ A(\shift) y(k) = B(\shift)u(k) + e(k+n) \]

The error signal \(e(k)\) is a zero-mean white noise sequence representing perturbations and modeling errors.
\end{frame}

\begin{frame}[label={sec:org43fbae7}]{First-order ARX model with one delay}
\begin{center}
\includegraphics[width=0.3\linewidth]{../../figures/block-arx}
\end{center}
\[ (\shift + a_1) y(k) = (b_0 \shift + b_1) \shift^{-1}u(k) + e(k+1) \]
\[ y(k+1) +  a_1y(k) = b_0u(k) + b_1u(k-1) + e(k+1) \]

\pause

Using the model to predict the output one step ahead:
\begin{align*}
 \hat{y}(k+1) &= -a_1y(k) + b_0u(k) + b_1u(k-1) =  \underbrace{\begin{bmatrix} -y(k) & u(k) & u(k-1) \end{bmatrix}}_{\varphi_{k+1}^T} \underbrace{\begin{bmatrix} a_1\\b_0\\b_1\end{bmatrix}}_{\theta}\\
 &= \varphi_{k+1}^T\theta
 \end{align*}
\end{frame}

\begin{frame}[label={sec:org82bc73b}]{Parameter estimation - Least squares}
\alert{Objective} Given observations \[\mathcal{D} = \{ (u_1,y_1), (u_2, y_2), \ldots, (u_N, y_N)\}\] and model \(\mathcal{M}: \; y(k+1) = -ay(k) + b_0u(k) + b_1u(k-1)  + e(k+1)\), obtain the parameters \((a_1,\,b_0,\,b_1)\) which gives the best fit of the model to the data.
\end{frame}

\begin{frame}[label={sec:orgee9dfe7}]{Parameter estimation - Least squares}
Given observations \[\mathcal{D} = \{ (u_1,y_1), (u_2, y_2), \ldots, (u_N, y_N)\}\] and model \(\mathcal{M}: \; y(k+1) = -ay(k) + b_0u(k) + b_1u(k-1)  + e(k+1)\).

\begin{enumerate}
\item Form the one-step ahead prediction
\[ \hat{y}_{k+1} = -a_1y_k + b_0u_k + b_1u_{k-1} =  \underbrace{\begin{bmatrix} -y_k & u_k & u_{k-1} \end{bmatrix}}_{\varphi_{k+1}^T} \underbrace{\begin{bmatrix} a_1\\b_0\\b_1\end{bmatrix}}_{\theta}\] and the prediction error
   \[ \epsilon_{k+1} = y_{k+1} - \hat{y}_{k+1} = y_{k+1} - \varphi_{k+1}^T\theta.\]
\end{enumerate}
\end{frame}

\begin{frame}[label={sec:orgd1a0844}]{Parameter estimation - Least squares}
\begin{enumerate}
\setcounter{enumi}{1}
\item Combine all the observations \(y_k\) and predictions \(\hat{y}_k\) on vector form
\begin{align*}
\epsilon &= \begin{bmatrix} \epsilon_3\\\epsilon_4\\\vdots\\\epsilon_N\end{bmatrix} =  \begin{bmatrix} y_3\\ y_4\\\vdots\\y_N \end{bmatrix} - \begin{bmatrix} \hat{y}_3\\ \hat{y}_4\\\vdots\\\hat{y}_N \end{bmatrix}
 =  \begin{bmatrix} y_2\\ y_3\\\vdots\\y_N \end{bmatrix} - \begin{bmatrix} \varphi_2^T\theta\\ \varphi_3^T\theta\\\vdots\\\varphi_N^T\theta \end{bmatrix}\\
&= y - \underbrace{\begin{bmatrix}\varphi_1^T\\\varphi_2^T\\\vdots\\\varphi_N^T\end{bmatrix}}_{\Phi}\theta = y - \Phi\theta
\end{align*}
\item Solve \(\arg\min \; J(\theta) = \frac{1}{2}\epsilon^T\epsilon = \frac{1}{2}\sum_{i=3}^N \epsilon_i(\theta)^2\)
\end{enumerate}
\end{frame}

\begin{frame}[label={sec:org6ce2d0d}]{The problem with least squares}
\begin{columns}
\begin{column}{0.4\columnwidth}
\begin{align*}
 \text{minimize} \; &\sum_k g(\epsilon_k)\\
 \text{where} \; g(u) &= u^2
\end{align*}
\end{column}

\begin{column}{0.6\columnwidth}
\begin{center}
  \begin{tikzpicture}
    \begin{axis}[
      width=8cm,
      height=6cm,
      ylabel=loss,
      xlabel=penalty,
      ]
      \addplot[red, thick, no marks, domain=-4:4, samples=201] {x^2};
    \end{axis}
  \end{tikzpicture}
\end{center}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org49222fc}]{More robust: The Huber loss function}
\begin{columns}
\begin{column}{0.4\columnwidth}
Also known as \alert{robust regression}
\begin{align*}
 \text{minimize} \; &\sum_k g_{hub}(\epsilon_k)\\
 \text{where}\; g_{hub}(u) &= \begin{cases} u^2 & |u| \le M\\ M(2|u|-M) & |u| > M \end{cases}
\end{align*}
\end{column}

\begin{column}{0.6\columnwidth}
\begin{center}
  \begin{tikzpicture}
    \begin{axis}[
      width=8cm,
      height=6cm,
      ylabel=penalty,
      xlabel=residual,
      ]
      \addplot[red, thick, no marks, domain=-4:4, samples=201] {x^2};
      \addplot[orange!90!black, ultra thick, no marks, domain=-4:-1, samples=201] {2*abs(x)-1};
      \addplot[orange!90!black, thin, no marks, domain=-1:1, samples=201] {x^2};
      \addplot[orange!90!black, ultra thick, no marks, domain=1:4, samples=201] {2*abs(x)-1};
    \end{axis}
  \end{tikzpicture}
\end{center}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org10b0bf3}]{First-order ARX model without delay}
\begin{center}
\includegraphics[width=0.4\linewidth]{../../figures/block-arx}
\end{center}
\[ (\shift + a_1) y(k) = (b_0 \shift + b_1) u(k) + e(k+1) \]

\alert{Activity}

\begin{enumerate}
\item Determine the one-step ahead predictor \(\hat{y}_{k+1}\) and the prediction error \(\epsilon_{k+1}\).
\item Form the system of equations \(\Phi\theta = y\)
\end{enumerate}
\end{frame}

\begin{frame}[label={sec:orgc2d06b4}]{The ARX model}
\[ A(\shift) y(k) = B(\shift)u(k) + e(k+n)\]

\alert{Activity} Fill the empty blocks.

\begin{center}
  \begin{tikzpicture}[node distance=22mm, block/.style={rectangle, draw, minimum width=15mm, minimum height=12mm}, sumnode/.style={circle, draw, inner sep=2pt}]

    \node[coordinate] (input) {};
    \node[block, right of=input, node distance=20mm] (plant)  {};
    \node[sumnode, right of=plant, node distance=24mm] (sum) {\tiny $\Sigma$};
    \node[block, above of=sum, node distance=20mm] (dist)  {};

    \node[coordinate, above of=dist, node distance=12mm] (disturbance) {};
    \node[coordinate, right of=sum, node distance=20mm] (output) {};

    \draw[->] (input) -- node[above, pos=0.3] {$u(k)$} (plant);
    \draw[->] (plant) -- node[above] {} (sum);
    \draw[->] (sum) -- node[above, near end] {$y(k)$} (output);
    \draw[->] (disturbance) -- node[right, pos=0.2] {$e(k)$} (dist);
    \draw[->] (dist) -- node[above] {} (sum);

  \end{tikzpicture}
\end{center}
\end{frame}
\end{document}