    \filetitle{estimate}{Estimate a reduced-form VAR or BVAR}{VAR/estimate}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
[V,VData,Fitted] = estimate(V,Inp,Range,...)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\item
  \texttt{V} {[} VAR {]} - Empty VAR object.
\item
  \texttt{Inp} {[} struct {]} - Input database.
\item
  \texttt{Range} {[} numeric {]} - Estimation range, including
  \texttt{P} pre-sample periods, where \texttt{P} is the order of the
  VAR.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\item
  \texttt{V} {[} VAR {]} - Estimated reduced-form VAR object.
\item
  \texttt{VData} {[} struct {]} - Output database with the endogenous
  variables and the estimated residuals.
\item
  \texttt{Fitted} {[} numeric {]} - Periods in which fitted values have
  been calculated.
\end{itemize}

\paragraph{Options}\label{options}

\begin{itemize}
\item
  \texttt{'A='} {[} numeric \textbar{} \emph{empty} {]} - Restrictions
  on the individual values in the transition matrix, \texttt{A}.
\item
  \texttt{'BVAR='} {[} numeric {]} - Prior dummy observations for
  estimating a BVAR; construct the dummy observations using the one of
  the \texttt{BVAR} functions.
\item
  \texttt{'C='} {[} numeric \textbar{} \emph{empty} {]} - Restrictions
  on the individual values in the constant vector, \texttt{C}.
\item
  \texttt{'J='} {[} numeric \textbar{} \emph{empty} {]} - Restrictions
  on the individual values in the coefficient matrix in front of
  exogenous inputs, \texttt{J}.
\item
  \texttt{'diff='} {[} \texttt{true} \textbar{} \emph{\texttt{false}}
  {]} - Difference the series before estimating the VAR; integrate the
  series back afterwards.
\item
  \texttt{'G='} {[} numeric \textbar{} \emph{empty} {]} - Restrictions
  on the individual values in the coefficient matrix in front of the
  co-integrating vector, \texttt{G}.
\item
  \texttt{'cointeg='} {[} numeric \textbar{} \emph{empty} {]} -
  Co-integrating vectors (in rows) that will be imposed on the estimated
  VAR.
\item
  \texttt{'comment='} {[} char \textbar{} \texttt{Inf} {]} - Assign
  comment to the estimated VAR object; \texttt{Inf} means the existing
  comment will be preserved.
\item
  \texttt{'constraints='} {[} char \textbar{} cellstr {]} - General
  linear constraints on the VAR parameters.
\item
  \texttt{'constant='} {[} \emph{\texttt{true}} \textbar{}
  \texttt{false} {]} - Include a constant vector in the VAR.
\item
  \texttt{'covParam='} {[} \texttt{true} \textbar{}
  \emph{\texttt{false}} {]} - Calculate and store the covariance matrix
  of estimated parameters.
\item
  \texttt{'eqtnByEqtn='} {[} \texttt{true} \textbar{}
  \emph{\texttt{false}} {]} - Estimate the VAR equation by equation.
\item
  \texttt{'maxIter='} {[} numeric \textbar{} \emph{\texttt{1}} {]} -
  Maximum number of iterations when generalised least squares algorithm
  is involved.
\item
  \texttt{'mean='} {[} numeric \textbar{} \emph{empty} {]} - Impose a
  particular asymptotic mean on the VAR process.
\item
  \texttt{'order='} {[} numeric \textbar{} \emph{\texttt{1}} {]} - Order
  of the VAR.
\item
  \texttt{'progress='} {[} \texttt{true} \textbar{}
  \emph{\texttt{false}} {]} - Display progress bar in the command
  window.
\item
  \texttt{'schur='} {[} \emph{\texttt{true}} \textbar{} \texttt{false}
  {]} - Calculate triangular (Schur) representation of the estimated VAR
  straight away.
\item
  \texttt{'stdize='} {[} \texttt{true} \textbar{} \emph{\texttt{false}}
  {]} - Adjust the prior dummy observations by the std dev of the
  observations.
\item
  \texttt{'timeWeights=}' {[} tseries \textbar{} empty {]} - Time series
  of weights applied to individual periods in the estimation range.
\item
  \texttt{'tolerance='} {[} numeric \textbar{} \emph{\texttt{1e-5}} {]}
  - Convergence tolerance when generalised least squares algorithm is
  involved.
\item
  \texttt{'warning='} {[} \emph{\texttt{true}} \textbar{} \texttt{false}
  {]} - Display warnings produced by this function.
\end{itemize}

\paragraph{Options for panel VAR}\label{options-for-panel-var}

\begin{itemize}
\item
  \texttt{'fixedEff='} {[} \texttt{true} \textbar{}
  \emph{\texttt{false}} {]} - Include constant dummies for fixed effect
  in panel estimation; applies only if \texttt{'constant=' true}.
\item
  \texttt{'groupWeights='} {[} numeric \textbar{} \emph{empty} {]} - A
  1-by-NGrp vector of weights applied to groups in panel estimation,
  where NGrp is the number of groups; the weights will be rescaled so as
  to sum up to \texttt{1}.
\end{itemize}

\paragraph{Description}\label{description}

\subparagraph{Estimating a panel VAR}\label{estimating-a-panel-var}

Panel VAR objects are created by calling the function
\href{VAR/VAR}{\texttt{VAR}} with two input arguments: the list of
variables, and the list of group names. To estimate a panel VAR, the
input data, \texttt{Inp}, must be organised a super-database with
sub-databases for each group, and time series for each variables within
each group:

\begin{verbatim}
d.Group1_Name.Var1_Name
d.Group1_Name.Var2_Name
...
d.Group2_Name.Var1_Name
d.Group2_Name.Var2_Name
...
\end{verbatim}

\paragraph{Example}\label{example}


\section{$p$-$n$ Junction in Non-Equilibrium}\label{sec:sec003}
Previously, the $p$-$n$ junction has been discussed when in equilibrium, when $V_a = 0$. However,
when the configuration is no longer in equilibrium, when a bias voltage is applied, the details of the
junction change. Fig. \ref{fig:fig05} shows the energy band diagram of the junction under both
reverse bias ($V_a<0$) and forward bias ($V_a>0$). In each case, there are a number of effects that result.
First, under reverse bias, the built-in potential is effectively increased. In addition, the depletion region width
increases as the depletion region width can be described as
\begin{equation}
    W_{V_a\neq0} = \sqrt{\frac{2\epsilon}{q}\frac{\left(\Phi_0-V_a\right)\left(N_a+N_d\right)}{N_aN_d}}.
\end{equation}
Fig. \ref{fig:fig07} shows the depletion region under reverse bias in which the increase in the
depletion width can be clearly seen. Another effect seen under reverse bias is that the
diffusion of hole in the $n$-type region and diffusion of electrons in the $p$-type region are reduced and the net current,
resulting from the drift of holes from the $n$-type region into the $p$-type region and the drift of electrons
from the $p$-type region into the $n$-type region is observed. Conversely, under forward bias the built-in potential
is effectively reduced and the depletion region is also decreased in width. Also, in contrast with the reverse bias regime,
under forward bias there is increased diffusion current because the potential is reduced so that the electric field and diffusion are
no longer equal and opposite. This is because the diffusion force acting on the carriers is only partially compensated for by the force resulting
from the junction potential variation and therefore, holes can flow from the $p$-type region into the $n$-type semiconductor and electrons can flow
from the $n$-type region into the $p$-type semiconductor.
\begin{figure}[h!]\label{fig:fig05}
    \centering
    \includegraphics[height=3.5cm,width=8.5cm]{figs/bias_pn_junction}
    \caption{Energy band diagram on $p$-$n$ junction at forward and reverse bias.}
\end{figure}

\section{Current-Voltage Characteristics}\label{sec:cv_ideal}
Thus far ideal $p$-$n$ junctions have been discussed and several assumptions have been made to make
this possible. First, an abrupt depletion layer has been assumed. This implies that the built-in potential
and applied voltages are supported by a dipole layer with abrupt boundaries, and outside the boundaries the semicondutor is assumed
to be charge neutral. Second, the Boltzmann approximation has been assumed to be valid. Meaning that the semiconductor
doping level are non-degenerate. If this is not the case then Fermi-Dirac statistics must be employed.
Third, it has been assumed that the injected minority carrier densities are small compared to the major carrier
densities. If this is not the case, then the high-injection regime has been entered. This will be discussed in more detail in the next section.
Lastly, it is assumed that there is no generation or recombination current present inside the depletion layer,
and the electron and hole currents are constant throughout the depletion layer. Taking these four assumptions into
account, then the ideal current-voltage characteristics are presented in fig. \ref{fig:fig07}. Note that the minority carriers
are small compared to the majority carriers on each side. The hole current density $J_p$ is large compared to the electron
carrier density $J_n$ on the $p$-side and the electron carrier density is large compared to the hole carrier density on the $n$-side. In addition,
throughout the depletion region both $J_p$ and $J_n$ are constant in both forward and reverse bias.
\begin{figure}[h!]\label{fig:fig07}
    \centering
    \includegraphics[height=4cm,width=8cm]{figs/schokley_current_reverse_forward}
    \caption{Shockley current density as a function of position within the semiconductor structure at forward and reverse bias.}
\end{figure}

\section{Non-Ideal Current-Voltage Characteristics}
In the previous section the assumptions made for ideal $p$-$n$ junctions was discussed. However,
in reality, $p$-$n$ junctions are from ideal and subject to a number effects in which the aforementioned assumptions
do not hold. Here, two of possible departures will be discussed, as there are many possible effects that could be mentioned, but many
are beyond the scope of this paper. In section \ref{sec:cv_ideal} it was stated that the minority carriers are assumed to be much less than the
majority carriers. First, consider the low-injection regime, where the minority carriers are much less than the majority carriers. In this case
the vast majority of the potential drop occurs across the junction. The hole-concentration in the $n$-side is small compared to the electron concentration
as pictured in the left side of fig. \ref{fig:fig010} and vice versa on the $p$-side. As the high-injection regime approaches, the electron
concentration near the junction increases in order to maintain charge neutrality. If the concentration is increased sufficiently to reach the high-injection regime
as show in the right side of fig. \ref{fig010} then the potential drop across the junction is insignificant compared to the ohmic drops on both sides of the
neutral regions.
\begin{figure}[h!]\label{fig:fig010}
    \centering
    \includegraphics[height=4cm,width=8cm]{figs/high_low_injection}
    \caption{Low and high-injection regimes depicted through carrier densities.}
\end{figure}
Another assumption made in section \ref{sec:cv_ideal} was that generation and recombination does not occur in the depletion
layer. However, in non-ideal cases, this does occur. Whenever the equilibrium condition of a system is disturbed processes exist to restore
the system to equilibrium. When an external bias is applied, the product $pn$ in the transition region is different from the its equilibrium value
$n_i^2$, since carriers are injected into ($V_a>0$) or extracted from ($V_a<0$) the transition region.
To restore equilibrium, generation and recombination occurs inside the junction (recombination occurs when $np > n_i^2$ and generation occurs when $np < n_i^2$).
There are two main mechanisms that can occurs in the depletion layer. First, band-to-band recomnbination. This occurs when an electron
moves from its conduction band state into the empty valence band state associated with its hole. This band-to-band transition is also a radiative transition in direct
bandgap semiconductors. A second mechanism is called Schockley-Read Hall (SRH) recombination, also known as trap-assisted recombination.
This occurs when an electron falls into a trap, an energy level within the bandgap caused by some defect. Once the trap is filled it cannot accept another electron.
The electron occupying the trap, in a second step, moves into an empty valence band state, thereby completing the recombination process. This can be envisioned
as a two-step transition of an electron from the conduction band to the valence band or as the annihilation of the electron and the hole, which meet each other in the trap.
The localized state in the gap in can absorb the difference in momentum between the carriers, and so this process is dominant
in indirect bandgap semiconductors, though it can also dominate in direct bandgap material under condtions of very low
carrier denisities.


\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[colorlinks,linkcolor=red]{hyperref}
\usepackage{graphicx}

\title{
    {Paper Note}\\
    {\large "Model-Agnostic Boundary-Adversarial Sampling for Test-Time Generalization in Few-Shot learning"}
}
\author{Lisen Dai}
\date{Oct 2020}

\begin{document}

\maketitle

\section{General Discription of Few-shot}
Paper link:\href{https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123460579.pdf}{ECCV 2020}
\subsection{Few-shot problem}
Few-shot learning is a general name for tasks in which people hope
to train a machine learning model with just very small amount of data. \newline

\subsection{Previous Research}
1. \textbf{Data augmentation}. Generating fake labaled data. \newline
2. Distance metric methods. \newline
3. Meta-learning methods. \newline

\subsection{Limitations of data augmentation few-shot}
1. Such methods learn to generate additional examples with the
meta-training set, and thus may not be effective if meta-test domains are far from the meta-training domain. \\
2. Since they do not update the trained parameters of the base
classifier models at test time, they have no chance to correct the
errors that exist in the base classifiers (e.g. overfitting of the embedding functions to the meta-training set). \\
3. These methods need to be re-trained for each base classifier
to generate fake labeled data optimal for the base model. \\

\section{Innovative Designs}
A novel model-agnostic sample generation approach named \textbf{MABAS} (Model-Agnostic Boundary-Adversarial Sampling). \\
\subsection{Test-time Fine-tuning of Embedding Functions}
Since each meta-test task consists of the classes that are never seen during metatraining,
it is a common approach in few-shot learning to fine-tuning the learned parameters using the
support samples of the novel task. This work aims at fine-tuning the learned parameters of the
base few-shot learner adaptively to novel tasks but limited to update the parameters of the
embedding function (or the feature extractor).
\subsection{Fine-tuning by Boundary-Adversatial Samples}
Once we have the adversatial samples, we can update the parameter $\phi$ of embedding function via \underline{gradient descent}. The fine-tuning loss $\mathcal{L}^{fine-tune}$ is defined as: \\
$$
\mathcal{L}^{fine-tune}(\mathcal{S}, \phi) := \mathcal{L}^{adv}(\mathcal{S}, \phi) + \eta \cdot \frac{1}{\mathcal{S}}\sum_{(\textbf{x},y)}\in\mathcal{S}{\Vert}f_{\phi}(\textbf{x}){Vert}^2,
$$
and,
$$
\mathcal{L}^{adv}(\mathcal{S}, \phi) =
\frac{1}{\mathcal{S}}
\sum_((\textbf{x}, y) \in \mathcal{S})[
    \frac{1}{K - 1} \sum_{k^{\prime} \neq y}
        \{\alpha_{\textbf{x},y} -
        \min{
            m(\textbf{z}_{y, k^{\prime}}^{adv}, y, k | \psi, \mathcal{S})
            }
        \}_+
    ]
$$
where,
$
\alpha_{\textbf{x}, y} =
\frac{1}{K - 1}
\sum_{k \neq y}
m
(\textbf{z}, y, k
|
\phi,
\mathcal{S}
)
$
\\
feature: not only prevents the exces- sive expansion
of the supports’ embedding space but also stabilizes
the updates of the embedding space.\\
Below is an illustration picture of the MABAS method.\\
\begin{center}
    \includegraphics[scale=0.4]{src/img/MABAS Illustration.jpg}\\
\end{center}

\section{Other Applications of Few-shot}
To show the flexibility and generality of our MABAS approach,
this paper applies it to three representative few-shot learning methods: \\
1. MetaOptNet \\
2. Few-Shot without Forgetting \\
3. Standard Transfer Learning \\

In each method, the paper give out the original equation of implementation
and then the three ways below about how to optimize it by MABAS: \\
1. Boundary-adversarial fine-tuning. \\
2. Variation. \\
3. Setting of $\delta$ \\
And here's an example of \textit{MetaOptNet}: \\
\begin{center}
    \includegraphics[scale=0.6]{src/img/MetaOptNet1.jpg} \\
    \includegraphics[scale=0.6]{src/img/MetaOptNet2.jpg} \\
\end{center}

\section{Experiment}
\subsection{Setup}
    \subsubsection{Dataset}
1. miniImageNet: consists of 100 classes each of which has 600 images with a size of 84 × 84 × 3. It adopts the same class split used by [36, 22]: 64, 16 and 20 classes for training, validation and the test, respectively. \\
2. CIFAR-FS: splits all of the classes in CIFAR100 [20] into 64 training, 16 validation and 20 test sets, respectively. \\
3. FC100: is another CIFAR100-based dataset. Classes are split into 60, 20 and 20 for training, validation and test, respectively. This class split is designed to minimize the overlap of information between all three subsets, to be more challenging than CIFAR-FS for few-shot learning. \\
    \subsubsection{Embedding functions}
ResNet-12, but for STL and MetaOptNet, different average pooling methods are applied in the last residual blocks. \\
    \subsubsection{Meta-training and meta-validation phase}
For MetaOptNet- Proto, it uses a learning decay rate of 0.1 with a decay period of 15 epochs for simplicity. For the STL models, it trains for 100 epochs with a batch size of 256 and a learning rate of 0.001 using the cosine annealing decay. \\
    \subsubsection{Meta-test phase}
5-way 5-shot and 5-way 1-shot classification tasks. Each meta-test run consists of 600 tasks sampled from $D^{test}$, and a single task contains 15 query samples per each of the 5 classes. \\
    \subsubsection{Boundary-adversarial fine-tuning}
In all experiments, they update the embedding function for 150 steps and use the step-based learning rate decay with a decay rate of 0.8 and a period of 5.
\subsection{Result}
\begin{center}
    \includegraphics[scale=0.5]{src/img/Table 1.jpg}
    \includegraphics[scale=0.5]{src/img/Table 234.jpg}
    \clearpage
    \includegraphics[scale=0.6]{src/img/Fig2.jpg}
\end{center}

\end{document}


\chapter{Machine Learning and Image Classification}
\input{BasicML}
\input{ClassificationProblem}

\chapter{Linear Machine Learning Models}
\input{LinearModels}
\input{IntroLR}
\input{KL-CR-LR}
\input{binaryLRSVM}
\input{LR-SVM-Num}
%\section{Finite element discretization for Poisson equation}
\chapter{Convolutional Multigrid Method}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{3FEM/1Dvariational}

%\input{4MSC/smootherproperty}
%\section{Multigrid algorithms}
%\input{4MSC/1Dtwogrid}
%\input{3FEM/1DMG}
%\input{3FEM/1DMGvector}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{multigrid}
\input{6DL/multigrid}
\input{bilinear}
\input{2DFEM}
\input{bilinear_grids}
\input{2d_basis}
\input{XuNet}
\input{FEM-MG-CONV}
%\input{6DL/1D2DFE_MgNet}
%\input{ReLU-multigrid}
\input{NonlinearMG}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{Convolutional Neural Networks}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{NonlinearClassifiable}
\input{ConvolutionalOperator}
\input{convolution-filter}
\input{ClassicCNNs}
\input{CNN-Results}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{MgNet: A Special CNN with MG Structure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{6DL/mgnet}
\input{6DL/mgnet_relation}
\input{ConstrainedLinearModel}
\input{MgNet-Results}

%\iffalse

\chapter{Multigrid method}
%\section{Gradient descent and multigrid method for 1D problem}
\input{4MSC/smootherproperty}
\input{4MSC/1Dtwogrid}
\input{3FEM/1DMG}
%\input{3FEM/1DMGvector}
%\chapter{Multigrid for 2D problem and MgNet}
%\section{Multigrid for 2D Finite Element}
\input{6DL/2DFEM}
\input{6DL/1D2DFE_MgNet}

\chapter{Finite Element and Deep Neural Network Functions}
\input{6DL/FEM2DNN}
\input{6DL/WhyDeep}
\input{6DL/DefineDNN}
\input{3FEM/DNN-FEM}
\chapter{Approximation Properties of DNN}
\input{6DL/PolyWeierstrass}
\input{6DL/DNN_Qualitative0}
\newpage
\input{6DL/MonteCarloBasic}
%\subsection{Stratified Sampling}
%\input{6DL/StratifiedL2}
\newpage
\section{Approximation properties}
\input{6DL/FourierRepresentation}
\input{6DL/Barron-L2}
%\input{6DL/Barron-Hk}
\newpage
%\section{ReLU as activation function}
\input{6DL/ReLUFourierSimple}

%
\newpage
\chapter{CNN and MgNet}
\input{6DL/ShortLRforImages}
\input{6DL/mgnet}
%\fi

\bibliographystyle{abbrv}
\bibliography{ref,ref_mgcnn,../3FEM/3FEM}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{3FEM/1DMGvector}
\input{multigrid}
\input{2DFEM}
\input{XuNet}
\input{FEM-MG-CONV}
\input{ReLU-multigrid}
\input{NonlinearMG}

\chapter{MgNet: a Unified Framework for CNN and MG}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{NonlinearMG}
\input{6DL/mgnet}
\input{6DL/mgnet_relation}

\end{document}

%\break
\chapter{Machine Learning and Image Classification}
\input{BasicML}
\input{ClassificationProblem}

\chapter{Linear Machine Learning Models}
%%%%%%%%%%%%%%%%%%%%%
%%%LR and SVM%%%%%%
\input{LinearModels}
\input{IntroLR}
\input{KL-CR-LR}
%\input{DL-LRSVM-2}
\input{binaryLRSVM}
\input{DL-GD}
%%%%%%%%%%%%%%%%%%%%%

\chapter{Probability and Training Algorithms}
%%%%%%%%%%%%%%%%%%%%%
%%%Probability related topics%%%%%%
\input{probability_intro}
\input{BasicProb}
\input{DL-LR-Prob}
%\input{MLTheory}
\input{DL-GD-Convergence}
\input{ChSGD}
%\input{momentum}
%\input{pytorch-momentum}

\chapter{Nonlinear Models}
\input{NonlinearClassifiable}
%\input{ProbNonlinear}

\chapter{Polynomials, Finite Element and Neural Network Functions}
\input{PolyWeierstrass}
\input{3FEM/FEspaces}
\input{3FEM/Nodal-Interpolation}
\input{FEM2DNN}
\input{WhyDeep}
\input{DefineDNN}
\input{DNN_Qualitative}

\chapter{Convolutional Neural Networks}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{ConvolutionalOperator}
\input{convolution-filter}
\input{ClassicCNNs}
\includepdf[pages=-,pagecommand={}]{497/handwritten_notes/MultidimensionalVariance.pdf}
\input{initialization}
\input{BN}
\input{StatsNormalization}
\input{ImageNormalization}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{Finite Element Method and Multigrid method in Convolution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{3FEM/1Dvariational}
\input{4MSC/smootherproperty}
\input{4MSC/1Dtwogrid}
\input{3FEM/1DMG}
\input{multigrid}
\input{2DFEM}
\input{XuNet}
\input{FEM-MG-CONV}
\input{ReLU-multigrid}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{MgNet: a Unified Framework for CNN and MG}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{mgnet}
\input{mgnet_summary}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\bibliographystyle{abbrv}\bibliography{ref,ref_mgcnn,../3FEM/3FEM}

\end{document}

\chapter{ Polynomials, Finite Element and Neural Network Functions}
%%%%%%%%%%%%%%%%%%%%%
%%%DNN and Approximation%%%%%%

\input{NonlinearClassifiable}

\input{PolyWeierstrass}

\input{3FEM/FEspaces}
\input{3FEM/Nodal-Interpolation}

\input{4MSC/smootherproperty}
\input{4MSC/1Dtwogrid}

\input{3FEM/1DMG}
%\input{MG-Recursion}

\input{FEM2DNN}
\input{WhyDeep}
\input{DefineDNN}

\input{DNN_Qualitative}

%\chapter{An Introduction to Multigrid Methods}
%%%%%%%%%%%%%%%MG%%%%%%%%%%%%%%%%%
%\input{6DL/multigrid}
%\input{6DL/FEM-MG-CONV}
%\input{6DL/ReLU-multigrid}

\bibliographystyle{abbrv}\bibliography{ref,ref_mgcnn,../3FEM/3FEM}

\end{document}

%\chapter{Basic Machine Learning: Support Vector Machine}
%%%%%%%%%%%%%%%%%%%%%%
%%%%LR and SVM%%%%%%
%\input{DL-SVM-2}
%\input{DL-LRSVM-2}
%%%%%%%%%%%%%%%%%%%%%%

\chapter{Topics Related to Probability}
%%%%%%%%%%%%%%%%%%%%%
%%%Training algorithms%%%%%%
\input{BasicProb}
\input{DL-LR-Prob}
\input{MLTheory}
%\input{}

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

\chapter{ Polynomials, Finite Element and Neural Network Functions}
%%%%%%%%%%%%%%%%%%%%%
%%%DNN and Approximation%%%%%%
\input{6DL/PolyWeierstrass}
\input{6DL/FEM2DNN}
\input{6DL/DNN_Qualitative}
%\input{6DL/SampleLemma}
%\input{6DL/Representations}
%\input{6DL/Barron-L2}
%\input{6DL/Barron-Hk}
%%%%%%%%%%%%%%%%%%%%%

\chapter{Deep Neural Networks and Mathematical Properties}
\input{6DL/WhyDeep}

%%%%%%%%%%%%%%%%%%%CNN%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Convolutional Neural Networks}
%%%%%%%%%%%%%%Qingguo%%%%%%%%%%%%%%%%%
\input{Initialization}
\input{BN}
%\chapter{Supplemental Material: Convolution Filters}
%%%%%%%%%%%%%%Juncai%%%%%%%%%%%%%%%%%%%
%\input{convolution-filter}

%%%%%%%%%%%%%%%%%%%CNN%%%%%%%%%%%%%%%%%%%%%%%
\chapter{An Introduction to Multigrid Methods}
%%%%%%%%%%%%%%MG%%%%%%%%%%%%%%%%%
\input{6DL/multigrid}
\input{6DL/FEM-MG-CONV}
%\input{6DL/ReLU-multigrid}

\chapter{MgNet: a Unified Framework for CNN and MG}
%%%%%%%%%%%%%Juncai and Qingguo%%%%%%%%%%%%%%%%%%%
\input{mgnet}
\input{mgnet_summary}

%\chapter{More Knowledge of Training Neural Networks}
%%%%%%%%%%%%%Juncai and Qingguo%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

\bibliographystyle{abbrv}
\bibliography{ref,ref_mgcnn,../3FEM/3FEM}


% ----------------------------------------------------------------
% Article Class (This is a LaTeX2e document)  ********************
% ----------------------------------------------------------------
\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm, amssymb}
\usepackage{amsfonts}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{enumerate}
\usepackage[utf8]{inputenc}
\usepackage{multicol}

%Candelaria's favorite packages
\usepackage{setspace}	% Set the spacing for the document
\usepackage{xtab}		% Use for tables
\usepackage{comment}	% Use for block comments
\usepackage{rotating}	% Helpful for rotating figures
\usepackage{lscape}	% Change a page into landscape
\usepackage{hyperref}
\hypersetup{colorlinks=false,pdfborder={0 0 0},breaklinks=true}
\usepackage{graphicx}	% Load a graphic image
%\usepackage{url}		% Use for formatting URLS (nice for NatBib also)
\usepackage{booktabs}  	% Use for nice tables/ Works well with ESTOUT
\usepackage{longtable} 	% Used to break long tables over multiple pages
\usepackage{caption}
\usepackage{subcaption} 	% Used to create SubFloats
\usepackage{listings} 	% Use to enter code blocks, like a fancy verbatim

% ADD COLOR:
\usepackage{color}
\usepackage[usenames, dvipsnames, svgnames, table]{xcolor}

% Packages for the bibliography
\usepackage[longnamesfirst]{natbib}
%\usepackage{natbib}

% Set Page Margins
%\usepackage{fullpage}
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}

% Set line and table spacing
\renewcommand{\baselinestretch}{1.0}
\renewcommand{\arraystretch}{1.1}
\setlength\abovedisplayskip{0pt}
\setlength\belowdisplayskip{0pt}

% Redefine the cite command
\renewcommand\cite{\citet}

%\setlength{\parindent}{0in}

%\setlength{\leftmargin}{0pt} \setlength{\parskip}{1.1ex} \setlength{\parindent}{1em} \setlength{\itemsep}{0pt} \setlength{\footnotesep}{10pt}
%\renewcommand{\footnoterule}{\rule{3in}{.3pt}\vspace{-.3pt}}

% THEOREMS -------------------------------------------------------
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\theoremstyle{remark}
\newtheorem{rem}[thm]{Remark}
%\numberwithin{equation}{section} %Number equations within section
% ----------------------------------------------------------------

% AUTHOR INFO

\title{Problem Set 7\\ Due: TBD}%

% ----------------------------------------------------------------

%%%%%%
% SHORT CITES
%%%%%%
\shortcites{ColEtAl1966}

\begin{document}

\begin{center}
{\huge Problem Set 3: Linear Algebra}\\[5pt]
Due: September 6, 2019
\end{center}

\section*{Problem 1}
Write each of the following systems of equations as an augmented matrix and a matrix equation.
\begin{enumerate}
\item
$
-x_1 + x_2 = 4 \\
4x_1 + 3x_2 = -9
$

\item
$
x_1 + x_2 + x_3 = 6 \\
2x_2 + 5x_3 = -4 \\
2x_1 + 5x_2 -x_3 = 27 \\
$

\item
$
x_1 + x_2 + x_3 + x_4 = 9 \\
-3x_1 + 7x_2 + 2x_3 + 4x_4 = 27 \\
3x_2 - 4x_3 + 2x_4 = 10 \\
8x_1 - 6x_2 - x_4 = 1 \\
$

\end{enumerate}

\section*{Problem 2}
Solve the systems of equations in 1 and 2 from Problem 1 using row operations on the augmented matrices you wrote.

\section*{Bonus}
Solve the system of equations in 3 from Problem 1 using row operations on the augmented matrix you wrote.

\end{document}


%!TEX root = fastZKP.tex

\subsection{Zero-Knowledge Verifiable Polynomial Delegation Scheme}
\label{subsec::zkvpd}

Let $\mathbb{F}$ be a finite field, $\mathcal{F}$ be a family of $\ell$-variate polynomial over $\mathbb{F}$, and $d$ be a variable-degree parameter \babis{this ``variable-degree" comes up all the time and you have not defined it. can you please define it?}\yupeng{defined at the beginning of section 2}. A zero-knowledge verifiable polynomial delegation scheme (zkVPD) for $f\in\mathcal{F}$ and $t\in\F^\ell$ consists of the following algorithms:
\begin{itemize}
    \item $(\pp, \vp) \leftarrow \KeyGen(1^\lambda, \ell, d)$,
    \item $\comm \leftarrow \Commit(f, r_f, \pp)$,
    \item $\{\accept,\reject\}\leftarrow\CheckComm(\comm, \vp)$,
    \item $(y,\pi)\leftarrow\Open(f,t,r_f,\pp)$,
    \item $\{\accept,\reject\}\leftarrow\Verify(\comm,t,y,\pi,\vp)$.
\end{itemize}
%\dawn{we should mention $f \in \mathcal{F}$, and $t\in \mathbb{F}$, right?}
A zkVPD scheme satisfies correctness, soundness and zero knowledge, which we formally define below.

\begin{definition}\label{def::zkvpd}
	Let $\mathbb{F}$ be a finite field, $\mathcal{F}$ be a family of $\ell$-variate polynomial over $\mathbb{F}$, and $d$ be a variable-degree parameter. A zero-knowledge verifiable polynomial delegation scheme (zkVPD) consists of the following algorithms: $(\pp, \vp) \leftarrow \KeyGen(1^\lambda, \ell, d)$, $\comm \leftarrow \Commit(f, r_f, \pp)$, $\{\accept,\reject\}\leftarrow\CheckComm(\comm, \vp)$, $(y,\pi)\leftarrow\Open(f,t,r_f,\pp)$, $\{\accept,\reject\}\leftarrow\Verify(\comm,t,y,\pi,\vp)$, such that

	\begin{itemize}
		\item \textbf{Perfect Completeness}
		For any polynomial $f \in \mathcal{F}$ and value $t$, the following probability is 1.
		\[\Pr_{r_f}\left[
		\begin{aligned}
		(\pp, \vp) \leftarrow \KeyGen(1^\lambda, \ell, d) && \\
		\comm \leftarrow \Commit(f, r_f, \pp) &:&  \CheckComm(\comm, \vp)=\accept \hspace*{5pt}\land \\
		(y, \pi) \leftarrow \Open(f, t, r_f, \pp) && \hspace*{10pt}\Verify(\comm, t, y, \pi, \vp)=\accept\\
		\end{aligned}
		\right]\]
		\item \textbf{Binding}
		For any PPT adversary $\mathcal{A}$ and benign auxiliary input $z_1, z_2$ the following probability is negligible of $\lambda$:
		{\footnotesize
			\[\Pr \left[
			\begin{aligned}
			(\pp, \vp) \leftarrow \KeyGen(1^\lambda, \ell, d) && \CheckComm(\comm^*, \vp)=\accept \hspace*{5pt}\land\\
			(\pi^*, \comm^*, y^*, state) \leftarrow \mathcal{A}(1^\lambda, z_1, \pp) &:& \Verify(\comm^*, t^*, y^*, \pi^*, \vp)=\accept \hspace*{5pt} \land\\
			(f^*, t^*, r_f^*) \leftarrow \mathcal{A}(1^\lambda, z_2, state, \pp) && \comm^*=\Commit(f^*, r_f^*, \pp) \hspace*{5pt} \land\\
			&& (y^*, \pi^*) = \Open(f^*, t^*, r_f^*, \pp) \hspace*{5pt} \land \\
			&& f^*(t^*) \neq y^*\\
			\end{aligned}
			\right]\]
		}
		\item \textbf{Zero Knowledge} For security parameter $\lambda$, polynomial $f$, adversary $\mathcal{A}$, and simulator $\S$, consider the following two experiments:
		{\footnotesize
			\begin{align*}
			\begin{minipage}{.48\linewidth}
			$\mathsf{Real}_{\A, f}(1^\lambda)$:
			\begin{enumerate}
			\item $(\pp, \vp) \leftarrow \KeyGen(1^\lambda, \ell, d)$
			%\item \text{Generate $r_f$ uniformly at random}
			\item $\comm \leftarrow \Commit(f, r_f, \pp)$
			\item $k\leftarrow \mathcal{A}(1^\lambda, \comm, \vp)$
			\item \text{For $i=1,...,k$ repeat}
			\begin{enumerate}
			\item $t_i \leftarrow \A(1^\lambda, \comm, y_1,...,y_{i-1}, \pi_1,\\ ..., \pi_{i-1}, \vp)$
			\item $(y_i, \pi_i) \leftarrow \Open(f, t_i, r_f, \pp)$
			\end{enumerate}
			\item $b \leftarrow \A(1^\lambda, \comm, (y_1, ..., y_k, \pi_1, ..., \pi_k), \vp)$
			\item \text{Output b}
			\end{enumerate}
			\end{minipage}
			\hspace*{5pt}\vline \hspace*{5pt}
			%\vline
			\begin{minipage}{.48\linewidth}
			$\mathsf{Ideal}_{\A, \S}(1^\lambda)$:
			\begin{enumerate}
			\item $(\comm, \pp, \vp, \sigma) \leftarrow \mathsf{Sim}(1^\lambda, \ell, d)$
			\item $k \leftarrow \A(1^\lambda, \comm, \vp)$
			\item \text{For $i=1,...,k$ repeat}:
			\begin{enumerate}
			\item $t_i \leftarrow \A(1^\lambda, \comm, y_1, ..., y_{i-1}, \pi_1,\\ ..., \pi_{i-1}, \vp)$
			\item $(y_i, \pi_i, \sigma) \leftarrow \mathsf{Sim}(t_i, \sigma, \pp)$
			\end{enumerate}
			\item $b \leftarrow \A(1^\lambda, \comm, (y_1, ..., y_k, \pi_1, ..., \pi_k), \vp)$
			\item \text{Output b}
			\end{enumerate}
			\end{minipage}
			\end{align*}
		}
		For any PPT adversary $\A$ and all polynomial $f\in\F$, there exists simulator $\S$ such that
		\[
		|\Pr[\mathsf{Real}_{\A, f}(1^\lambda)=1] - \Pr[\mathsf{Ideal}_{\A, \S}(1^\lambda)=1]|\le \negl(\lambda).
		\]
	\end{itemize}

\end{definition}

\ignore{
	Zero-knowledge Verifiable Polynomial Delegation Commitment Scheme (Zk-VPD for short) is a important building block for our zero knowledge construction. We will use the construction from Zhang et al. \cite{zkvpd}.

	\subsubsection{Scheme Description}

	\begin{theorem}

		Zhang et al.'s construction \cite{zkvpd} is a zero knowledge ex-tractable verifiable polynomial-delegation protocol. For a variable-degree-$d$ $l$-variate polynomial $f \in \mathcal{F}$ with $m$ monomials, algorithm \textnormal{KeyGen} runs in time $O(\binom{ld+l}{ld})$, \textnormal{CommitPoly} in time $O(m)$, \textnormal{CommitValue} in time $O(ldm)$, \textnormal{Ver} in time $O(l)$ and \textnormal{CheckCom} in time $O(1)$. The commitment produced by \textnormal{CommitPoly} consists of $O(1)$ group elements and the proof produced by \textnormal{CommitPoly} consists of $O(l)$ group elements.
	\end{theorem}
}


\label{sec:conclusions}

%
% be sure to mention that this thesis is a success of CFD/CAD
% computational optimization and computational design
%

%
% bob mentioned today that one should considered feasibility in the
% context of just technological scaling, no cost.
%

\section{Summary of the Present Work}

%
% be sure to hedge bet as technological feasibility is limited to just
% tech, not finance
%

%
% weave every story together--
%
%     1) results are not promising
%     2) be sure to talk about new models contributions and possible
%     applications
%

Observed velocities indicates that naturally occurring dust devils
contain a considerable amount of energy, from the gravitational
potential energy contained in air near the hot surface of the Earth
and ambient winds. While rudimentary proof-of-concept devices have shown
that artificial dust devils can be created and
anchored in place by turning vanes, no previous studies have attempted
to methodically explore how best to intensify the produced vortex,
and yield a stronger and more powerful dust devil.

This thesis has developed and validated computational models that have
subsequently
explored a broad configuration space of turning vanes to estimate
how much power might be produced by one of these synthetic dust devils.
The purpose behind this is to provide an assessment of the technological
feasibility of the entire synthetic columnar vortex concept as a means
of generating renewable energy.

Such a system had never been simulated previously. Developing
simulations capable of modeling the SoV apparatus and for the scenarios
of interest therefore required the development of new models and
software capabilities. This required the development and implementation
of mathematical models for the turbulent diffusivities in the ambient
conditions, and the representation of the SoV vanes, cone and
turbine. The latter required the development of a novel representation
of the SoV system geometry that is sufficiently flexible to permit
cost-effective iteration in designs. These virtual vanes were
further extended to include both a separation model and a modification
to account for the drag due to skin friction along the surface.
In addition, a modification to the actuator-disk model to account
for the observed impact of the turbine blade solidity was developed.

The ultimate simulation capability was a complicated coupled system that
accounted for buoyancy effects, ambient winds and a wide variety of
turning vane and turbine geometries. These simulations were validated
across a range of conditions and system configurations and were largely
consistent with available experimental data and
observations. Furthermore, a steady state simulation was validated
against unsteady simulations, which permitted computationally
inexpensive explorations of the design space.

%In doing so, we
%have discussed the physics that influence dust devils formation, our
% We summarized the
%numerical discretizations used, the software stack and the calibration,
%verification and validation of these components. The purpose of these
%sections was to communicate two major points.
%The first is that an
%accurate, verified and validated simulation capability has been
%developed that can quickly investigate a wide variety of system and
%scenario settings at a modest computational cost.

% keep?
%The second point is
%that we have developed heuristics that permit optimization of any
%baseline SoV configuration to a local maximum of energy production, as
%measured by kinetic energy flux through the top of the SoV vanes.

These capabilities supported the principle objective of this work, which
was to explore a large space of possible system configurations and
geometries to discover mechanisms that intensify the vortex velocities
and the power extracted by the turbine. These simulations indicated that
the synthetic flow generated by the SoV do indeed have a dust
devil-like character. The flow is buoyancy driven, with a coherent
thermal plume corresponding to a region of intense vertical and
azimuthal velocity. These flows are consistent with the Rankine
vortex model, which has generally been found to be an accurate
representation of the velocities in the naturally occurring phenomenon.

A contribution of this work is in indicating the role of
ambient winds are more substantial than previously indicated. The wind
provides a significant contribution of kinetic energy to the flow, but it
also changes the structure of the vortex. The expectation that the more
powerful naturally occurring dust devils are similarly driven by substantial
winds also implies that the structure of dust devils may be more
asymmetric than previously realized.

%Coupled with the scaling analysis presented in
%Chapter~\ref{sec:physics}, we are now able to predict the conditions (if
%any) under which the SoV apparatus will be technologically competitive
%with other sources of renewable energy.
%This has also permitted investigating the physics of the apparatus, to
%assess how closely the synthetic dust devils mimic the natural
%variety.

%
% probably dont want this...
%
\section{System Feasibility Assessment}

The results of the simulations indicate that over tens of square meters,
several kilowatts of energy can be produced. These results are not
promising with regards to the competitiveness of the power generated by
the device. For comparison, a photovoltaic array typically converts
the peak solar insolation of $\approx 1000 \text{ W}/\text{m}^2$ at an efficiency
of approximately 15\%. Thus, the power generated by a solar array with
an area comparable to the six meter inner diameter of the turning
vanes for the 2016 SoV field test would be substantially larger than
the estimated power predicted in the simulations
(4 kW for the PV vs. 2 kW from the SoV).

In addition to this unpromising result, two major additional risks
exist that likely limit the expected utility of the SoV paradigm.
The first is that at this time no experimental validation accompanies the
computational results, and it is conceivable that the apparatus will not
perform as well as predicted by simulation.

Furthermore, the simulations indicated that the synthetic dust devils
are fragile, and
the kinetic energy flux in the plume is highly sensitive to ambient
conditions and the complex interplay between the ambient winds and the
thermal buoyancy effects. In some cases, small perturbations to the
system parameters such as the turbine blade number or the turning vane
angles would result in orders of magnitude weaker vortices.
This indicates that any energy generation system that uses dust
devils may not be a reliable and regular means of energy generation.
It is interesting to note that this may indicate that the
naturally occurring dust devils,
while pervasive, are not robust, and that individual whirlwinds are
easily dissipated when interfered with.

However, it must also be emphasized that feasibility is focused on
technical viability, namely energy produced by the apparatus, and does
not include an economic assessment. The SoV is almost certainly cheaper
to fabricate and install than competing renewable technologies such as
photovoltaics or wind turbines. Thus, while simulations indicate that
the SoV lags these technologies in terms of power production, it may be
more competitive on a dollar per watt basis. Economic considerations
such as these are not considered in this work.

%In other words, it is currently believed that
%that the SoV does produce usable energy,
%but the design required to do could be prohibitively expensive, and
%therefore not economically competitive with existing technologies.

% is this too hokey?
%In essence, our calculus is,
%\begin{equation}
% = \frac{\text{Energy}}{\text{meter}^2} * \text{ efficiency (\%) } *
%  \text{meter}^2
%\end{equation}
%Where the peak energy per meter squared is detailed in Section~\ref{},
%and the efficiency estimated in Section\ref{sec:peak_estimate}.

%A pertinent question is how does this compare to existing technologies,
%when evaluated from a similar standpoint?

One outstanding question is: why do the synthetic dust devils generated by
the SoV possess substantially reduced velocities versus the naturally
occurring phenomenon. The scaling of the velocity of these objects with
respect to the diameter of the apparatus is not known, and it is
possible that the larger diameters of the naturally occurring dust
devils also corresponds to intensified velocities. Alternatively,
the solidity or blockage of the device in the vanes and turbine was
found to be a significant limit to the power produced. As the natural
variety do not have control surfaces that also serve to block the flow,
these vortices may have larger mass flow rates and consequently,
kinetic energy fluxes.

\section{Conclusions and Future Work}

Despite the considerable simulation campaign, the SoV extracts
considerably less energy than other renewable technologies. It is
therefore unlikely that the SoV technology is competitive versus
presently existing approaches. It is possible that the technology could
be useful in radically different scenarios, such as harvesting waste
industrial heat, where the ambient conditions and scales would so differ
from those considered in this work that further investigation would be
necessary.

Another possible venue of research would be a marked departure from the
two tier vane paradigm in this work. For instance, dynamically
adjustable vanes might be capable of harmoniously "building up" the
vortex. Or, additional turning tiers might be necessary to provide a
more continuous entrainment region.
However, these concepts would certainly require a much more expensive
design configuration and the simulations presented in this work do not
clearly indicate a promising path of investigation.

While the technological feasibility of the SoV is questionable,
the enabling models and simulation capabilities developed in the course
of this investigation have independent value. The turning vane
formulation is a useful tool where explicitly meshing surfaces is
prohibitively expensive or difficult, and at least for the conditions
present in this work, the resulting simulations with the virtual vanes
were a useful design tool. Broadly speaking, the optimization heuristics
and steady models used to explore the turning vane and turbine
configuration were powerful tools, and could be much more broadly
applied for optimization and design in many other systems.

%Turbine solidity implications

Finally, dust devils remain a relatively poorly understood phenomenon,
in part due to the lack of simulation data that permits detailed
investigations of the underlying fluid-dynamical structure of these
objects. The simulations here have generated dust devil-like structures
that could be used as a research tool to further investigate the physics
of dust devils and cyclonic phenomenon in general.

%\todo{add note that mentions how the formulation of an optimization
%heuristic is also a worthy contribution}

% \subsection{Additional Investigations}

% %
% % control for inter unit spacing
% %
%In addition to the system configuration, it would be interest to
%consider the effect of local conditions on SoV
%performance. Characterizing the impact of variations in ambient
%conditions on the SoV\todo{finish me}

% will guide the commercialization strategy of the
% product, by determining optimal install locations across the country. It
% is therefore desirable to have models that are capable of accounting for
% variation in field conditions, such as solar input, cross-winds and
% topography. Furthermore, it is expected that large ``farms'' of SoVs
% (akin to the wind and solar farms for wind turbines and photovoltaics,
% respectively) may be used by commercial or utility-scale energy
% generation. For this to be effective,  the inter-unit spacing must also
% be optimized, as a single SoV collects from a large area. These
% computations will guide commercialization planning, where
% decision-makers will need to assess optimum unit size, spacing, and
% geographic location for utility-scale deployment.


\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage[landscape]{geometry}

% To make this come out properly in landscape mode, do one of the following
% 1.
%  pdflatex latexsheet.tex
%
% 2.
%  latex latexsheet.tex
%  dvips -P pdf  -t landscape latexsheet.dvi
%  ps2pdf latexsheet.ps

% If you're reading this, be prepared for confusion.  Making this was
% a learning experience for me, and it shows.  Much of the placement
% was hacked in; if you make it better, let me know...

% 2008-04
% Changed page margin code to use the geometry package. Also added code for
% conditional page margins, depending on paper size. Thanks to Uwe Ziegenhagen
% for the suggestions.

% 2006-08
% Made changes based on suggestions from Gene Cooperman. <gene at ccs.neu.edu>

% To Do:
% \listoffigures \listoftables
% \setcounter{secnumdepth}{0}

% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
	{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
	{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
		{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
		{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
	}

% Turn off header and footer
\pagestyle{empty}

% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
                                {-1ex plus -.5ex minus -.2ex}%
                                {0.5ex plus .2ex}%x
                                {\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
                                {-1explus -.5ex minus -.2ex}%
                                {0.5ex plus .2ex}%
                                {\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
                                {-1ex plus -.5ex minus -.2ex}%
                                {1ex plus .2ex}%
                                {\normalfont\small\bfseries}}
\makeatother

% Define BibTeX command
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

% Don't print section numbers
\setcounter{secnumdepth}{0}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}

% -----------------------------------------------------------------------
   \newcommand{\tab}{\hspace*{2em}}

\begin{document}

\raggedright
\footnotesize
\begin{multicols}{3}

% multicol parameters
% These lengths are set only within the two main columns
%\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}

\begin{center}
     \Large{\textbf{Combinatoric CheatSheet \\ SymPy.org}} \\
\end{center}
\section{Partition}
\verb!Path: from sympy.combinatorics.partitions!\\
\subsection{Methods}
\verb!random_integer_partition(n, seed=None)! \\
Generates a random integer partition summing to n as a list of reverse-sorted integers

\verb!RGS_generalized(m)! \\
Computes the \verb!m + 1! generalized unrestricted growth strings and returns them as rows in matrix

\verb!RGS_enum(m)! \\
computes the total number of restricted growth
 strings possible for a superset of size \verb!m!

\verb!RGS_unrank(rank, m)! \\
Gives the unranked restricted growth string for a given superset size

\verb!RGS_rank(rgs)! \\
Computes the rank of a restricted growth string.

\subsection{Subclass \texttt{Partition}}
A partition is a set of disjoint sets whose union equals a given set.
This Class represent abstract partition.

\begin{tabular}{@{}lp{4.5cm}l@{}}
\verb!rgs!    & Restricted Growth String\\
\verb!from_rgs(rgs,elements)!  & Creates a set partition from a RSG\\
\verb!rank! & Gets the rank of a partition \\
\verb!partition!  & Return partition as a sorted list of lists\\
\verb!sort_key(order=None)!  & Return a canonical key that can be used for sorting.
\end{tabular}

%dump : \\
%Used at the very beginning of a document:
%\verb!\documentclass{!\textit{class}\verb!}!.  Use
%\verb!\begin{document}! to start contents and \verb!\end{document}! to
%end the document.
%\\end dump.

\subsection{Subclass \texttt{IntegerPartition}}
This class represents an integer partition.
\newlength{\MyLen}
\settowidth{\MyLen}{\texttt{letterpaper}/\texttt{a4paper} \ }
\begin{tabular}{@{}p{\the\MyLen}%
                @{}p{\linewidth-\the\MyLen}@{}}
\verb!as_dict()! & Return the partition as a dictionary whose keys are the
				partition integers and the values are the multiplicity of that integer \\
\verb!as_ferrers(char='#')! & Prints the ferrer diagram of a partition\\
\verb!conjugate! &Computes the conjugate partition of itself\\
\verb!next_lex()! & Return the next partition of the integer, n, in lexical order\\
\verb!prev_lex()! & Return the previous partition of the integer, n, in lexical order\\
\end{tabular}

\section{Permutation}
Path \verb!sympy.combinatorics.permutations.Permutation!\\
\subsection{Methods}
\verb!array_form! \\
This is used to convert from cyclic notation to the canonical notation

\verb!ascents()!\\
Returns the positions of ascents in a permutation, i.e., the location where $p[i] < p[i+1]$

\verb!descents()!
Returns the positions of descents in a permutation, i.e., the location where $p[i] > p[i+1]$

\verb!atoms()!\\
Returns all the elements of a permutation

\verb!cardinality!\\
Returns the number of all possible permutations.

\verb!commutator(x)!\\
Return the commutator of self and x: \verb!~x*~self*x*self!

\verb!commutes_with(other)!\\
Checks if the elements are commuting.

\verb!cycle_structure!\\
Return the cycle structure of the permutation as a dictionary indicating the multiplicity of each cycle length.

\verb!cycles! \\
Returns the number of cycles contained in the permutation (including singletons).

\verb!cyclic_form!\\
This is used to convert to the cyclic notation from the canonical notation. Singletons are omitted.

\verb!from_inversion_vector(inversion)!\\
Calculates the permutation from the inversion vector.

\verb!from_sequence(i, key=None)!\\
Return the permutation needed to obtain \verb!i! from the sorted elements of \verb!i!.
If custom sorting is desired, a key can be given.

\verb!full_cyclic_form!\\
Return permutation in cyclic form including singletons.

\verb!get_adjacency_distance(other)!\\
Computes the adjacency distance between two permutations.

\verb!get_adjacency_matrix()!\\
Computes the adjacency matrix of a permutation.

\verb!get_positional_distance(other)!\\
Computes the positional distance between two permutations.

\verb!get_precedence_distance(other)!\\
Computes the precedence distance between two permutations.

\verb!get_precedence_matrix()!\\
Gets the precedence matrix. This is used for computing the distance between two permutations.

\verb!index()!\\
Returns the index of a permutation.

\verb!inversion_vector()!\\
Return the inversion vector of the permutation.

\verb!inversions()!\\
Computes the number of inversions of a permutation.

\verb!is_Empty!\\
Checks to see if the permutation is a set with zero elements

\verb!is_Identity!\\
Returns True if the Permutation is an identity permutation.

\verb!is_Singleton!\\
Checks to see if the permutation contains only one number and
 is thus the only possible permutation of this set of numbers.

 \verb!is_even!\\
Checks if a permutation is even.

\verb!is_odd!\\
Checks if a permutation is odd.

\verb!josephus(m, n, s=1)!\\
Return as a permutation the shuffling of range(\verb!n!) using the Josephus scheme
in which every \verb!m!-th item is selected until all have been chosen.

\verb!length()!\\
Returns the number of integers moved by a permutation.

\verb!list(size=None)!\\
Return the permutation as an explicit list

\verb!max()!\\
The maximum element moved by the permutation.

\verb!min()!\\
The minimum element moved by the permutation

\verb!next_lex()!\\
Returns the next permutation in lexicographical order.

\verb!next_nonlex()!\\
Returns the next permutation in nonlex order.

\verb!next_trotterjohnson()!\\
Returns the next permutation in Trotter-Johnson order.

\verb!order()!\\
Computes the order of a permutation.

\verb!parity()!\\
Computes the parity of a permutation.

\verb!random(n)!\\
Generates a random permutation of length \verb!n!.

\verb!rank(i=None)!\\
Returns the lexicographic rank of the permutation
(default) or the \verb!i!th ranked permutation of self.

\verb!rank_nonlex(inv_perm=None)!\\
This is a linear time ranking algorithm
that does not enforce lexicographic order.

\verb!rank_trotterjohnson()!\\
Returns the Trotter Johnson rank, which we get from the minimal change algorithm.

\verb!static rmul(*args)!\\
Return product of Permutations $[a, b, c, \ldots]$ as the Permutation whose $i$th value is $a(b(c(i)))$.

\verb!runs()!\\
Returns the runs of a permutation.

\verb!signature()!\\
Gives the signature of the permutation needed to place the elements
 of the permutation in canonical order.

\verb!size!\\
Returns the number of elements in the permutation.

\verb!support()!\\
Return the elements in permutation, $P$, for which $P[i] \neq i$.

\verb!transpositions()!\\
Return the permutation decomposed into a list of transpositions.

\verb!unrank_lex(size, rank)!\\
Lexicographic permutation unranking.

\verb!unrank_nonlex(n, r)!\\
This is a linear time unranking algorithm that does not respect lexicographic order.

\verb!unrank_trotterjohnson(size, rank)!\\
Trotter Johnson permutation unranking.

\subsection{Subclass \texttt{Cycle(*args)}}
Wrapper around dict which provides the functionality of a disjoint cycle.

\subsection{Subclass \texttt{Generators}}

\verb!symmetric(n)!\\
Generates the symmetric group of order \verb!n!, \verb!Sn!.

\verb!cyclic(n)!\\
Generates the cyclic group of order \verb!n, Cn!.

\verb!alternating(n)!\\
Generates the alternating group of order \verb!n, An!

\verb!dihedral(n)!\\
Generates the dihedral group of order \verb!2n, Dn!.

\section{PermutationGroup}
Path : \verb!sympy.combinatorics.perm_groups.PermutationGroup!

\subsection{Methods}
\verb!base!\\
Return a base from the Schreier-Sims algorithm.

\verb!baseswap(base, strong_gens, pos, randomized=False,!\\
\verb!transversals=None, basic_orbits=None,! \\
\verb!strong_gens_distr=None)!\\
Swap two consecutive base points in base and strong generating set.

\verb!basic_orbits!\\
Return the basic orbits relative to a base and strong generating set.

\verb!basic_stabilizers!\\
Return a chain of stabilizers relative to a base and strong generating set.

\verb!basic_transversals!\\
Return basic transversals relative to a base and strong generating set.

\verb!center()!\\
Return the center of a permutation group.

\verb!centralizer(other)!\\
Return the centralizer of a group/set/element.

\verb!commutator(G, H)!\\
Return the commutator of two subgroups.

\verb!contains(g, strict=True)!\\
Test if permutation \verb!g! belong to self.

\verb!coset_factor(g, af=False)!\\
Return G's (self's) coset factorization, \verb!f,! of \verb!g!.

\verb!coset_rank(g)!\\
rank using Schreier-Sims representation

\verb!coset_unrank(rank, af=False)!\\
unrank using Schreier-Sims representation

\verb!degree!\\
Returns the size of the permutations in the group.

\verb!derived_series()!\\
Return the derived series for the group.

\verb!derived_subgroup()!\\
Compute the derived subgroup.

\verb!generate(method='coset', af=False)!\\
Return iterator to generate the elements of the group

\verb!generate_dimino(af=False)!\\
Yield group elements using Dimino's algorithm

\verb!generate_schreier_sims(af=False)!\\
Yield group elements using the Schreier-Sims representation.

\verb!generators!\\
Returns the generators of the group.

\verb!is_abelian!\\
Test if the group is Abelian.

\verb!is_alt_sym(eps=0.05, _random_prec=None)!\\
Monte Carlo test for the symmetric/alternating group for degrees $>= 8$.

\verb!is_group()!\\
Return True if the group if identity is present, the inverse of every element is also an element, and the product of any two elements is also an element.

\verb!is_nilpotent!\\
Test if the group is nilpotent.

\verb!is_normal(gr)!\\
Test if G=self is a normal subgroup of \verb!gr!.

\verb!is_primitive(randomized=True)!\\
Test if a group is primitive.

\verb!is_solvable!\\
Test if the group is solvable.

\verb!is_subgroup(G, strict=True)!\\
Return True if all elements of self belong to G.

\verb!is_transitive(strict=True)!\\
Test if the group is transitive.

\verb!is_trivial!\\
Test if the group is the trivial group.

\verb!lower_central_series()! \\
Return the lower central series for the group.

\verb!make_perm(n, seed=None)!\\
Multiply n randomly selected permutations from pgroup together, starting with the identity permutation.

\verb!max_div!\\
Maximum proper divisor of the degree of a permutation group.

\verb!minimal_block(points)!\\
For a transitive group, finds the block system generated by \verb!points!.

\verb!normal_closure(other, k=10)!\\
Return the normal closure of a subgroup/set of permutations.

\verb!orbit(alpha, action='tuples')!\\
Compute the orbit of alpha \verb!\{g(\alpha) | g \in G\}! as a set.

\verb!orbit_rep(alpha, beta, schreier_vector=None)!\\
Return a group element which sends \verb!alpha! to \verb!beta!.

\verb!orbit_transversal(alpha, pairs=False)!\\
Computes a transversal for the orbit of \verb!alpha! as a set.

\verb!orbits(rep=False)!\\
Return the orbits of self, ordered according to lowest element in each orbit.

\verb!order()!\\
Return the number of permutations that can be generated from elements of the group.

\verb!pointwise_stabilizer(points, incremental=False)!\\
Return the pointwise stabilizer for a set of points.

\verb!random(af=False)!\\
Return a random group element.

\verb!random_pr(gen_count=11, iterations=50, _random_prec=None)!\\
Return a random group element using product replacement.

\verb!random_stab(alpha, schreier_vector=None, _random_prec=None)!\\
Random element from the stabilizer of \verb!alpha!.

\verb!schreier_sims()!\\
Schreier-Sims algorithm.

\verb!schreier_sims_incremental(base=None, gens=None)!\\
Extend a sequence of points and generating set to a base and strong generating set.

\verb!schreier_sims_random(base=None, gens=None,!\\

\verb! consec_succ=10, _random_prec=None)!\\
Randomized Schreier-Sims algorithm.

\verb!schreier_vector(alpha)! \\
Computes the schreier vector for \verb!alpha!.

\verb!stabilizer(alpha)!\\
Return the stabilizer subgroup of \verb!alpha!.

\verb!stabilizer_cosets(af=False)!\\
Return a list of cosets of the stabilizer chain of the group as computed by the Schreir-Sims algorithm.

\verb!stabilizer_gens(af=False)!\\
Return the generators of the chain of stabilizers of the Schreier-Sims representation.

\verb!strong_gens!\\
Return a strong generating set from the Schreier-Sims algorithm.

\verb!subgroup_search(prop, base=None, strong_gens=None,!\\

\verb!tests=None, init_subgroup=None)!\\
Find the subgroup of all elements satisfying the property prop.

\verb!transitivity_degree!\\
Compute the degree of transitivity of the group.

\section{Polyhedron}
Path : \verb!sympy.combinatorics.polyhedron.Polyhedron!\\
Represents the polyhedral symmetry group (PSG).
\subsection{Methods}
\verb!array_form!\\
Return the indices of the corners.

\verb!corners!\\
Get the corners of the Polyhedron.

\verb!cyclic_form!\\
Return the indices of the corners in cyclic notation.

\verb!edges!\\
Given the faces of the polyhedra we can get the edges.

\verb!faces!\\
Get the faces of the Polyhedron.

\verb!pgroup!\\
Get the permutations of the Polyhedron.

\verb!reset()!\\
Return corners to their original positions.

\verb!rotate(perm)!\\
Apply a permutation to the polyhedron in place.

\verb!size!\\
Get the number of corners of the Polyhedron.

\verb!vertices!\\
Get the corners of the Polyhedron.

\section{Prufer}
Path: \verb!sympy.combinatorics.prufer.Prufer!\\
The Prufer correspondence is an algorithm that describes the bijection
 between labeled trees and the Prufer code.
  A Prufer code of a labeled tree is unique up to
   isomorphism and has a length of $n - 2$.
\subsection{Methods}

\verb!static edges(*runs)!\\
Return a list of edges and the number of nodes from the given
 runs that connect nodes in an integer-labelled tree.

 \verb!next(delta=1)!\\
Generates the Prufer sequence that is delta beyond the current one.

\verb!nodes!\\
Returns the number of nodes in the tree.

\verb!prev(delta=1)!\\
Generates the Prufer sequence that is -delta before the current one.

\verb!prufer_rank()!\\
Computes the rank of a Prufer sequence.

\verb!prufer_repr!\\
Returns Prufer sequence for the Prufer object.

\verb!rank!\\
Returns the rank of the Prufer sequence.

\verb!size!\\
Return the number of possible trees of this Prufer object.

\verb!static to_prufer(tree, n)!\\
Return the Prufer sequence for a tree given as a list of edges where n is the number of nodes in the tree.

\verb!static to_tree(prufer)!\\
Return the tree (as a list of edges) of the given Prufer sequence.

\verb!tree_repr!\\
Returns the tree representation of the Prufer object.

\verb!unrank(rank, n)!\\
Finds the unranked Prufer sequence.

\section{Subset}
Path: \verb!sympy.combinatorics.subsets.Subset!\\
Represents a basic subset object.

\subsection{Methods}

\verb!bitlist_from_subset(subset, superset)!\\
Gets the bitlist corresponding to a subset.

\verb!cardinality!\\
Returns the number of all possible subsets.

\verb!iterate_binary(k)!\\
This is a helper function. It iterates over the binary subsets by k steps. This variable can be both positive or negative.

\verb!iterate_graycode(k)!\\
It performs k step overs to get the respective Gray codes.

\verb!next_binary()!\\
Generates the next binary ordered subset.

\verb!next_gray()!\\
Generates the next Gray code ordered subset.

\verb!next_lexicographic()!\\
Generates the next lexicographically ordered subset. NOT IMPLEMENTED

\verb!prev_binary()!\\
Generates the previous binary ordered subset.

\verb!prev_gray()!\\
Generates the previous Gray code ordered subset.

\verb!prev_lexicographic()!\\
Generates the previous lexicographically ordered subset. NOT IMPLEMENTED

\verb!rank_binary!\\
Computes the binary ordered rank.

\verb!rank_gray!\\
Computes the Gray code ranking of the subset.

\verb!rank_lexicographic!\\
Computes the lexicographic ranking of the subset.

\verb!size!\\
Gets the size of the subset.

\verb!subset!\\
Gets the subset represented by the current instance.

\verb!subset_from_bitlist(super_set, bitlist)!\\
Gets the subset defined by the \verb!bitlist!.

\verb!subset_indices(subset, superset)!\\
Return indices of subset in superset in a list;
the list is empty if all elements of \verb!subset! are not in \verb!superset!.

\verb!superset!\\
Gets the superset of the subset.

\verb!superset_size!\\
Returns the size of the superset.

\verb!unrank_binary(rank, superset)!\\
Gets the binary ordered subset of the specified rank.

\verb!unrank_gray(rank, superset)!\\
Gets the Gray code ordered subset of the specified rank.

\verb!subsets.ksubsets(superset, k)!\\
Finds the subsets of size \verb!k! in lexicographic order.

\section{Gray Code}
Path: \verb!sympy.combinatorics.graycode.GrayCode!
A Gray code is essentially a Hamiltonian walk on an n-dimensional
 cube with edge length of one. The vertices of the cube are
 represented by vectors whose values are binary.
 The Hamilton walk visits each vertex exactly once.

\subsection{Methods}

\verb!current!\\
Returns the currently referenced Gray code as a bit string.

\verb!generate_gray(**hints)!\\
Generates the sequence of bit vectors of a Gray Code.

\verb!n!\\
Returns the dimension of the Gray code.

\verb!next(delta=1)!\\
Returns the Gray code a distance delta (default = 1) from the current value in canonical order.

\verb!rank!\\
Ranks the Gray code.

\verb!selections!\\
Returns the number of bit vectors in the Gray code.

\verb!skip()!\\
Skips the bit generation.

\verb!unrank(n, rank)!\\
Unranks an n-bit sized Gray code of rank k.
This method exists so that a derivative GrayCode class can define its own code of a given rank.

\verb!graycode.random_bitstring(n)!\\
Generates a random bitlist of length n.

\verb!graycode.gray_to_bin(bin_list)!\\
Convert from Gray coding to binary coding.

\verb!graycode.bin_to_gray(bin_list)!\\
Convert from binary coding to gray coding.

\verb!graycode.get_subset_from_bitstring(super_set, bitstring)!\\
Gets the subset defined by the bitstring.

\verb!graycode.graycode_subsets(gray_code_set)!\\
Generates the subsets as enumerated by a Gray code.

\section{Named Groups}
Path: \verb!sympy.combinatorics.named_groups!\\

\subsection{Methods}

\verb!SymmetricGroup(n)!\\
Generates the symmetric group on \verb!n! elements as a permutation group.

\verb!CyclicGroup(n)!\\
Generates the cyclic group of order n as a permutation group.

\verb!DihedralGroup(n)!\\
Generates the dihedral group Dn as a permutation group.

\verb!AlternatingGroup(n)!\\
Generates the alternating group on \verb!n! elements as a permutation group.

\verb!AbelianGroup(*cyclic_orders)!\\
Returns the direct product of cyclic groups with the given orders.

\section{Utilities}
Path: \verb!sympy.combinatorics.util!

\subsection{Methods}
\verb!_base_ordering(base, degree)!\\
Order $\{0,1,\ldots,n\}$ so that base points come first and in order

\verb!_check_cycles_alt_sym(perm)!\\
Checks for cycles of prime length $p$ with $n/2 < p < n-2$.

\verb!_distribute_gens_by_base(base, gens)!\\
Distribute the group elements \verb!gens! by membership in basic stabilizers.

\verb!_handle_precomputed_bsgs(base, strong_gens,!\\
\verb!transversals=None, basic_orbits=None,!\\
\verb!strong_gens_distr=None)!\\
Calculate BSGS-related structures from those present.

\verb!_orbits_transversals_from_bsgs(base, strong_gens_distr,!\\
\verb!transversals_only=False)!\\
Compute basic orbits and transversals from a base and strong generating set.

\verb!_remove_gens(base, strong_gens,!
\verb!basic_orbits=None, strong_gens_distr=None)!\\
Remove redundant generators from a strong generating set.

\verb!_strip(g, base, orbits, transversals)!\\
Attempt to decompose a permutation using a (possibly partial) BSGS structure.

\verb!_strong_gens_from_distr(strong_gens_distr)!\\
Retrieve strong generating set from generators of basic stabilizers.

\section{Group Constructors}
Path: \verb!sympy.combinatorics.group_constructs!

\subsection{Method}
\verb!DirectProduct(*groups)!\\
Returns the direct product of several groups as a permutation group.

\section{Test Utilities}
Path: \verb!sympy.combinatorics.testutil!

\subsection{Methods}
\verb!_cmp_perm_lists(first, second)!\\
Compare two lists of permutations as sets.

\verb!_naive_list_centralizer(self, other)!\\

\verb!_verify_bsgs(group, base, gens)!\\
Verify the correctness of a base and strong generating set.

\verb!_verify_centralizer(group, arg, centr=None)!\\
Verify the centralizer of a group/set/element inside another group.

\verb!_verify_normal_closure(group, arg, closure=None)!\\

\rule{0.3\linewidth}{0.25pt}
\scriptsize\\
https://www.sympy.org/cheatsheets

\end{multicols}
\end{document}


\documentclass[12pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amsmath, amssymb, amsthm}
\usepackage{wasysym}
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{mathtools}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\graphicspath{ {./} }
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\prob}{\mathbb{P}}
\newcommand{\degrees}{^{\circ}}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\author{Tianshuang (Ethan) Qiu}
\begin{document}
\title{Math 104, HW7}
\maketitle
\newpage

\section{Q1}
We first show that the limits exist $\implies$ uniformly continuous. We extend the definition of $f: [a,b]$ where $f(a) = \lim_{x\to a}, f(b) = \lim_{x\to b}$. Since the limit exists, we know that $f$ can get arbitrily close it. More precisely, we know that there exists $\delta$ such that $|x-a| < \delta \implies |f(x)-\lim_{x\to a}|<\epsilon$ for any $\epsilon > 0$. This also demonstrates continuity at $a$. We can repeat this logic to show that it is continuous at $b$. Then, since $f$ is continuous on the closed inverval and continuous, it is uniformly continuous.
\newline
Now we show that uniformly continuous $\implies$ limits exist. Let $a_n \in (a,b)$ be an arbitrary sequence that converges to $a$. Then since it is convergent, we know that it is cauchy. Now since $f$ is uniformly continuous, we know that $f(a_n)$ is also cauchy, and it is therefore convergent. Therefore the limit exists as $x \to a$. We can repeat this argument for $b$ to show that $\lim_{x\to b} f(x)$ exists.
\newline
Thus it is proven.
\newpage

\section{Q2}
\subsection{Forward statement}
Let $f: S \to S^{*}$ be continuous, let $E \subset S^{*}$ be a closed set, then $E' = S^{*} \setminus E$ is open and $f^{-1}(E')$ is also open by continuity.
\newline
Consider $f^{-1}(E')$, since $f$ is defined on all $S$, each $\exists f(s) \forall s \in S$. Therefore all $s \in S$ either has an image in $E$ or in $E'$, and $f^{-1}(E') = S \setminus f^{-1}(E)$. Since we know that both $S$ and $f^{-1}(E')$ are open, $f^{-1}(E)$ must be closed.

\subsection{Converse}
Now assume that for any closed $F \subset S^{*}$,  $f^{-1}(F)$ is also closed. We essentially construct the same proof for open sets but with one more step. For any point $s_0 \in S$, $\epsilon >0$,  construct open set $G = \{d^{*}(f(s_0), s^{*}) < \epsilon\}$. Now take its complement $G' = S^{*} \setminus G$. Since $S^{*}$ and $G$ are both open, $G'$ is closed.
\newline
By our assuption $H' = f^{-1}(G')$ is closed, then its complement $H = S \setminus H'$ is open. Since $f(s_0) \in G$, we have $s_0 \in H$. Then we can find a "ball" inside this set such that for some $\delta >0$, $\{d(s-s_0)<\delta\} \subseteq H$
\newline
Thus it follows that $d(s-s_0)<\delta$ implies $d^{*}(f(s_0), s^{*}) < \epsilon$ and we have shown that $f$ is continuous at $s_0$. Since $s_0$ is an arbitrary point in $S$, $f$ is continuous.
\newpage

\section{Q3}
Let $C = \{(1/n, \infty)...\}$ for all $n \in \N$.
We claim that $C$ is a cover for $(0, \infty)$. To see that it is true, let $x \in (0, \infty)$, if $x>1$, it is in every subset. Otherwise, by the Archimedean Principle there exists $m \in \N$ such that $1/m < x$. Therefore $x \in (1/m, \infty) \in C$.
\newline
Now we take $C \cup (-\infty, 0]$. Let $x \in \R$, if $ x\leq 0$, then it is in the second set, otherwise it is in the first.
\newline
Let $C'$ be a finite subset of $C$, then we must have $C' = \{(1/a, \infty), ..., (1/b, \infty)\}$ with natural numbers $a \leq b$. Now consider $r = 1/(2a)$. Since $0<r<1/a$, $r \not \in C'$, and $r \not \in (-\infty, 0]$
\newline
We can find a such $r$ for any finite subset of $C$, therefore there is no finite subcover of $\R$. Thus $\R$ is not compact.
\newpage

\section{Q4}
Consider $X = S \setminus F$. Since $F$ is closed, its complement $X$ is open. Now let $C$ be any arbitrary open cover of $F$. We take the union of the above two sets: $C' = X \cup C$. Since $C$ covers F and $A$ covers the rest of the metric space, and since $E \subset S$, $C'$ is an open cover of $E$.
\newline
Now we apply the definition of compactness, so there exists a finite subcover in $C'$. Let this subcover be $Y$. If $X \not\in Y$, then our proof is complete since $F \subseteq E$. Any cover that covers $E$ must also cover $F$.
\newline
Otherwise, we remove A: $Y \setminus X$. Since we have removed what we have added, $(Y \setminus X) \subseteq C$. This set is a subcover for $F$, since $X \cup F = \emptyset$, we are not removing any point that is inside $F$, thus we have found a subcover that covers $F$.
\newpage

\section{Q5}
Any set with the interval property can be written as $(a,b), [a,b], (a,b], [a,b)$, where $a$ is the infimum of the set and $b$ the supremum. Square brackets mean that the infimum/supremum is in the set and round brackets mean that they are not.

\subsection{a}
If $I$ is closed, then $R \setminus I$ is open. Let $I$ be $[x,y]$. Then its complement is $(-\infty, x) \cup (y, \infty)$. For any point $i_0$ in this complement, we pick $r = \min\{|i_0-x|/2, |i_0-y|/2\}$, and thus $\{|i-i_0|<r\} \subset (\R \setminus I)$. Having square brackets on both ends ensures that $I$'s complement is open, therefore $I$ is closed.
\newline
Otherwise consider $I$ with a round bracket. Then its complement will contain that point. Let that point be $i_1$. At $i_1$, for any $r>0$, $\{|i_1-i|<r\} \cap I \not = \emptyset$. There will always be some part of that set that is in our original $I$. Therefore an interval with any round brackets is not closed.

\subsection{b}
If $I$ is open, then let it be $(x,y)$. For any point $i_0$ in this complement, we pick $r = \min\{|i_0-x|/2, |i_0-y|/2\}$, and thus $\{|i-i_0|<r\} \subseteq I$. Having round brackets on both ends ensures that $I$ is open.
\newline
Otherwise consider $I$ with a square bracket. Then it contains this point. Let this point be $i_1$ At $i_1$, for any $r>0$, $\exists j \in \{|i_1-i|<r\} \not \in I$
\newline
No matter how small we make the radius, this set will contain points that are not in $I$. Therefore having any square brackets make the interval not open.
\newpage

\section{Q6}
We first assume that the set $G = E \cup F$ is disconnected. Then it follows that there exists two open sets $A,B$ such that $G = (G \cap A) \cup (G \cap B)$, $ (G \cap A) \cap (G \cap B) = \emptyset$, and $A \cap G \not = \emptyset$, $B \cap G \not = \emptyset$
\newline
We now attempt to show that these two sets cannot exist.
\newline
Let $x \in E \cap F$, then without loss of generality assume that $x \in A$. Now take $y \in B$. Now one of the following must be true: $y \in E$ or $y \in F$. To make this simpler we name the subset that $y$ is in: $H$. Since $x \in E \cap F$, $x \in H$. Now we have $x \in A \cap H, y \in B \cap H$.
\newline
Since $E, F$ are connected, $H$ must also be connected. Since we know that $x \in A \cap H, y \in B \cap H$, we know that $A \cap H \not = \emptyset$, $B \cap H \not = \emptyset$. According to our assumption, $G \subseteq A \cup B$, then $H \subset A \cup B$. However, this is not possible because $H$ is connected and per the defintion of connectedness, it cannot be split by two open sets that satisfy the above constraints.
\newline
Therefore as shown above the sets $A, B$ cannot exist. We have reached a contradiction, and $G$ is therefore connected.
\newpage

\section{Q7}
Since the equation we are given is a unit circle, we know from trigonometry that we can paramatrize the unit circle into $x=\cos(x), y=\sin(x), 0 \leq x \leq 2\pi$
\newline
Now since sine and cosine are both continuous, their sum is also continuous. Since $[0, 2\pi]$ is an interval, it is connected. We apply the theorem that continuous functions map connected sets to connected sets to see that the image (the unit circle) is connected as well.

\end{document}