\section{Guided waves Based SHM through DL}
The guided waves approach is widely utilised in SHM/NDT, due to the fact it is able to detect very small damage sizes ~\cite{Guemes2020}.
Damage detection and identification approaches using guided waves are based on the measurements of the PZT sensors whether bonded or embedded into the investigated structure.
In which, PZT sensor(s) responsible for the excitation of the structure by a short ultrasonic pulse (usually, the used frequency is in the range of a hundreds of kHz) that propagates through an investigated structure such as plates or pipes as an elastic wave.
The registered signals (baseline) are stored and compared with other registered signals acquired through the lifetime of the investigated structure.
Damage detection using the baseline subtraction approach for guided waves is based on subtracting damage-free registered measurements from the newly registered measurements to obtain the new changes that occurred to the structure.
These changes are considered as damage information.
The baseline approach is effective in controlled environments where the variations of the operational/environments (i.e. considerations of multiple sensing modalities, uncertainty in material properties, bounding conditions, etc ) are negligible ~\cite{Yuan2020}.
Such variations can alter registered data leading to false alarms.
The effect of such variations can be reduced through physics-based modeling, which can simulate an undamaged scenario (baseline) for the wave propagation through the investigated structure.
Then, the simulated baseline can be used in the subtraction for damage detection.
However, for real-world structures, it is difficult to tune the model parameter to match the experimental registered data.
Accordingly, data-driven techniques based on ML and DL approaches can be the solution and deliver a robust models for many real-life variations.

In the following, several guided wave for SHM/NDT based on data-driven techniques for damage detection and localisation are presented.
Authors in~\cite{Melville1949} proposed a CNN model for the prediction of damage state in thin metal plates to overcome the issue of inaccurate representation of guided wave propagation when applying conventional approaches.
The model utilizes the full wavefield scans of thin plates (aluminum).
Moreover, the acquired raw data used for training the model was divided into undamaged and damaged states equally.
The model achieved higher accuracy regarding damage  \(99.98\%\) when compared to SVM that achieved \(62\%\).
Authors in~\cite{Sammons2016} proposed a CNN model based on X-ray computed tomography for delamination estimation in a composite structure.
Furthermore, image segmentation was applied to the input images to identify the damage.
However, the model was only able to identify small delaminations.
Moreover, Chetwynd et al. ~\cite{Chetwynd2008} presented a multi-layer perceptron (MLP) network for damage detection in curved composite panels, in which, stiffeners were added to represent the damage.
The Authors in this work investigated the propagation of Lamb waves through the panel in which they were generated and registered by a PZT array.
Furthermore, for each Lamb wave response, a novelty index was obtained.
The index value is compared to some threshold value, in which if the index value exceeds the threshold it implies that there is damage in the structure.
Accordingly, the MLP network was fed by obtained novelty indexes, and performed two operations: classification and regression.
The classification network was designed to define three convex regions of the panel then to determine whether the panel is damaged or not.
On the other hand, the regression network is capable of estimating the exact location of the damage.
Furthermore, authors in~\cite{DeFenza2015} proposed an artificial neural network (ANN) model for damage detection in plates made of aluminum alloys and composite utilising Lamb waves.
Response data of wave propagation were used to calculate damage indexes which were fed into the model as an input.
Accordingly, the model performs automatic feature extraction in conjunction with the probability ellipse-based method.
The ANN model and probability ellipse (PE) method were applied to identify damage location.
The results from the ANN model and the PE presents how it is useful to apply damage indexes as a baseline for such methods in order to evaluate damage in aluminum and composite structures.
Ewald et al.~\cite{Ewald2019} present a CNN model called (DeepSHM) for signal classification using Lamb waves.
Furthermore, the model provides an end-to-end approach for SHM by utilising response signals captured by sensors.
Moreover, response signals were preprocessed by wavelet transform to get the wavelet coefficient matrix (WCM).
Further, the CNN model was trained with the WCM to obtain neural weights.
Authors in~\cite{Ijjeh2021} presented a fully convolutional network (FCN)  for damage identification in composite plates base on a supervised learning approach.
Furthermore, the authors utilised a full wavefield of Lamb waves propagation, which was numerically generated resembling measurements acquired by scanning laser Dopler vibrometer (SLDV).
The model performs a pixel-wise segmentation that is able to identify the delamination which results in damaged and undamaged classes.
Moreover, the model results were validated through a comparison with a conventional wavefield signal processing method i.e. adaptive wavenumber filtering~\cite{Radzienski2019,Kudela2018}.
The proposed model achieved an accuracy of \(93.3\%\) in damage detection on numerical data compared to  \(64.8\%\) with the conventional method.
Furthermore, the proposed model was verified on experimental data and it proved its ability for generalisation.


\section{Empirical Illustration}\label{sec:3}

This section demonstrates the use of our new statistic by revisiting
\citepos{GoW:08} study of excess stock returns.  Goyal and Welch argue
that many variables thought to predict excess returns (measured as the
difference between the yearly log return of the S\&P 500 index and the
T-bill interest rate) on the basis of in-sample evidence fail to do so
out-of-sample.  To show this, Goyal and Welch look at the forecasting
performance of models using a lag of the variable of interest, and
show that these models do not significantly outperform the excess
return's recursive sample mean.

Here, we conduct the same analysis, but using this paper's \mds\ test.
The benchmark model is the excess return's sample mean (as in the
original) and the alternative models are of the form
\begin{equation*}
  \mathit{excess~return}_{t+1} = \beta_{0} + \beta_{1}\
  \mathit{predictor}_{t} + \ep_{t+1},
\end{equation*}
where $\beta_{0}$ and
$\beta_{1}$ are estimated by \ols\ using a \windowlength-year window.
The predictors used are listed in the \emph{predictor} column of
Table~\ref{tab:em1}. \citep[See][for a detailed description of the
variables.]{GoW:08}  We also consider \citepos{CaT:08} proposed
correction to the models, that the forecasts be bounded below by zero
since negative forecasts are incredible, as well as two simple
combination forecasts, the mean and the median (over both the original
and the non-negative forecasts).  The data set is annual data
beginning in 1927 and ending in 2009, and the rolling window uses
\windowlength\ observations.%
\footnote{This statistical analysis was conducted in R \citep{R} and
  uses the MASS \citep[7.3-22]{VeR:02} package.} %

\begin{table}[tb!]
  \centering
  \empiricaltable
\caption{Results from \oos\ comparison of equity premium prediction
  models; the benchmark is the recursive sample mean of the equity
  premium and each alternative model is a constant and single lag of
  the variable listed in the \emph{predictor} column.  The dataset begins
  in 1927 and ends in 2009 and is annual data. The \emph{value} column
  lists the value of this paper's \oos\ statistic, the \emph{naive}
  column indicates whether the statistic is significant at standard
  critical values, and the \emph{corrected} column indicates significance
  using critical values that
  account for the number of models.  See Section~\ref{sec:3} for details.}
\label{tab:em1}
\end{table}

Table~\ref{tab:em1} presents the results for each model.  The column
\emph{value} gives the value of the test statistic for each model,
while \emph{naive} indicates whether the statistic is greater than the
standard 10\% critical value (\naivecriticalvalue). Three predictors
are significant at the naive critical values for both the original and
bounded forecasts: the dividend yield, long term interest rate, and
book to market ratio, and the median forecast is significant as well.
This could suggest that excess returns are not an \mds\ and that
information in these three variables is useful for predicting returns.

However, we know that this is an extremely optimistic assessment of
the models' performance. We are conducting \nmod\ simultaneous
hypothesis tests, so it is likely that some will reject by chance.
There are several approaches that could accommodate this multiplicity and a full
treatment is beyond the scope of this paper, however, it is
straightforward to use our results to
derive a valid critical value similar to~\citet{Whi:00}.

Let $\fb_i$ be the \oos\ statistic associated with the $i$th alternative
forecast, $\yh_{i,t+1}$. The arguments underlying our results apply essentially unchanged to
multivariate $f_t$, so the continuous mapping theorem implies that
\begin{equation*}
  \max_{i=1,\dots,\nmod} \sqrt{P} \fb_i/\sigmah_{2i} \to^d \max_{i=1,\dots,\nmod} W_i,
\end{equation*}
where $W \sim N(0, V)$ and $V$ is the $\nmod
\times \nmod$ correlation matrix with elements
\begin{equation*}
  V_{ij} = \lim \frac{\cov(\fb_i, \fb_j)}{\var(\fb_i)^{1/2} \var(\fb_j)^{1/2}}.
\end{equation*}

To estimate $V$, we use the correlation matrix associated with the
multivariate analogue of $\sigmah_2$,
\[
\oavg{t}\Big[(\fh_t - \fb)(\fh_t - \fb)' + (\fh_t - \fb)(\gh_t - \gb)'
+ (\gh_t - \gb)(\fh_t - \fb)' + 2 (\gh_t - \gb)(\gh_t - \gb)' \Big]
\]
where $\fh_t$ and $\gh_t$ are vectors with $i$th elements
\begin{gather*}
  \fh_{it} = (y_{t+1} - x_t'\bh_t)^2 - (y_{t+1} - \yh_{i,t+1})^2 + (x_t'\bh_t - \yh_{i,t+1})^2
  \intertext{and}
  \gh_{it} = 2\, \Bigg[\oavg{s} (x_s'\bh_s - \yh_{i,s+1}) x_s'\Bigg]\,
            \Bigg[\tfrac{1}{T-1} \sum_{s=1}^{T-1} x_s x_s'\Bigg]^{-1} x_t \eph_{t+1}
\end{gather*}
respectively. Call this estimate $\hat V$ and let $\hat c$ denote the
$0.90$ quantile of the distribution of $\max_i \hat W_i$, with
$\hat W \sim N(0, \hat V)$.  Then
\begin{equation*}
  \limsup_{T \to \infty} \Pr\Big[\max_{i=1,\dots,\nmod} \sqrt{P} \fb_i / \sigmah_{2i} > \hat c\Big] \leq 0.10,
\end{equation*}
under the null hypothesis that excess returns are an \mds\ with
respect to all of the information contained in the variables listed in
Table~\ref{tab:em1}, making $\hat c$ an asymptotically valid critical
value.%
\footnote{\citet{Han:05} makes the point that multiple one-sided
  comparisons can have poor power if irrelevant predictors are
  included in these tests and proposes a threshold for discarding very
  poor forecasts. His threshold is well below our worst performing
  model, so this issue is not a concern here.} %

We calculate $\hat c$ by generating \empiricaldraws\ draws from
$N(0,\hat V)$, giving a value of \empiricalcriticalvalue, and the
\emph{corrected} column of Table~\ref{tab:em1} denotes the models that
remain significant at 10\% with this critical value. Using this
critical value, none of the predictors are significant, which
gives additional support to \citepos{GoW:08} conclusion that excess
returns are unpredictable and also demonstrates the importance of
correcting for multiplicity in these studies.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "mixedwindow"
%%% TeX-command-extra-options: "-shell-escape"
%%% End:


% !TEX root = algorithms_code_subfile.tex

\chapter{Algorithms \& code blocks}

\section{Algorithms}

Use the \verb|algorithm| environment to display algorithms in pseudocode.
A list of algorithms can be generated using the macro \verb|\listofalgorithms|.

\begin{algorithm}
  \caption{Counting mismatches between two packed DNA strings
    \label{alg:packed-dna-hamming}}
  \begin{algorithmic}[0]
    \Function{Distance}{$x, y$}
      \Let{$\delta$}{$0$}
      \For{$i \gets 1 \textrm{ to } n$}
        \If{$x_i \oplus y_i \neq 0$} \Comment{$\oplus$: bitwise exclusive-or}
          \Let{$\delta$}{$\delta + 1$}
        \EndIf
      \EndFor
      \State \Return{$\delta$}
    \EndFunction
  \end{algorithmic}
\end{algorithm}

\section{Code blocks}

You can use \mintinline{latex}{\mintinline{latex}{$a+b$}} to highlight source code inline. Use the \texttt{code} environment to display a code block.
A list of listings can be generated using the macro \verb|\listoflistings|.

\begin{listing}[htbp]
\begin{code}{python}
class Person:
    def __init__(self, name="John", age=22):
        self.name = name
        self.age = age
\end{code}
\caption{Code snippet}
\label{code:snippet}
\end{listing}


\documentclass[]{BasiliskReportMemo}
\usepackage{AVS}

\newcommand{\submiterInstitute}{Autonomous Vehicle Simulation (AVS) Laboratory,\\ University of Colorado}

\newcommand{\ModuleName}{thrMomentumManagement}
\newcommand{\subject}{Reaction Wheel Angular Momentum Dumping Management Module}
\newcommand{\status}{Initial Document draft}
\newcommand{\preparer}{H. Schaub}
\newcommand{\summary}{This module reads in the Reaction Wheel (RW) speeds, determines the net RW momentum, and then determines the amount of angular momentum that must be dumped.  A separate thruster firing logic module called {\tt thrMomentumDumping} will later on compute the thruster on cycling.      }

\begin{document}

\makeCover

%
%	enter the revision documentation here
%	to add more lines, copy the table entry and the \hline, and paste after the current entry.
%
\pagestyle{empty}
{\renewcommand{\arraystretch}{1.1}
\noindent
\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}
\hline
{\bfseries Rev}: & {\bfseries Change Description} & {\bfseries By} \\
\hline
Draft & Initial document creation & H. Schaub \\
0.1 & Updated the sign of $\leftexp{B}{\Delta\bm H}$ & H. Schaub \\
\hline

\end{longtable}
}

\newpage
\setcounter{page}{1}
\pagestyle{fancy}

\tableofcontents
~\\ \hrule ~\\

\begin{figure}[htb]
	\centerline{
	\includegraphics[]{Figures/rwMomentumOverview}
	}
	\caption{Overview of the Modules Used to Perform Reaction Wheel Angular Momentum Dumping.}
	\label{fig:Fig1}
\end{figure}

\section{Introduction}
To manage the Reaction Wheel (RW) angular momentum build-up over time, a thruster-based momentum dumping strategy is used.  Figure~\ref{fig:Fig1} illustrates how the momentum dumping will occur simultaneously with an inertial pointing control solution.  Assume the spacecraft contains $N_{\text{RW}}$ RWs, and $M_{\text{thr}}$ thrusters. The net RW angular momentum is given by
\begin{equation}
	\bm h_{s} = \sum_{i=1}^{N_{\text{RW}}} \hat{\bm g}_{s_{i}} \Omega_{i}
\end{equation}
where $\hat{\bm g}_{s_{i}}$ is the RW spin axis, and $\Omega_{i}$ is the RW speed rate about this axis.
Because the inertial attitude of the spacecraft is assumed to be held nominally steady,
\begin{equation}
	\dot{\bm h}_{s} = \frac{\leftexp{B}{\D}\bm h_{s}}{\D t} + \bm\omega_{B/N} \times \bm h_{s} \approx \frac{\leftexp{B}{\D}\bm h_{s}}{\D t}
\end{equation}

\begin{figure}[tp]
	\centerline{
	\includegraphics[]{Figures/rwMomentumManagement}
	}
	\caption{Overview of the Reaction Wheel Angular Momentum Management Module.}
	\label{fig:Fig2}
\end{figure}

\section{{\tt thrMomentumManagement}  Module Description}
Figure~\ref{fig:Fig2} illustrates the function of the RW angular momentum dumping management module.  Let $h_{s,\text{min}}$ be lower bound that the RW momentum dumping strategy should achieve.  The desired net change in inertial angular momentum is thus determined through
\begin{equation}
	\leftexp{B}{\Delta}\bm H = -\leftexp{B}{\bm h}_{s} \frac{
		|\bm h_{s}| - h_{s,\text{min}}
	}{|\bm h_{s}|}
\end{equation}

This strategy requires a thruster firing solution which creates this desired $\leftexp{B}{\Delta}\bm H$ over the duration of the momentum dumping.  The goal of the RW momentum management module is to simply compute if a $\leftexp{B}{\Delta}\bm H$ is required, or set it equal to zero if the RW momentum is too small.  Not that this module will only compute $\leftexp{B}{\Delta}\bm H$ once.  Either it is zero or non-zero.  To reuse this momentum management module, the reset() function must be called.

\section{Module Parameters}
\subsection{{\tt hs\_min} Parameter}
This parameter dictates the desired lower ceiling of the RW cluster angular momentum.  It must be set prior to calling the routine.

\end{document}


\subsection{Differential forms}


%
% Nov. 10th:
% normalization, transformation and Gaussian theory parts has been carefully examined
%
%
%
%
%

\chapter{Basis Set Functions and Shell Pair Data}
%
%
%
In modern quantum chemistry package, usually there are two types of elementary functions
to compose the basis sets, one is the Slater type of function and the other is the
Gaussian function. In our program, the basis set functions are all composed by Gaussian
type functions so that here the Gaussian functions is the only thing we are going to
talk.

The basis sets is usually composed by a set of Gaussian primitive functions.
The Cartesian format has the form below:
\begin{equation}
 \label{int_sec1_eq:1}
  \chi = x^{l}y^{m}z^{n}e^{-\alpha r^{2}}
\end{equation}
and the spherical format has the form that:
\begin{equation}
 \label{int_sec1_eq:2}
\chi = r^{L}Y_{L}^{M}(\theta,\phi)e^{-\alpha r^{2}}
\end{equation}
$Y_{L}^{M}$ is the spherical hamonic functions generated in the spherically symmetric
potential(like for the atom system, so the spherical functions are more close to the
atom type of functions). we note that the angular momentum of L is expressed as
$L = l + m + n$. Compared with the Cartesian format, the spherical
functions has less functions (2L+1) for a given angular momentum number (Cartesian functions
has $(L+1)(L+2)/2$); hence the spherical functions are more useful in the calculation
involving higher angular momentum number.

For the basis set functions, it's usually expressed as linear combination of the
Gaussian primitive functions on the same center; so that to mimic the atomic orbitals
for a given atom shell(S, P, D etc.):
\begin{equation}
 \label{int_sec1_eq:3}
  \phi_{i} = \sum_{j}d_{j}\chi_{ij}
\end{equation}
where the $d_{j}$ is some fixing constant.
In the following content, we use the $\chi$ to represent the Gaussian primitive
functions, and to use $\phi$ to denote the basis set functions.

We are not going to give more talks related to the concepts and forming of the basis sets.
For this part of information, reader could refer to other materials for more information
\cite{Davidson_Feller_CR_86_681_1986} or see our previous chapter\ref{BASIS:2}.
Here in this chapter, we only describe the algorithms that how to handle the basis set
functions as well as shell pairs in the standard quantum chemistry software.

The contents in this chapters are organized as below. Firstly, we will talke about the
normalization for both primitives and the spherical primitives. Next, the transformation
between the Cartesian type of functions into the spherical functions will be discussed
in detail. Third, we will talk about the Gaussian product theorem, then based on this
theorem we will talk about what's the shell pair data and how to use it in the following
integral module.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Normalization of Cartesian Basis Set Functions}
%
%
%
%
The basis set functions of $\phi$, and the Gaussian primitive functions $\chi$ should be
normalized before in use\footnote{This is necessary in the calculation. We can understand
it in this way, that in the final the wave function, each basis set/primitive should have
some proportion; such proportion is meaningful only if the component is normalized.}:
\begin{align}
 \label{int_sec2_eq:1}
\int \chi_{i}^{*}\chi_{i} dr &= 1 \nonumber \\
\int \phi_{\mu}^{*}\phi_{\mu} dr &= 1
\end{align}

Firstly let's consider the normalization of the Gaussian primitive functions.  Suggest
for a basis set function it's composed by uncontracted basis set functions,
which means we only have one primitive function in the basis function. Assuming we have a
normalization constant of N for $\phi_{\mu}$, then we have:
\begin{align}
 \label{int_sec2_eq:2}
\int \phi_{\mu}^{*}\phi_{\mu} dr &=
\int N^{2} (x^{l}y^{m}z^{n}e^{-\alpha r^{2}})(x^{l}y^{m}z^{n}e^{-\alpha r^{2}})
dxdydz \nonumber \\
&= N^{2} \int x^{2l}y^{2m}z^{2n}e^{-2\alpha r^{2}}dxdydz \nonumber \\
&=  N^{2} \int x^{2l}e^{-2\alpha x^{2}}dx\int y^{2m}e^{-2\alpha y^{2}}dy
\int z^{2n}e^{-2\alpha z^{2}}dz \nonumber \\
&=  N^{2} I_{x}I_{y}I_{z}
\end{align}
where I is\footnote{This is the integral for the Gamma function}:
\begin{equation}
 \label{int_sec2_eq:3}
I = \int^{-\infty}_{+\infty} x^{2k}e^{-2\alpha x^{2}}dx =
\frac{(2k-1)!!\sqrt{\pi}}{(4\alpha)^{k}\sqrt{2\alpha}}
\end{equation}
Hence we can get that:
\begin{align}
 \label{int_sec2_eq:4}
N^{2}I_{x}I_{y}I_{z} &= 1 \nonumber \\
N &= \frac{1}{\sqrt{I_{x}I_{y}I_{z}}}  \nonumber \\
  &= \left( \frac{2}{\pi}\right)^{\frac{3}{4}}
\frac{2^{l+m+n}\alpha^{\frac{2l+2m+2n+3}{4}}}{\sqrt{(2l-1)!!(2m-1)!!(2n-1)!!}}
\end{align}
This could be used in normalizing the Cartesian format of primitive functions.

Now let's step further to consider the contracted basis set functions:
\begin{equation}
  \label{int_sec2_eq:5}
\phi_{\mu} = \sum_{i}d_{\mu i}\chi_{i}
\end{equation}
For each basis set function, each component shares the same angular momentum part(
Physically each basis set function should be some simulation of the corresponding
atom orbitals). Hence we can expand the \ref{int_sec2_eq:5} into some detailed form:
\begin{align}
 \label{int_sec2_eq:6}
\phi_{\mu} &= \sum_{i}d_{\mu i}\chi_{i} \nonumber \\
&= \sum_{i}d_{\mu i} x^{l}y^{m}z^{n}e^{-\alpha r_{i}^{2}}
\end{align}
Hence the \ref{int_sec2_eq:1} gives:
\begin{equation}
 \label{int_sec2_eq:7}
\begin{split}
 \int \phi_{\mu}^{*}\phi_{\mu} dr &= N^{2}\int x^{2l}y^{2m}z^{2n}
\left[ \sum_{i}d_{\mu i}e^{-\alpha r_{i}^{2}}\cdot\sum_{j}d_{\mu j}e^{-\alpha r_{j}^{2}}\right]
dr \\
&= N^{2}\sum_{i}\sum_{j}d_{\mu i}d_{\mu j}\int x^{2l}y^{2m}z^{2n}
e^{-\alpha (r_{i}+r_{j})^{2}} dr
\end{split}
\end{equation}
The result in the \ref{int_sec2_eq:7} can be easily calculated by extending \ref{int_sec2_eq:3}
into a new form (just to replace $2\alpha$ with $\alpha$):
\begin{equation}
 \label{int_sec2_eq:8}
\int x^{2k}e^{-\alpha x^{2}} dx =
\frac{(2k-1)!!\sqrt{\pi}}{(2\alpha)^{k}\sqrt{\alpha}}
\end{equation}
Hence the integral for the \ref{int_sec2_eq:7} can be finally expressed as:
\begin{equation}
 \label{int_sec2_eq:9}
\int x^{2l}y^{2m}z^{2n}e^{-\alpha (r_{i}+r_{j})^{2}} =
\frac{(2l-1)!!(2m-1)!!(2n-1)!!\pi^{\frac{3}{2}}}{2^{l+m+n}(\alpha_{i}+\alpha_{j})^{l+m+n+\frac{3}{2}}}
\end{equation}
Now we can get the final result:
\begin{align}
 \label{int_sec2_eq:10}
& N^{2}\frac{(2l-1)!!(2m-1)!!(2n-1)!!\pi^{\frac{3}{2}}}{2^{l+m+n}}
\sum_{i}\sum_{j}\frac{d_{\mu i}d_{\mu j}}{(\alpha_{i}+\alpha_{j})^{l+m+n+\frac{3}{2}}}
 = 1\rightarrow \nonumber \\
N &= \left[
\frac{(2l-1)!!(2m-1)!!(2n-1)!!\pi^{\frac{3}{2}}}{2^{l+m+n}}
\sum_{i}\sum_{j}\frac{d_{\mu i}d_{\mu j}}{(\alpha_{i}+\alpha_{j})^{l+m+n+\frac{3}{2}}}
\right]^{-\frac{1}{2}}
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Normalization for The Spherical Basis Set Functions}
%
%
%
Now let's concentrate on the normalization of an individual spherical primitive function
by start from the \ref{int_sec2_eq:1}:
\begin{equation}
 \begin{split}
  &N^{2}\int \chi_{i}^{*}\chi_{i} d\Omega = 1 \Longrightarrow  \\
  &N^{2}\int r^{L}Y_{L}^{M*}(\theta,\phi)e^{-\alpha r^{2}}
r^{L}Y_{L}^{M}(\theta,\phi)e^{-\alpha r^{2}} d\Omega = 1  \\
&N^{2}\int_{0}^{\pi}\sin \theta d\theta \int_{0}^{2\pi}d\phi Y_{L}^{M*}(\theta,\phi)
Y_{L}^{M}(\theta,\phi) \int_{0}^{\infty} dr r^{2}r^{2L}e^{-2\alpha r^{2}} = 1
 \end{split}
\label{int_norm_eq:1}
\end{equation}
Since the $Y_{L}^{M}$ is the normalized form of function(will talk about in detail in
next section), hence they are orthogonal:
\begin{equation}
 \label{int_norm_eq:2}
\int_{0}^{\pi}\sin \theta d\theta \int_{0}^{2\pi}d\phi Y_{L^{'}}^{M^{'}*}(\theta,\phi)
Y_{L}^{M}(\theta,\phi) = \delta_{LL^{'}}\delta_{MM^{'}}
\end{equation}
Therefore the \ref{int_norm_eq:1} becomes:
\begin{equation}
 \begin{split}
  &N^{2}\int \chi_{i}^{*}\chi_{i} d\Omega = 1 \Longrightarrow  \\
  &N^{2}\int_{0}^{\infty} dr r^{2}r^{2L}e^{-2\alpha r^{2}} = 1
 \end{split}
\label{int_norm_eq:3}
\end{equation}

For the integral in \ref{int_norm_eq:3}, we have:
\begin{equation}
 \begin{split}
 \int_{0}^{\infty} dr r^{2}r^{2L}e^{-2\alpha r^{2}} &=
\frac{2L+1}{4\alpha}\int_{0}^{\infty} dr r^{2L}e^{-2\alpha r^{2}}  \\
&=\frac{(2L+1)!!}{(4\alpha)^{L+1}}\int_{0}^{\infty} dr e^{-2\alpha r^{2}} \\
&=\frac{(2L+1)!!}{(4\alpha)^{L+1}}\frac{1}{2}\sqrt{\frac{\pi}{2\alpha}} \\
&=\frac{(2L+1)!!}{2^{2(L+1)+\frac{3}{2}}}\sqrt{\frac{\pi}{\alpha^{2L+3}}}
 \end{split}
\label{int_norm_eq:4}
\end{equation}
Therefore the normalization factor of $N$ is:
\begin{equation}
\label{int_norm_eq:5}
 N = \left[ \frac{(2L+1)!!}{2^{2(L+1)+\frac{3}{2}}}
            \sqrt{\frac{\pi}{\alpha^{2L+3}}}\right]^{-\frac{1}{2}}
\end{equation}
We can see that compared the \ref{int_norm_eq:5} with \ref{int_sec2_eq:4}, the normalization factor
for the spherical functions only depending on angular momentum. This is because we make use of
the orthogonality condition of spherical harmonic of $Y_{L}^{M}$.

Now let's go to the contracted basis set functions:
\begin{equation}
 \label{int_norm_eq:6}
\phi_{\mu} = \sum_{i}d_{\mu i}\chi_{i}
\end{equation}
By repeating the same process, the result is:
\begin{equation}
 \begin{split}
&N^{2}\int \phi_{\mu}^{*}\phi_{\mu} dr =\\
& N^{2}\sum_{i}\sum_{j}d_{\mu i}d_{\mu j}
\int r^{L}Y_{L}^{M*}(\theta,\phi)e^{-\alpha_{i} r^{2}}
r^{L}Y_{L}^{M}(\theta,\phi)e^{-\alpha_{j} r^{2}} d\Omega =   \\
&N^{2}\sum_{i}\sum_{j}d_{\mu i}d_{\mu j}
\int_{0}^{\infty} dr r^{2}r^{2L}e^{(\alpha_{i}+\alpha_{j}) r^{2}} \Rightarrow \\
&N =  \left[ \pi^{\frac{1}{2}}\frac{(2L+1)!!}{2^{(L+1)+1}}
\sum_{i}\sum_{j}\frac{d_{\mu i}d_{\mu j}}{(\alpha_{i}+\alpha_{j})^{L+\frac{3}{2}}}
\right]^{-\frac{1}{2}}
 \end{split}
\label{int_norm_eq:7}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Transformation from Cartesian Functions to Spherical functions}
\label{Transformation_Cart_sphere}
%
%
%
The core idea for the integral involving the spherical type of basis set functions, is that
we evaluate the integral first with its corresponding Cartesian type of functions. Then we
transform it from Cartesian type into the spherical type. Since such transform is only related
to basis set itself, so the matrix is constant for any type of integrals (normalization, one
electron integral and its derivatives etc.). In this section, we will discuss how to
compute each element in the transformation matrix.

First of all, let's get to more familiar with the spherical harmonic function of
$Y^{m}_{l}(\theta,\phi)$. This function is generated at any central field potential (which means,
the angular momentum operator is commuting with Hamiltonian for all of X, Y and Z direction).
Typically,  any atom system is central field potential so that to describe the atomic orbital,
the spherical harmonic function is some necessary part. On the other hand, it's easy to see
that spherical harmonic function could be expanded into the sum over Cartesian type of functions;
therefore this is the reason that we could use the Cartesian type of function forming the basis
set functions to mimic the atomic orbital.

The normalized $Y^{m}_{l}(\theta,\phi)$ used in this transformation could be expressed as
(here our derivation is normally just following Ref. \cite{QUA:QUA560540202}):
\begin{equation}
 \begin{split}
  Y^{m}_{l}(\theta,\phi) &=
\sqrt{\frac{2l+1}{4\pi}\frac{(l-|m|)!}{(l+|m|)!}}e^{im\phi}P_{l}^{|m|}(\cos\theta)
 \end{split}
\label{int_transform_pure_cart_eq:1}
\end{equation}
and we know that $m$ is between $-l$ and $+l$. $P_{l}^{|m|}(\cos\theta)$ is the
associated Legendre polynomials, which expresses as (here we note this form is without
the Condon - Shortley phase factor of $(-1)^{m}$):
\begin{equation}
 \label{int_transform_pure_cart_eq:2}
\begin{split}
 P_{l}^{|m|}(\cos\theta) &= (1-\cos^{2}\theta)^{\frac{|m|}{2}}
\frac{\partial^{|m|}}{\partial\cos^{|m|}\theta}P_{l}(\cos\theta) \\
&= \frac{(1-\cos^{2}\theta)^{\frac{|m|}{2}}}{2^{l}l!}
\frac{\partial^{l+|m|}}{\partial\cos^{l+|m|}\theta}(\cos^{2}\theta-1)^{l}
\end{split}
\end{equation}

Here it's worthy to note, that why we use the $|m|$ rather than $m$ in the expression.
The associated Legendre polynomials satisfy the relation below($m > 0$):
\begin{equation}
 P_{l}^{-m}(\cos\theta) = (-1)^{m}\frac{(l-m)!}{(l+m)!}P_{l}^{m}(\cos\theta)
\end{equation}
therefore for the $Y^{m}_{l}(\theta,\phi)$ it satisfy:
\begin{equation}
 Y^{-m}_{l}(\theta,\phi) = (-1)^{m}Y^{m*}_{l}(\theta,\phi)
\end{equation}
and we also have:
\begin{equation}
 \int Y^{m*}_{l}(\theta,\phi) Y^{m^{'}}_{l^{'}}(\theta,\phi) d\theta d\phi =
 \delta_{ll^{'}}\delta_{mm^{'}}
\end{equation}
Therefore, for simplicity here we could fix the $m$ to its absolute value:
\begin{equation}
\begin{split}
Y^{|m|}_{l}(\theta,\phi) &=
\sqrt{\frac{2l+1}{4\pi}\frac{(l-|m|)!}{(l+|m|)!}}e^{im\phi} \\
&\frac{(1-\cos^{2}\theta)^{\frac{|m|}{2}}}{2^{l}l!}
\frac{\partial^{l+|m|}}{\partial\cos^{l+|m|}\theta}(\cos^{2}\theta-1)^{l}
\end{split}
\label{int_transform_pure_cart_eq:3}
\end{equation}

Now let's try to convert the coordinates from spherical into the Cartesian. Firstly,
we note that the above expression is for an arbitrary basis set function with
spherical angular part. In practical use, we always stick to the normalized basis set
functions therefore we need to multiply the normalized factor\footnote{We note, that
this is for normalized Cartesian type of functions. We assume that the basis set is
normalized, we need to drop the Cartesian normalization factor and multiply it with
the spherical normalization factor}:
\begin{equation}
 c = \frac{N_{spherical}}{N_{Cartesian}} c^{'}
\end{equation}
$c^{'}$ is the coefficients we will derive below, and $N_{spherical}$ is just the
\ref{int_norm_eq:5}, and $N_{Cartesian}$ is just \ref{int_sec2_eq:4}. We note
that $\dfrac{N_{spherical}}{N_{Cartesian}}$ is:
\begin{equation}
 \frac{N_{spherical}}{N_{Cartesian}} = \sqrt{\frac{4\pi
 (2l_{x}-1)!!(2l_{y}-1)!!(2l_{z}-1)!!}{(2l+1)!!}}
\end{equation}
where we have $l = l_{x} + l_{y} + l_{z}$.

The \ref{int_transform_pure_cart_eq:3} is finally turned into:
\begin{equation}
\begin{split}
Y^{|m|}_{l}(\theta,\phi) &=
\sqrt{\frac{(2l_{x})!(2l_{y})!(2l_{z})!l!}{(l_{x})!(l_{y})!(l_{z})!(2l)!}
\frac{(l-|m|)!}{(l+|m|)!}}e^{im\phi} \\
&\frac{(1-\cos^{2}\theta)^{\frac{|m|}{2}}}{2^{l}l!}
\frac{\partial^{l+|m|}}{\partial\cos^{l+|m|}\theta}(\cos^{2}\theta-1)^{l}
\end{split}
\label{int_transform_pure_cart_eq:4}
\end{equation}

Now let's drop the partial derivatives in \ref{int_transform_pure_cart_eq:4} so that to
expand it into the polynomials. In this process, since the factor of
\begin{equation}
\sqrt{\frac{(2l_{x})!(2l_{y})!(2l_{z})!l!}{(l_{x})!(l_{y})!(l_{z})!(2l)!}
\frac{(l-|m|)!}{(l+|m|)!}}\frac{1}{2^{l}l!}
\end{equation}
is invariant therefore we designate it as $C$. Then the $Y^{m}_{l}(\theta,\phi)$ is:
\begin{equation}
 Y^{m}_{l}(\theta,\phi) = C
e^{im\phi}(1-\cos^{2}\theta)^{\frac{|m|}{2}}
\frac{\partial^{l+|m|}}{\partial\cos^{l+|m|}\theta}(\cos^{2}\theta-1)^{l}
\label{int_transform_pure_cart_eq:5}
\end{equation}

For the higher order partial derivatives, through binomial expression we can get:
\begin{equation}
\frac{\partial^{l+|m|}}{\partial\cos^{l+|m|}\theta}(\cos^{2}\theta-1)^{l} =
\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right]}\binom{l}{i}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}
\cos^{l-|m|-2i}\theta
\label{int_transform_pure_cart_eq:6}
\end{equation}

For the product between $e^{im\phi}(1-\cos^{2}\theta)^{\frac{|m|}{2}}$ we have:
\begin{equation}
 \begin{split}
 e^{im\phi}(1-\cos^{2}\theta)^{\frac{|m|}{2}} &=
(\cos\phi\pm i\sin\phi)^{|m|}(\sin^{2}\theta)^{\frac{|m|}{2}} \\
&=\frac{1}{r^{|m|}\sin^{|m|}\theta}(x\pm iy)^{|m|}\sin^{|m|}\theta \\
&=\frac{(x \pm iy)^{|m|}}{r^{|m|}}
 \end{split}
\label{int_transform_pure_cart_eq:7}
\end{equation}
Now multiply the $r^{l}$ the $Y^{m}_{l}$ becomes:
\begin{align}
 r^{l}Y^{m}_{l} &= C(x\pm iy)^{|m|}
\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }
\binom{l}{i}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}\cos^{l-|m|-2i}\theta r^{l-|m|} \nonumber \\
&=  C(x\pm iy)^{|m|}
\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }
\binom{l}{i}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}z^{l-|m|-2i}r^{2i}
\label{int_transform_pure_cart_eq:8}
\end{align}
Expanding the $r^{2i}$ gives:
\begin{equation}
\begin{split}
 r^{l}Y^{m}_{l} &=  C(x\pm iy)^{|m|}
\sum_{i=0}^{\frac{l-|m|}{2}}\binom{l}{i}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}z^{l-|m|-2i}r^{2i} \\
&= C(x\pm iy)^{|m|}
\sum_{i=0}^{\frac{l-|m|}{2}}\sum_{j=0}^{i} \\
&\binom{l}{i}\binom{i}{j}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}z^{l-|m|-2j}(x^{2}+y^{2})^{j}
\end{split}
\label{int_transform_pure_cart_eq:9}
\end{equation}

Next we expand the $(x\pm iy)^{|m|}$ as well as $(x^{2}+y^{2})^{j}$:
\begin{equation}
 \begin{split}
 r^{l}Y^{m}_{l} &=  C(x\pm iy)^{|m|}
\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }\sum_{j=0}^{i} \\
&\binom{l}{i}\binom{i}{j}(-1)^{i}\frac{(2l-2i)!}{(l-|m|-2i)!}z^{l-|m|-2j}(x^{2}+y^{2})^{j} \\
&= C\sum_{h=0}^{|m|}\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }\sum_{j=0}^{i}\sum_{k=0}^{j}
\binom{|m|}{h}\binom{l}{i}\binom{i}{j}\binom{j}{k} \\
&(-1)^{i}(\pm i)^{|m|-h}\frac{(2l-2i)!}{(l-|m|-2i)!} x^{2k+h}y^{|m|-h+2j-2k}z^{l-|m|-2j}
 \end{split}
\label{int_transform_pure_cart_eq:10}
\end{equation}

Here we have the relation that:
\begin{equation}
 \begin{cases}
  2k+h &= l_{x}  \\
  |m|-h+2j-2k &= l_{y} \\
  l-|m|-2j &= l_{z}
 \end{cases}
\label{int_transform_pure_cart_eq:11}
\end{equation}
Now the problem turns out to be that for a given set of $l_{x}, l_{y}$ and $l_{z}$;
how we can determine the corresponding coefficient for the fixed l and m value.

Suggest that $l_{x}, l_{y}$ and $l_{z}$ are fixed, and $l = l_{x} + l_{y} + l_{z}$;
it could see that $j = (l-|m| - l_{z})/2$ and $h = l_{x} - 2k$. We note that the second
function in \ref{int_transform_pure_cart_eq:11} is not independent. Therefore from
\ref{int_transform_pure_cart_eq:10} we note the coefficient is:
\begin{equation}
 \begin{split}
  C_{r^{l}Y^{m}_{l}}^{l_{x}, l_{y}, l_{z}} &= C\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }
\sum_{k=0}^{j} \\
&\binom{|m|}{l_{x}-2k}\binom{l}{i}\binom{i}{j}\binom{j}{k}(-1)^{i}(\pm i)^{|m|-l_{x}+2k}
\frac{(2l-2i)!}{(l-|m|-2i)!} \\
&= C\sum_{i=0}^{\left[ \frac{l-|m|}{2}\right] }
\sum_{k=0}^{j} \\
&\binom{|m|}{l_{x}-2k}\binom{l}{i}\binom{i}{j}\binom{j}{k}(-1)^{i}(-1)^{\frac{|m|-l_{x}+2k}{2}}
\frac{(2l-2i)!}{(l-|m|-2i)!}
 \end{split}
\label{int_transform_pure_cart_eq:13}
\end{equation}
Where
\begin{equation}
 j = \left[ (l-|m| - l_{z})/2\right]
\end{equation}
We could do more work so that to make the result in \ref{int_transform_pure_cart_eq:13}
more clear. If $j$ is not an integer, then the coefficient is zero. Furthermore
in the original form  \ref{int_transform_pure_cart_eq:10} $j\leq i$ so if $j > i$
then the $\binom{i}{j} = 0$. For the $l_{x}-2k$, it meets the similar requirement that
$0\leq l_{x}-2k \leq |m|$ since the $l_{x}$ and $|m|$ are separate variables. In
the
\ref{int_transform_pure_cart_eq:13}, if the $m<0$, we take ``-'' sing else we take ``+'' sign.

In the real quantum chemistry package, actually we always stick to the real orbitals. However,
we can always combine them into the real form:
\begin{align}
 C_{l,m,+}^{l_{x}, l_{y}, l_{z}} &= \frac{1}{\sqrt{2}}
\left( C_{r^{l}Y^{m}_{l}}^{l_{x}, l_{y}, l_{z}} + C_{r^{l}Y^{-m}_{l}}^{l_{x}, l_{y}, l_{z}}\right)
\nonumber \\
 C_{l,m,-}^{l_{x}, l_{y}, l_{z}} &= \frac{-i}{\sqrt{2}}
\left( C_{r^{l}Y^{m}_{l}}^{l_{x}, l_{y}, l_{z}} - C_{r^{l}Y^{-m}_{l}}^{l_{x}, l_{y}, l_{z}}\right)
\label{int_transform_pure_cart_eq:14}
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Transformation from Spherical functions to Cartesian functions}
\label{transformation_p2c}

Sometimes we will meet the reverse situation, that we need to convert the spherical functions
into the Cartesian ones. This is very common when we do integral calculation, since all of
integrals are based on Cartesian form of Gaussian primitive functions.

Based on the expression for Cartesian to spherical transformation, this job is easily done.
Suppose we have an overlap matrix based on normalized Cartesian basis set functions,
then we have the result below:
\begin{equation}
  \label{transformation_p2c_eq:1}
  T^{+}ST = I
\end{equation}
$T^{+}ST = I$ is because normalized spherical basis sets overlap matrix must give identity
matrix. $T$ is the transformation matrix to convert the overlap matrix from Cartesian
into spherical type, and $T^{+}$ is it's conjugated matrix. Based on this idea,
the reverse of the $T$ could be simply expressed as:
\begin{equation}
 \label{transformation_p2c_eq:2}
 T^{+}ST = I \Rightarrow T^{-1} = T^{+}S
\end{equation}
For $T$ with only real number, $T^{+}$ is simply the transpose of $T$.

Now the problem is that how can we calculate $S$. We can pick up the simplest form of basis
set functions. In these functions, there's only one only have one
Gaussian primitive function, and all of the basis set functions are on same center. Furthermore,
all of these basis set functions have the same exponent factor
\footnote{Since the transformation work is independent on the
basis set content, therefore we can choose to use the simplest basis set function to derive
the general formula here}. Based on our assumption, the basis set functions is simply expressed
as:
\begin{equation}
 \label{transformation_p2c_eq:3}
 \chi(r) = x^{l}y^{m}z^{n}e^{-\alpha r^{2}}
\end{equation}
For different basis set functions, only the $l,m,n$ change.

Now the matrix element in \ref{transformation_p2c_eq:1} can be expressed as:
\begin{equation}
 S_{ij} = N_{i}N_{j}\int\chi_{i}(r)\chi_{j}(r) dr = N_{i}N_{j}s_{ij}
\end{equation}
$N$ is the normalized factor for Cartesian basis set function.

Through the \ref{int_sec2_eq:4} we can get the normalized factor:
\begin{equation}
\label{transformation_p2c_eq:4}
N_{i} = \left( \frac{2}{\pi}\right)^{\frac{3}{4}}
\frac{2^{l_{i}+m_{i}+n_{i}}\alpha^{\frac{2l_{i}+2m_{i}+2n_{i}+3}{4}}}
{\sqrt{(2l_{i}-1)!!(2m_{i}-1)!!(2n_{i}-1)!!}}
\end{equation}

The $s_{ij}$ can be got through \ref{overlap_direct_int_eq:9}:
\begin{align}
\int\chi_{i}(r)\chi_{j}(r) dr &=
\int x^{l_{i}+l_{j}}y^{m_{i}+m_{j}}z^{n_{i}+n_{j}}e^{-(2\alpha)r^{2}} dr \nonumber \\
&= \left( \frac{\pi}{2\alpha}\right)^{\frac{3}{2}}
\frac{(l_{i}+l_{j}-1)!!(m_{i}+m_{j}-1)!!(n_{i}+n_{j}-1)!!}
{(2(2\alpha))^{\frac{l_{i}+l_{j}+m_{i}+m_{j}+n_{i}+n_{j}}{2}}}
\end{align}

By setting that:
\begin{align}
 l_{i}+l_{j} &= l  \nonumber \\
 m_{i}+m_{j} &= m  \nonumber \\
 n_{i}+n_{j} &= n  \nonumber \\
 l_{i}+m_{i}+n_{i} &= l_{j}+m_{j}+n_{j} = L
\end{align}
We can have:
\begin{align}
\label{transformation_p2c_eq:5}
 S_{ij} &=
 \left( \frac{2}{\pi}\right)^{\frac{3}{4}}
\frac{2^{L}\alpha^{\frac{2L+3}{4}}}{\sqrt{(2l_{i}-1)!!(2m_{i}-1)!!(2n_{i}-1)!!}} \times \nonumber \\
&\left( \frac{2}{\pi}\right)^{\frac{3}{4}}
\frac{2^{L}\alpha^{\frac{2L+3}{4}}}{\sqrt{(2l_{j}-1)!!(2m_{j}-1)!!(2n_{j}-1)!!}} \times \nonumber \\
&\left( \frac{\pi}{2\alpha}\right)^{\frac{3}{2}}
\frac{(l-1)!!(m-1)!!(n-1)!!}
{(4\alpha)^{L}} \nonumber \\
&= \frac{(l-1)!!(m-1)!!(n-1)!!}
{\sqrt{(2l_{i}-1)!!(2m_{i}-1)!!(2n_{i}-1)!!(2l_{j}-1)!!(2m_{j}-1)!!(2n_{j}-1)!!}}
\end{align}
This is what we need to know for the transformation process.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Gaussian Primitive Product Theorem}
\label{Gaussian_Primitive_Product_Theorem}

Suggest that we have two arbitrary primitive functions, one is centered at nuclear A and the other
is centered at nuclear B; the electron is located at ``e'', which is shown by the figure \ref{fg:1}.
The theorem shows that for any two center Gaussian primitive functions, their product can be
expressed by a new Gaussian type of primitive function which is centered at ``P''.

\begin{figure}[!hbp]
\begin{center}
\includegraphics[scale=0.7]{gp.eps}
\caption{Gaussian primitive product theorem}
\label{fg:1}
\end{center}
\end{figure}

Now let's prove the simplest case, that both of the two primitive functions are S type of function;
so the theorem can be stated as:
\begin{equation}
 \label{gaussian_product_rule_eq:1}
e^{-\alpha r_{A}^{2}}e^{-\beta r_{B}^{2}} = Ke^{-(\alpha+\beta) r_{P}^{2}}
\end{equation}
where $K$ is some constant.

Now let's prove it. By using the Cosine Rule, it's clear that:
\begin{align}
 \label{gaussian_product_rule_eq:2}
r_{A}^{2} &= r_{P}^{2} + \overline{PA}^{2} -2r_{P}\overline{PA}\cos\theta \nonumber \\
r_{B}^{2} &= r_{P}^{2} + \overline{PB}^{2} +2r_{P}\overline{PB}\cos\theta
\end{align}
Here $\theta$ is the angle formed by $\overline{AP}$ and $\overline{Pe}$.

Now let's get rid of the $\theta$. By multiplying $\overline{PB}$ to $r_{A}^{2}$, and
multiplying $\overline{PA}$ to $r_{B}^{2}$ and add two equations in \ref{gaussian_product_rule_eq:2}
together; we can get:
\begin{equation}
 \label{gaussian_product_rule_eq:3}
\overline{PB}r_{A}^{2} + \overline{PA}r_{B}^{2} = \overline{AB}r_{P}^{2} +
\overline{PA}\times\overline{PB}\times\overline{AB}
\end{equation}

However, in the exponent part of integral, besides the $r_{A}^{2}$ we have another factor
of $\alpha$. Hence we have to find a way to associate the $\overline{PB}$ etc. with
$\alpha$ so that to make up the exponent in the left hand side of \ref{gaussian_product_rule_eq:3}.
It's easy to see that:
\begin{align}
 \label{gaussian_product_rule_eq:4}
\overline{PA} &= \frac{\beta}{\alpha+\beta}\overline{AB} \nonumber \\
\overline{PB} &= \frac{\alpha}{\alpha+\beta}\overline{AB}
\end{align}
Hence we can have:
\begin{equation}
\label{gaussian_product_rule_eq:5}
 \begin{split}
\frac{\alpha}{\alpha+\beta}\overline{AB}r_{A}^{2} +
\frac{\beta}{\alpha+\beta}\overline{AB}r_{B}^{2} &= \overline{AB}r_{P}^{2} +
\frac{\beta}{\alpha+\beta}\overline{AB}\frac{\alpha}{\alpha+\beta}\overline{AB}\times\overline{AB}
 \end{split}
\end{equation}
Where we can get the result as:
\begin{equation}
\label{gaussian_product_rule_eq:6}
\alpha r_{A}^{2} + \beta r_{B}^{2} = (\alpha+\beta)r_{P}^{2} + \frac{\alpha\beta}{\alpha+\beta}
\overline{AB}^{2}
\end{equation}
Hence we have the final result as:
\begin{equation}
\label{gaussian_product_rule_eq:7}
e^{-\alpha r_{A}^{2} - \beta r_{B}^{2}} =
e^{-(\alpha+\beta)r_{P}^{2}} e^{-\frac{\alpha\beta}{\alpha+\beta}
\overline{AB}^{2}}
\end{equation}

In the real calculation, it's necessary to know the P point location; that is to say, $P_{x}$ etc.
However, it's clear that the P's coordinate is determined by the $A$, $B$ and their exponents $\alpha$
and $\beta$:
\begin{equation}
 \label{gaussian_product_rule_eq:8}
\begin{split}
 \overline{PA} &= \frac{\beta}{\alpha+\beta}\overline{BA} \rightarrow \\
\overrightarrow{P} - \overrightarrow{A} &= \frac{\beta}{\alpha+\beta}
(\overrightarrow{B} - \overrightarrow{A}) \rightarrow  \\
\overrightarrow{P} &= \frac{\alpha}{\alpha+\beta}\overrightarrow{A} +
\frac{\beta}{\alpha+\beta}\overrightarrow{B}
\end{split}
\end{equation}
So from here all of $P_{x}$, $P_{y}$ and $P_{z}$ can be got.

Now let's extend it to any arbitrary Gaussian primitives, that is to say; how we can express
the following expression?
\begin{equation}
   x_{A}^{l_{1}}y_{A}^{m_{1}}z_{A}^{n_{1}}e^{-\alpha r_{A}^{2}}
   x_{B}^{l_{2}}y_{B}^{m_{2}}z_{B}^{n_{2}}e^{-\beta  r_{B}^{2}}   =  ?
\label{gaussian_product_rule_eq:9}
\end{equation}
for the $X_{A}$, since we have:
\begin{equation}
\begin{split}
 x_{A} &= e_{x} - A_{x} \\
       &= e_{x} - P_{x} + P_{x} - A_{x} \\
       &= x_{P} + \overline{PA}_{x}
\end{split}
 \label{gaussian_product_rule_eq:10}
\end{equation}
Hence for the $x_{A}$ it totally converts into the expression related to $x_{P}$.

Similarly, for the $y_{A}$, $z_{A}$ etc. it's convenient to get their expressions too. So we can
finally convert the \ref{gaussian_product_rule_eq:9} into:
\begin{align}
&  x_{A}^{l_{1}}y_{A}^{m_{1}}z_{A}^{n_{1}}e^{-\alpha r_{A}^{2}}
   x_{B}^{l_{2}}y_{B}^{m_{2}}z_{B}^{n_{2}}e^{-\beta  r_{B}^{2}} \nonumber \\
=& (x_{P} + \overline{PA}_{x})^{l_{1}}(y_{P} + \overline{PA}_{y})^{m_{1}}
   (z_{P} + \overline{PA}_{z})^{n_{1}}e^{-\alpha r_{A}^{2}} \times \nonumber \\
&  (x_{P} + \overline{PB}_{x})^{l_{2}}(y_{P} + \overline{PB}_{y})^{m_{2}}
   (z_{P} + \overline{PB}_{z})^{n_{2}}e^{-\beta  r_{B}^{2}} \nonumber \\
=& (x_{P} + \overline{PA}_{x})^{l_{1}}(y_{P} + \overline{PA}_{y})^{m_{1}}
   (z_{P} + \overline{PA}_{z})^{n_{1}} \times \nonumber \\
&  (x_{P} + \overline{PB}_{x})^{l_{2}}(y_{P} + \overline{PB}_{y})^{m_{2}}
   (z_{P} + \overline{PB}_{z})^{n_{2}} \times \nonumber \\
&  e^{-(\alpha+\beta)r_{P}^{2}} e^{-\frac{\alpha\beta}{\alpha+\beta}
\overline{AB}^{2}}
  \label{gaussian_product_rule_eq:11}
\end{align}

In the practical calculation, usually it's required to separate the $x_{P}$ etc. from the
$(x_{P} +\overline{PA}_{x})^{l_{1}}$. So according to binomial theorem we may have:
\begin{equation}
 (x_{P} +\overline{PA}_{x})^{l_{1}} = \sum_{i=0}^{l_{1}} x_{P}^{i}\overline{PA}_{x}^{l_{1}-i}
\binom{l_{1}}{i}
 \label{gaussian_product_rule_eq:12}
\end{equation}

Hence we could combine the two terms together:
\begin{equation}
\label{gaussian_product_rule_eq:13}
\begin{split}
(x_{P} +\overline{PA}_{x})^{l_{1}}(x_{P} + \overline{PB}_{x})^{l_{2}}
&=  \sum_{i=0}^{l_{1}} x_{P}^{i}\overline{PA}_{x}^{l_{1}-i}
\binom{l_{1}}{i}
    \sum_{j=0}^{l_{2}} x_{P}^{j}\overline{PB}_{x}^{l_{2}-j}
\binom{l_{2}}{j} \\
&= \sum_{k=0}^{l_{1}+l_{2}}x_{P}^{k}
\sum_{i=0,j=k-i}^{i=l_{1},j=l_{2}}\overline{PA}_{x}^{l_{1}-i}
\overline{PB}_{x}^{l_{2}-j}\binom{l_{1}}{i}\binom{l_{2}}{j}
\end{split}
\end{equation}

Now let's make some further analysis to the result shown in the \ref{gaussian_product_rule_eq:13}.
The term involves $i,j$ together actually is not convenient for computation purpose, hence we should
make it easier. Firstly we noticed that for the index $i$ we have such restrictions:
\begin{equation}
 \begin{cases}
  &0 \leq i \leq l_{1} \\
  &k-l_{2} \leq i \leq k
 \end{cases}
\end{equation}
$i\leq k$ is because that $i+j=k$ and $j\geq 0$. $i\geq k-l_{2}$ is because $l_{2} - k+i \geq 0$ in
the \ref{gaussian_product_rule_eq:13}. Therefore the problem here is how can we sort out the
real range of $i$?

Now we can guess that \ref{gaussian_product_rule_eq:13} perhaps can be rearranged into the form
below\footnote{In practice we have tested the expression below for the $(x+a)^{3}(x+b)^{2}$, but
the proof can demonstrate that it's true for all of cases}:
\begin{multline}
\label{gaussian_product_rule_eq:14}
 (x_{P} +\overline{PA}_{x})^{l_{1}}(x_{P} + \overline{PB}_{x})^{l_{2}} = \\
\sum_{k=0}^{l_{1}+l_{2}}x_{P}^{k}
\sum_{i=max(0,k-l_{2})}^{i=min(k,l_{1})}\overline{PA}_{x}^{l_{1}-i}
\overline{PB}_{x}^{l_{2}-k+i}\binom{l_{1}}{i}\binom{l_{2}}{k-i}
\end{multline}

Now let's literally prove it. Suggest we have the expression below:
\begin{align}
\label{gaussian_product_rule_eq:15}
 (x_{P} +\overline{PA}_{x})^{l_{1}}(x_{P} + \overline{PB}_{x})^{l_{2}} &=
\sum_{i=0}^{l_{1}} x_{P}^{i}\overline{PA}_{x}^{l_{1}-i}
\binom{l_{1}}{i}
    \sum_{j=0}^{l_{2}} x_{P}^{j}\overline{PB}_{x}^{l_{2}-j}
\binom{l_{2}}{j} \nonumber \\
&=\sum_{k=0}^{l_{1}+l_{2}}x_{P}^{k} f_{k}(i,j,l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x})
\end{align}
Where $i+j = k$, and $f_{k}$ expressed as:
\begin{equation}
\label{gaussian_product_rule_eq:16}
 f_{k}(i,j,l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x}) =
\sum_{?}^{?}
\overline{PA}_{x}^{l_{1}-i}
\overline{PB}_{x}^{l_{2}-j}\binom{l_{1}}{i}\binom{l_{2}}{j}
\end{equation}

It's easy to know, that for each fixed $k$ value, $(i=0,j=k), (i=1,j=k-1), \cdots,
(i=k,j=0)$ contribute to the $f_{k}$. However, since $i$ and $j$ are also limited by the
$l_{1}$ and $l_{2}$, the $i$ and $j$ may not be able to take all of the pairs shown before.
Now the problem is, if we very $i$ freely, and take $j=k-i$; then what's the range of $i$
in variation?

Firstly let's consider the starting point of $i$. Obviously $i$ could start from $0$, however;
if $i=0$, then for a fixed $k$ then $j$ is $j=k-0=k$. But $j$ has a upper limit which is
$j\leq l_{2}$, and it could have the situation that $l_{2} \leq k$. Hence in this situation,
where $l_{2} \leq k$, then the minimum value of $i$ could not be $0$, but the value of $k-l_{2}$
since the maximum value of $j$ is $l_{2}$. The analysis here indicates that for the starting
point of $i$, we should use ``max'' function for the $(0, k-l_{2})$.

Second let's go to see the end point of $i$. The $i$ could be $l_{1}$ from its definition,
however; as $i=l_{1}$ then $j=k-i=k-l_{1}$ that we may have the situation of $k-l_{1}\leq 0$.
Since $j$ must be larger or equal to zero so that the maximum number of $i$ could be $k$
(if $l_{1}\geq k$) or could be $l_{i}$ (if $l_{1}\leq k$). In this case, we have a minimum
function of ``min'' between $(k,l_{1})$.

Finally, we note that the range analysis does not change the mathematical expression in the
\ref{gaussian_product_rule_eq:16}. Hence the proof is ended.

Now in the \ref{gaussian_product_rule_eq:16}, we are going to drop the index of $i$, $j$ from
the $f_{k}$ variable list since $i$ is summed over in the expression, and $j=k-i$ so that solely
determined by $i$ and $k$; hence we have:
\begin{equation}
\label{gaussian_product_rule_eq:17}
 (x_{P} +\overline{PA}_{x})^{l_{1}}(x_{P} + \overline{PB}_{x})^{l_{2}} =
\sum_{k=0}^{l_{1}+l_{2}}x_{P}^{k}f_{k}(l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x})
\end{equation}
and $f_{k}$ is:
\begin{equation}
 \label{gaussian_product_rule_eq:18_0}
f_{k}(l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x}) =
\sum_{i=max(0,k-l_{2})}^{i=min(k,l_{1})}\overline{PA}_{x}^{l_{1}-i}
\overline{PB}_{x}^{l_{2}-k+i}\binom{l_{1}}{i}\binom{l_{2}}{k-i}
\end{equation}

The expression in the \ref{gaussian_product_rule_eq:18} actually only applies for the situation
that both $l_{1}$ and $l_{2}$ larger than zero. For the cases that $l_{1}$ or $l_{2}$ equal to zero,
we can directly use the binomial theorem to get the result. Hence the final result for the
$f_{k}$ could be expressed as:
\begin{align}
\label{gaussian_product_rule_eq:18}
 &f_{k}(l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x}) \nonumber \\
&=
\begin{cases}
\sum_{i=max(0,k-l_{2})}^{i=min(k,l_{1})}\overline{PA}_{x}^{l_{1}-i}
\overline{PB}_{x}^{l_{2}-k+i}\binom{l_{1}}{i}\binom{l_{2}}{k-i}
    & l_{1} > 0, l_{2} > 0 \\
\overline{PA}_{x}^{l_{1}-k}\binom{l_{1}}{k}
&  l_{1} > 0, l_{2} = 0 \\
\overline{PB}_{x}^{l_{2}-k}\binom{l_{2}}{k}
&  l_{1} = 0, l_{2} > 0 \\
1
&  l_{1} = 0, l_{2} = 0
\end{cases}
\end{align}

Based on this result, for two arbitrary Gaussian primitives product on different center;
we have the result as:
\begin{align}
&  x_{A}^{l_{1}}y_{A}^{m_{1}}z_{A}^{n_{1}}e^{-\alpha r_{A}^{2}}
   x_{B}^{l_{2}}y_{B}^{m_{2}}z_{B}^{n_{2}}e^{-\beta  r_{B}^{2}} \nonumber \\
=& \sum_{i=0}^{l_{1}+l_{2}}x_{P}^{i}f_{i}(l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x})
   \times \nonumber \\
 & \sum_{j=0}^{m_{1}+m_{2}}y_{P}^{j}f_{j}(m_{1},m_{2},\overline{PA}_{y},\overline{PB}_{y})
   \times \nonumber \\
 & \sum_{k=0}^{n_{1}+n_{2}}z_{P}^{k}f_{k}(n_{1},n_{2},\overline{PA}_{z},\overline{PB}_{z})
   \times \nonumber \\
 &  e^{-(\alpha+\beta)r_{P}^{2}} e^{-\frac{\alpha\beta}{\alpha+\beta}\overline{AB}^{2}}
   \Rightarrow \nonumber \\
 & =\sum_{i=0}^{l_{1}+l_{2}}\sum_{j=0}^{m_{1}+m_{2}}\sum_{k=0}^{n_{1}+n_{2}}
   x_{P}^{i}y_{P}^{j}z_{P}^{k}
   e^{-(\alpha+\beta)r_{P}^{2}} e^{-\frac{\alpha\beta}{\alpha+\beta}\overline{AB}^{2}}
   \times F_{ijk}
  \label{gaussian_product_rule_eq:19}
\end{align}
Where $F_{ijk}$ is:
\begin{multline}
  F_{ijk} = \\
            f_{i}(l_{1},l_{2},\overline{PA}_{x},\overline{PB}_{x})
            f_{j}(m_{1},m_{2},\overline{PA}_{y},\overline{PB}_{y})
            f_{k}(n_{1},n_{2},\overline{PA}_{z},\overline{PB}_{z})
 \label{gaussian_product_rule_eq:20}
\end{multline}

Finally we note that for the same center situation, things is much more easier:
\begin{align}
&  x_{A}^{l_{1}}y_{A}^{m_{1}}z_{A}^{n_{1}}e^{-\alpha r_{A}^{2}}
   x_{A}^{l_{2}}y_{A}^{m_{2}}z_{A}^{n_{2}}e^{-\beta  r_{A}^{2}} \nonumber \\
=& x_{A}^{l_{1}+l_{2}}y_{A}^{m_{1}+m_{2}}z_{A}^{n_{1}+n_{2}}e^{-(\alpha+\beta)r_{A}^{2}}
  \label{gaussian_product_rule_eq:21}
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Shell Pair Data}
%
%
%
%
The Gaussian Primitive Product Theorem plays an key role in quantum chemistry\cite{SFBoys1950}. This
theorem is the key to understand that why we introduce the Gaussian type functions into the quantum
chemistry; after all, the Slater type of function is more like the real wave function for atom system.
However, the integral for STO is too expensive to evaluate so that  we can use the linear combination
of Gaussian functions to imitate the Slater functions, then to simulate the wave functions for atom.
Such idea is the crucial point for building the basis sets which is generally used in quantum chemistry
package.

In quantum chemistry, the electron integral could be generally expressed as:
\begin{equation}
 \label{shell_pair_eq:1}
I = \sum_{i=1}^{K}\sum_{j=1}^{K}\sum_{k=1}^{K}\sum_{l=1}^{K}
\int \int \chi_{i}^{*}(r)\chi_{j}^{*}(r)f(r,r^{'})
\chi_{k}(r^{'})\chi_{l}(r^{'}) dr dr^{'}
\end{equation}
Here $\chi$ is the Gaussian primitive function with arbitrary angular momentum, and $f(r,r^{'})$ is the
electron operator for one or two electrons. Generally through the Gaussian Primitive Product Theorem,
we could firstly combine the $ \chi_{i}^{*}(r)\chi_{j}^{*}(r)$ together into a new Gaussian function,
so as for the $\chi_{k}(r^{'})\chi_{l}(r^{'})$. Therefore, the integral has been simplified into some
new form which only has two Gaussian functions.

Formally, we could designate the $ \chi_{i}^{*}(r)\chi_{j}^{*}(r)$ as ``shell pair'', which is
physically related to the electron density (when multiply with MO coefficients etc.):
\begin{align}
\label{shell_pair_eq:2}
 \chi_{i}^{*}(r)\chi_{j}^{*}(r) \Longrightarrow (ij| \nonumber \\
 \chi_{k}(r^{'})\chi_{l}(r^{'}) \Longrightarrow |kl)
\end{align}
Such concept is trivial physically, but could bring great benefit for designing the software.
Therefore, any analytical electron integrals we discuss later will be realized based on the shell pair
data.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Hermite Polynomials in Shell Pair Data}
%
%
%
%
In section \label{Gaussian_Primitive_Product_Theorem}, we have derived the shell pair data as:
\begin{equation}
\label{basic_shell_pair_data_form}
 |\chi_{A}\chi_{B}) =
\begin{cases}
 \sum_{i=0}^{l_{1}+l_{2}}\sum_{j=0}^{m_{1}+m_{2}}\sum_{k=0}^{n_{1}+n_{2}}
   x_{P}^{i}y_{P}^{j}z_{P}^{k}
   e^{-(\alpha+\beta)r_{P}^{2}} e^{-\frac{\alpha\beta}{\alpha+\beta}\overline{AB}^{2}}
   \times F_{ijk}  \\
 x_{A}^{l_{1}+l_{2}}y_{A}^{m_{1}+m_{2}}z_{A}^{n_{1}+n_{2}}e^{-(\alpha+\beta)r_{A}^{2}}
\end{cases}
\end{equation}
It turns out that the complexity behind the shell pair data is brought by the angular momentum part.
For some arbitrary angular momentum number, each combination will introduce three sums hence
for two electron integral at least six round of sums is needed. Therefore, it implies that the
angular momentum is the potential bottle neck for the integral evaluation.

Is there any way to avoid direct calculation of angular momentum part? Physically, the angular
momentum part for atom wave function is generated by the central field; which turns out to be
in form of $Y^{m}_{l}(\theta,\phi)$, and this is a set of orthogonal functions(see
\ref{Transformation_Cart_sphere} for more information). Therefore, it implies that we could also
express the angular momentum part into other set of orthogonal functions (here we may need some
transformation, which finally convert it back to the Cartesian form or spherical form of
basis set functions). The new form of basis set functions may bring us extra benefit in calculating
the integrals.

McMurchie and Davidson showed that\cite{MD} it's possible to use the
Hermite polynomials to achieve such transformation. Typically, they defined the
new angular momentum part in the Gaussian primitive functions as:
\begin{equation}
 \label{Shell_pair_data_further_eq:1}
\Lambda_{n}(\alpha, x_{p}) = e^{\alpha x_{p}^{2}} \frac{\partial^{n}}{\partial
P_{X}^{n}}\left( e^{-\alpha x_{p}^{2}} \right)
\end{equation}
Here $x_{p}$ is defined the same as in \ref{gaussian_product_rule_eq:10}, which
is $x_{p} = e_{x} - P_{x}$. Now with the transformation that
\begin{equation}
 \label{Shell_pair_data_further_eq:2}
\frac{\partial}{\partial P_{x}} =
\frac{\partial}{\partial \sqrt{\alpha}x_{p}}\frac{\partial \sqrt{\alpha}x_{p}
}{\partial P_{x}} = -\sqrt{\alpha} \frac{\partial}{\partial \sqrt{\alpha}x_{p}}
\end{equation}
we can have:
\begin{equation}
 \label{Shell_pair_data_further_eq:3}
\Lambda_{n}(\alpha, x_{p}) = e^{\alpha x_{p}^{2}} (-\sqrt{\alpha})^{n}
 \frac{\partial^{n}}{\partial (\sqrt{\alpha}x_{p})^{n}}\left( e^{-\alpha
x_{p}^{2}} \right) \Rightarrow \Lambda_{n}(\alpha, x_{p}) =
\sqrt{\alpha}^{n}H_{n}(\sqrt{\alpha}x_{p})
\end{equation}
Now the $\Lambda$ is directly associated with the Hermite polynomials.

Furthermore, it's shown that:
\begin{equation}
 \label{Shell_pair_data_further_eq:4}
(x_{P} +\overline{PA}_{x})^{l_{1}}(x_{P} + \overline{PB}_{x})^{l_{2}}
= \sum^{l_{1}+l_{2}}_{k=0}d^{l_{1},l_{2}}_{k}\Lambda_{k}(\alpha, x_{p})
\end{equation}
Now the key to the problem is that how can we derive the $d$ in the
\ref{Shell_pair_data_further_eq:4}.

Through the recursive relation for Hermite polynomials in
\ref{hermite_definition_eq:6}:
\begin{equation}
\label{Shell_pair_data_further_eq:5}
 2(\alpha^{\frac{1}{2}}x_{p})H_{n}(\alpha^{\frac{1}{2}}x_{p}) =
2nH_{n-1}(\alpha^{\frac{1}{2}}x_{p}) + H_{n+1}(\alpha^{\frac{1}{2}}x_{p})
\end{equation}
Now multiplying with $\alpha^{\frac{n-1}{2}}$ we can get:
\begin{equation}
 \label{Shell_pair_data_further_eq:6}
2x_{p}\alpha^{\frac{n}{2}}H_{n}(\alpha^{\frac{1}{2}}x_{p}) =
2n\alpha^{\frac{n-1}{2}}H_{n-1}(\alpha^{\frac{1}{2}}x_{p}) +
\alpha^{\frac{n-1}{2}}H_{n+1}(\alpha^{\frac{1}{2}}x_{p})
\end{equation}
Then we have:
\begin{equation}
 \label{Shell_pair_data_further_eq:7}
2x_{p}\Lambda_{n}(\alpha,x_{p}) = 2n\Lambda_{n-1}(\alpha,x_{p}) +
\alpha^{-1}\Lambda_{n+1}(\alpha,x_{p})
\end{equation}

Now let's set $x_{p} = e_{x} - P_{x} = e_{x} - A_{x} + A_{x} - P_{x} =
x_{A} - \overline{PA}_{x} $, then we have:
\begin{equation}
\label{Shell_pair_data_further_eq:8}
2x_{A}\Lambda_{n}(\alpha,x_{p}) = 2n\Lambda_{n-1}(\alpha,x_{p}) +
2\overline{PA}_{x}\Lambda_{n}(\alpha,x_{p}) +
\alpha^{-1}\Lambda_{n+1}(\alpha,x_{p})
\end{equation}

Now let's combine the \ref{Shell_pair_data_further_eq:8} with
\ref{Shell_pair_data_further_eq:4}, we can have that:
\begin{equation}
 \label{Shell_pair_data_further_eq:9}
\begin{split}
 (x_{A})^{l_{1}}(x_{B})^{l_{2}}
&= \sum^{l_{1}+l_{2}}_{n=0}d^{l_{1},l_{2}}_{n}\Lambda_{n}(\alpha, x_{p}) \Rightarrow \\
(x_{A})^{l_{1}+1}(x_{B})^{l_{2}}
&= \sum^{l_{1}+l_{2}}_{n=0}x_{A}d^{l_{1},l_{2}}_{n}\Lambda_{n}(\alpha, x_{p}) \\
&= \sum^{l_{1}+l_{2}}_{n=0}d^{l_{1},l_{2}}_{n}\left[ n\Lambda_{n-1}(\alpha,x_{p}) +
\overline{PA}_{x}\Lambda_{n}(\alpha,x_{p}) +
\frac{1}{2\alpha}\Lambda_{n+1}(\alpha,x_{p}) \right] \\
&= \sum^{l_{1}+l_{2}}_{n=0}\left(
(n+1)d^{l_{1},l_{2}}_{n+1}             +
\overline{PA}_{x}d^{l_{1},l_{2}}_{n}   +
\frac{1}{2\alpha}d^{l_{1},l_{2}}_{n-1}
 \right)\Lambda_{n}(\alpha,x_{p})
\end{split}
\end{equation}

On the other hand, for the $(x_{A})^{l_{1}+1}(x_{B})^{l_{2}}$ we could expand it according to
the definition:
\begin{equation}
 \label{Shell_pair_data_further_eq:10}
(x_{A})^{l_{1}+1}(x_{B})^{l_{2}}  =
\sum^{l_{1}+1+l_{2}}_{n=0}d^{l_{1}+1,l_{2}}_{n}\Lambda_{n}(\alpha, x_{p})
\end{equation}
Therefore, we have:
\begin{equation}
 \label{Shell_pair_data_further_eq:11}
\sum^{l_{1}+1+l_{2}}_{n=0}d^{l_{1}+1,l_{2}}_{n}\Lambda_{n}(\alpha, x_{p}) =
\sum^{l_{1}+l_{2}}_{n=0}\left(
(n+1)d^{l_{1},l_{2}}_{n+1}             +
\overline{PA}_{x}d^{l_{1},l_{2}}_{n}   +
\frac{1}{2\alpha}d^{l_{1},l_{2}}_{n-1}
 \right)\Lambda_{n}(\alpha,x_{p})
\end{equation}
By applying the orthogonal relation for the Hermite polynomials, that means to multiply
$H_{n}(x)e^{x^{2}}$ to each side of above equation and integrate it, we could have the
recursive relation for the $d$:
\begin{equation}
 \label{Shell_pair_data_further_eq:12}
d^{l_{1}+1,l_{2}}_{n} = (n+1)d^{l_{1},l_{2}}_{n+1}             +
\overline{PA}_{x}d^{l_{1},l_{2}}_{n}   +
\frac{1}{2\alpha}d^{l_{1},l_{2}}_{n-1}
\end{equation}
We note that this only applies for the situation of $n\geq 1$. On the other hand, we note
that in the \ref{Shell_pair_data_further_eq:8} we could also expand the $x_{p}$ as:
\begin{equation}
 x_{p} = e_{x} - P_{x} = e_{x} - B_{x} + B_{x} - P_{x} =
x_{B} - \overline{PB}_{x}
\end{equation}
Therefore by same procedure we can have:
\begin{equation}
 \label{Shell_pair_data_further_eq:13}
d^{l_{1},l_{2}+1}_{n} = (n+1)d^{l_{1},l_{2}}_{n+1}             +
\overline{PB}_{x}d^{l_{1},l_{2}}_{n}   +
\frac{1}{2\alpha}d^{l_{1},l_{2}}_{n-1}
\end{equation}

The importance for the \ref{Shell_pair_data_further_eq:12} and \ref{Shell_pair_data_further_eq:13},
is that it indicates the integral could be evaluated through some ``recursive'' method. By starting
from the S type integral, we could gradually increase the order of angular momentums so that to
get integrals fro an arbitrary order of angular momentum.


\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}

\title{Chapter 2\\ Basic Topology}
\author{solutions by Hikari}
\date{August 2021}

\begin{document}

\newcommand{\V}{\mathbf}

\maketitle

\paragraph{1.}
"$x\in\phi $" is always false, so "$x\in\phi \Rightarrow x\in S$" in always true, by mathematical logic.

\paragraph{2.}
Let $S$ be the set of equations of the form $a_0z^n+a_1z^{n-1}+\cdots+a_{n-1}z+a_n=0$ with $a_0,\cdots,a_n$ being integers. Let $A_N$ be the set of equations in $S$ such that $n+|a_0|+|a_1|+\cdots+|a_n|=N$ with $N$ being positive integer. By \textit{Hint}, $A_N$ is finite (it has less than $\frac{(N+n+1)!}{N!(n+1)!}2^{n+1}$ elements). It is obvious that
\[
S=\bigcup_{N=1}^\infty A_N
\]
Because $A_N$ is finite, $S$ is countable by Theorem 2.12. Let $\alpha$ be an equation is $S$, and let $B_\alpha$ be the set of complex numbers satisfying $\alpha$. By fundamental theorem of algebra, the roots of $\alpha$ are countable, so $B_\alpha$ is countable. So the set
\[
T=\bigcup_{\alpha\in S}B_\alpha
\]
is countable by Corollary of Theorem 2.12, and the set of algebraic numbers is a subset of $T$, so the set of algebraic numbers is countable.

\paragraph{3.}
If every real number is algebraic, then the set of real numbers is a subset of the set of algebraic numbers and is therefore at most countable by Exercise 2, which contradicts the fact that the set of real numbers is uncountable (Corollary of Theorem 2.43).

\paragraph{4.}
Not countable. If the set of irrational numbers is countable, then because the set of rational numbers is also countable, the set of real numbers, which is the union of rational and irrational numbers, will be countable, contradicting to the fact that the set of real numbers is uncountable.

\paragraph{5.}
Let $A=\{\frac{1}{n}|n\in\mathbb{N}\}$, $B=\{1+\frac{1}{n}|n\in\mathbb{N}\}$, $C=\{2+\frac{1}{n}|n\in\mathbb{N}\}$. Then the set $A\cup B\cup C$ is bounded and has only three limit points: $0,1,2$.

\paragraph{6.}
Let $p$ be a limit point of $E'$, then every neighborhood of $p$, $\{x|d(x,p)<r_1\}$ contains a $q\in E'$, which means $q$ is a limit point of $E$, so every neighborhood of $q$, $\{x|d(x,q)<r_2\}$ contains a $s\in E$.

Let $r_2=r_1-d(q,p)$, then
\[
d(s,p)\leq d(s,q)+d(q,p)<r_2+d(q,p)=r_1
\]
which means $s$ is in the neighboorhood of $p$. So every neighborhood of $p$ contains a point of $E$, which means $p$ is a limit point of $E$, so $p\in E'$. So every limit point of $E'$ belongs to $E'$, which means $E'$ is closed.
\medskip

If $a$ is a limit point of $\bar{E}$, then every neighborhood of $a$ contains a point of $E$ or $E'$, and from above we know that the later also implies the neighborhood contains a point of $E$, so $a$ is a limit point of $E$. So every limit point of $\bar{E}$ is a limit point of $E$.

If $b$ is a limit point of $E$, so every neighborhood of $b$ contains a point of $E$, then because $E\subset\bar{E}$, the neighborhood contains a point of $\bar{E}$, which means $b$ is a limit point of $\bar{E}$. So every limit point of $E$ is a limit point of $\bar{E}$.

From the above two statements we know $E$ and $\bar{E}$ have the same limit points.
\medskip

$E$ and $E'$ do not necessary have the same limit points. Let $E$ be $\{\frac{1}{n}|n\in\mathbb{N}\}$, then $0$ is a limit point of $E$, but that also means $E'$ has only $0$ as its element, so $E'$ has no limit point.

\paragraph{7.}
(a) $B_n\supset A_i$, so $\bar{B}_n\supset A_i$. By Theorem 2.27(a) we know $\bar{B}_n$ is closed, so by Theorem 2.27(c) we have $\bar{B}_n\supset\bar{A}_i$. Therefore $\bar{B}_n\supset\bigcup_{i=1}^n\bar{A}_i$.

$B_n\subset\bigcup_{i=1}^n\bar{A}_i$. Because $\bar{A}_i$ is closed, by Theorem 2.24(d) we know $\bigcup_{i=1}^n\bar{A}_i$ is closed. So by Theorem 2.27(c) we have $\bar{B}_n\subset\bigcup_{i=1}^n\bar{A}_i$.

The above two statements implies $\bar{B}_n=\bigcup_{i=1}^n\bar{A}_i$.
\medskip

(b) The first result in (a) still holds, but the second does not because when $n$ becomes infinity, Theorem 2.24(d) no longer applies. So we have only $\bar{B}_n\supset\bigcup_{i=1}^\infty\bar{A}_i$.

Let $A_n=\{x|x>\frac{1}{n}\}$. Then $B=\{x|x>0\}$, $\bar{B}=\{x|x\geq0\}$, $\bar{A}_n=\{x|x\geq\frac{1}{n}\}$, $\bigcup_{n=1}^\infty\bar{A}_n=\{x|x>0\}$. So $0$ is a element of $\bar{B}_n$ but not $\bigcup_{i=1}^\infty\bar{A}_i$.

\paragraph{8.}
Every point $p$ of an open set $E$ is an interior point of $E$, which means there is a neighborhood $\{x:|\V{x}-\V{p}|<r_1\}\subset E$. For every neighborhood of $p$, $N_r(p)=\{x:|\V{x}-\V{p}|<r_2\}$, let $y$ be a point such that $0<|\V{y}-\V{p}|<\min(r_1,r_2)$, then $y\neq p$ and $y$ is in both $E$ and $N_r(p)$. So every neighborhood of $p$ contains a point of $E$ , which means $p$ is a limit point of $E$.

The statement does not hold for closed set when the closed set contains isolated points, for example $E=\{(0,0)\}$.

\paragraph{9.}
(a) Let $p\in E^\circ$, which means $p$ is an interior point of $E$, so there is a neighborhood $N_p$ such that $N_p\subset E$. $N_p$ is an open set, so for every $q\in N_p$, there is a neighborhood $N_q$ such that $N_q\subset N_p$, and therefore $N_q\subset E$. The fact that $q$ has a neighborhood $N_q\subset E$ implies $q$ is an interior point of $E$, or $q\in E^\circ$. The statement "$q\in N_p\Rightarrow q\in E^\circ$" implies $N_p\subset E^\circ$, so for every $p\in E^\circ$ there is a neighborhood $N_p\subset E^\circ$, which means $E^\circ$ is open.
\medskip

(b) If $E$ is open, then every point in $E$ is an interior point of $E$ and therefore belongs to $E^\circ$, so $E\subset E^\circ$. It is obvious that $E^\circ\subset E$, so $E=E^\circ$.

If $E^\circ=E$, then because $E^\circ$ is open, $E$ is open.
\medskip

(c) If $G$ is open, then for every $p\in G$ there is a neighborhood $N_p\subset G$, and therefore $N_p\subset E$. So $p$ is an interior point of $E$, which means $p\in E^\circ$. The statement "$ p\in G\Rightarrow p\in E^\circ$" implies $G\subset E^\circ$.
\medskip

(d)
For every $p\in(E^\circ)^c$, $p\not\in E^\circ$, so $p$ is not an interior point of $E$, which means every neighborhood of $p$ contains an element not in $E$, which means in $E^c$. Then $p$ is either an element of $E^c$, or a limit point of $E^c$, in either cases $p\in\overline{(E^c)}$. So $(E^\circ)^c\subset\overline{(E^c)}$.

For every $p\in\overline{(E^c)}$, either $p\in E^c$, or $p$ is a limit point of $E^c$. For the former case, because $E^\circ\subset E$, $(E^\circ)^c\supset E^c$, so $q\in E^c\subset (E^\circ)^c$. For the later case, every neighborhood of $p$ contains an element of $E^c$, so $p$ cannot be an interior point of $E$, $p\not\in E^\circ$, $p\in(E^\circ)^c$. In either cases $p\in(E^\circ)^c$, so $\overline{(E^c)}\subset(E^\circ)^c$.

Combining the above two statements we have $(E^\circ)^c=\overline{(E^c)}$.
\medskip

(e) No. Let $E=(-1,0)\cup(0,1)$. Then $\bar{E}=[-1,1]$, $E^\circ=(-1,0)\cup(0,1)$, $(\bar{E})^\circ=(-1,1)$, so $E^\circ\neq(\bar{E})^\circ.$
\medskip

(f) No. Let $E$ contains only a single point, then $\bar{E}$ also contains that point. But $E^\circ$ is empty, and therefore $\overline{(E^\circ)}$ is empty. So $\overline{E}\neq\overline{(E^\circ)}$.

\paragraph{10.}
We verify the three definitions of metric.

(a) $d(p,q)=1>0$ if $p\neq q$; $d(p,p)=0$

(b) $d(p,q)=d(q,p)=1$ when $p\neq q$; $d(p,q)=d(q,p)=0$ when $p=q$.

(c) If $p=q$, then $d(p,q)=0\leq d(p,r)+d(r,q)$.

\quad\; If $p\neq q$, then either $r\neq p$ or $r\neq q$ or both, so $d(p,r)+d(r,q)\geq1=d(p,q)$.
\medskip

For every subset $E$ in $X$, let $p$ be any point of $E$, then the neighborhood $N_p$ of $p$ with radius $r<1$ will contain only $p$, so $N_p\subset E$, and therefore $p$ is an interior point of $E$, which means $E$ is open. So every subset in $X$ is open.

For every subset of $E$ in $X$, because there is no limit point in $X$ (the neighborhood of $p$ with radius $r<1$ contains only $p$), the statement "every limit point of $E$ is a point of $E$ " is always true, so $E$ is closed. So every subset in $X$ is closed.

For every finite subset $E$ in $X$, let $\{G_\alpha\}$ be an open cover of $E$. Choose one $G_\alpha$ for each element that contains that element, then the resulting subcover is finite and contains E, so $E$ is compact. For every infinite subset $E'$ in $X$, let $G_\alpha$ contains only $\alpha$, $\alpha\in E'$, then $\bigcup_\alpha G_\alpha$ is an open cover of $E'$, while any finite subcover contains only finite elements of $E'$ and therefore cannot contains $E'$, so $E'$ is not compact. In conclusion, a subset in $X$ is compact if and only if it is finite.

\paragraph{11.}
\quad
\\
\noindent
$d_1$: $d(0,2)=2^2>1^2+1^2=d(0,1)+d(1,2)$, so Definition 2.15(c) is not satisfied and $d_1$ is not a metric.
\medskip

\noindent
$d_2$: Definition (a) and (b) can be easily verified. For Definition (c),
\[|p-q|\leq|p-r|+|r-q|\leq|p-r|+|r-q|+2\sqrt{|p-r||r-q|}=(\sqrt{|p-r|}+\sqrt{|r-q|})^2\]
\[
d(p,q)=\sqrt{|p-q|}\leq\sqrt{|p-q|}+\sqrt{|r-q|}=d(p,r)+d(r,q)
\]
so Definition (c) is satisfied, and $d_2$ is a metric.
\medskip

\noindent
$d_3$: $d(-1,1)=|(-1)^2-1^2|=0$ while $-1\neq1$, so Definition  (a) is not satisfied and $d_3$ is not a metric.
\medskip

\noindent
$d_4$: $d(1,1)=|1-2|=1\neq0$, so Definition (a) is not satisfied and $d_4$ is not a metric.
\medskip

\noindent
$d_5$: Definition (a) and (b) can be easily verified. For Definition (c), $|p-q|\leq|p-r|+|r-q|$, so
\[
d(p,q)=
\frac{|p-q|}{1+|p-q|}\leq\frac{(|p-r|+|r-q|)}{1+(|p-r|+|r-q|)}\leq\frac{|p-r|}{1+|p-r|}+\frac{|r-q|}{1+|r-q|}=d(p,r)+d(r,q)
\]
so Definition (c) is satisfied, and $d_5$ is a metric.

\paragraph{12.}
If an open cover $\bigcup_\alpha G_\alpha$ contains $K$, then there is an open set $G_0$ contains $0$, which means $0$ is an interior point of $G_0$, so there is a neighborhood $N_r(0)=\{x|-r<x<r\}$ be included in $G_0$. According to the archimedean property of $R$, there is a $N$ such that $Nr>1$, and if $n>N$, $\frac{1}{n}$ is included in $N_r(0)$ and therefore included in $G_0$ beacause $\frac{1}{n}<\frac{1}{N}<r$. So take the union of $G_0$ and the other $N$ open sets that contain $1,\frac{1}{2},\cdots,\frac{1}{N}$, then we formed a finite subcover of $K$, so $K$ is compact.

\paragraph{13.}
Let $K_i$ consists of $\frac{1}{2^i}$ and $\frac{1}{2^i}+\frac{1}{n}$, $n=2^{i+1},2^{i+1}+1,\cdots$, so all the elements are in the range $[\frac{1}{2^i},\frac{1}{2^i}+\frac{1}{2^{i+1}}]$, and the only limit point is $\frac{1}{2^i}$. Note that the range of different $K_i$ do not overlap.

Let $K$ be the union of $0$ and all the $K_i$, for $i=1,2,\cdots$. Note that all the elements are in the range $[0,1]$, so $K$ is bounded. We want to find all the limit points of $K$ to prove that it is closed.
\medskip

For $x<0$, $x$ is not a limit point because the neighborhood with radius $r<|x|$ does not contain an element of $K$.

$x=0$ is a limit point of $K$ because for every neighborhood with radius $r$, let $N>\log_2\frac{1}{r}$, then $\frac{1}{2^N}<r$, so every neighborhood contains an element of $K$.

For $0<x<1$, either $x$ is in the range of $K_i$, $[\frac{1}{2^i},\frac{1}{2^i}+\frac{1}{2^{i+1}}]$, or in the interval between $K_i$ and $K_{i-1}$, which is $(\frac{1}{2^i}+\frac{1}{2^{i+1}},\frac{1}{2^{i-1}})$. For the former, $x$ is a limit point of $K$ if and only if it is a limit point of $K_i$, so the only possible limit point is $\frac{1}{2^i}$. For the later, $x$ is not a limit point of $K$ because the neighborhood with radius $r<\min\left(|x-\frac{1}{2^i}-\frac{1}{2^{i+1}}|,|x-\frac{1}{2^{i-1}}|\right)$ does not contain an element of $K$.

For $x\geq1$, $x$ is not a limit point because the neighborhood with radius $r<\frac{1}{4}$ does not contain an element of $K$.

So the limit points of $K$ are $0$ and $\frac{1}{2^i}$, $i=1,2,\cdots$, which are all in $K$, so $K$ is closed.
\medskip

By Theorem 2.41, $K$ being closed and bounded implies $K$ is compact, and the limit points $0,\frac{1}{2^1},\frac{1}{2^2},\cdots$ form a countable set, so the $K$ we constructed satisfy the condition.

\paragraph{14.}
Let $G_n=(\frac{1}{n},1)$, then $\bigcup_{n=1}^\infty G_n$ is a open cover of $(0,1)$ because for every $0<x<1$, $x$ is included in $G_N$ if $Nx>1$. Let $\bigcup_{i=1}^kG_{n_i}\;(n_1<n_2\cdots<n_k)$ be a finite subcover of the open cover, then the element $0<x<\frac{1}{n_k}$ is not included in this subcover, a contradiction. So $\bigcup_{n=1}^\infty G_n$ is an open cover of $(0,1)$ but has no finite subcover.

\paragraph{15.}
\quad

For the "closed" case, let $K_n=\{x|x\geq n\}$, then $K_n$ is closed and every finite subcollection of $\{K_n\}$ is nonempty, but $\bigcap_1^\infty K_n$ is empty because for every $x$, let $N>x$, then $x$ is not included in $K_N$.
\medskip

For the "bounded" case, let $K_n=\{x|0<x<\frac{1}{n}\}$, then $K_n$ is bounded and every finite subcollection of $\{K_n\}$ is nonempty, but $\bigcap_1^\infty K_n$ is empty because for every $x$, let $Nx>1$, then $x$ is not included in $K_N$.

\paragraph{16.}
$E^c=\{p\,|\,p^2\leq2\;or\;p^2\geq3\}=\{p\,|\,p^2<2\;or\;p^2>3\}$ because there is no rational number whose square is $2$ or $3$. Let $x\in E^c$, if $x^2<2$, by Theorem 1.20(b) there is rational number $y$ such that $x<y<\sqrt{2}$, so the neighborhood $N_r(x)$ with $r=y-x$ is included in $E^c$, which means $x$ is an interior point of $E^c$. Similarly, if $x^2>3$, there is a rational number $y$ such that $\sqrt{3}<y<x$, so the neighborhood $N_r(x)$ with $r=x-y$ is included in $E^c$, which means $x$ is an interior point of $E^c$. So every $x\in E^c$ is an interior point of $E^c$, which means $E^c$ is an open set, and therefore $E$ is an closed set.

It is obvious that $E$ is bounded.

Let $G_n=\{p\,|\,2+\frac{1}{n}<p^2<3\}$, then $\bigcup_{n=1}^\infty G_n$ is an open cover of $E$ because $G_n$ is open (as $E$), and for every $x\in E$, which means $x^2>2$, there is a positive real number $\delta$ such that $x^2>2+\delta$; let $N\delta>1$, then $x^2>2+\delta>2+\frac{1}{N}$, so $x$ is included in $G_N$. For every finite subcover $\bigcup_{i=1}^kG_{n_i}\;(n_1<n_2<\cdots<n_k)$, the rational $x$ in $E$ that satisfy $\sqrt{2}<x<\sqrt{2+\frac{1}{n_k}}$ will not be included in any $G_{n_i}$, so $\bigcup_{i=1}^kG_{n_i}$ cannot be a finite subcover of $E$. Therefore, $E$ is not compact.

For $x\in E$, $2<x^2<3$. There exists $y_1,y_2$ such that $\sqrt{2}<y_1<x<y_2<\sqrt{3}$, so the neighborhood $N_r(x)$ with $r=\min(|x-y_1|,|x-y_2|)$ is included in $E$, which means $x$ is an interior point of $E$, so $E$ is open.

\paragraph{17.}
\quad

\textit{countable}: If $E$ is countable, let its elements be enumerated as $s_1,s_2,\cdots$. Construct a sequence $s$ by making the $n^{th}$ digit of $s$ be $4$ if the $n^{th}$ digit of $s_n$ is $7$, and the $n^{th}$ digit of $s$ be $7$ if the $n^{th}$ digit of $s_n$ is $4$. Then $s$ is different with every $s_i$, but $s$ is a element of $E$, a contradiction. So $E$ is uncountable.

\textit{dense}: $E$ is not dense in $[0,1]$ because there are many points in $[0,1]$ that are neither a point or a limit point of $E$, for example, $0.5$\,.

\textit{compact}: It is obvious that $E$ is bounded. If there is a limit point of $E$ that is not an element of $E$, whose $n^{th}$ digit is neither $4$ nor $7$, consider the neighborhood with radius $r=10^{-(n+1)}$, then the neighborhood cannot contain any element of $E$ because the $n^{th}$ and $(n+1)^{th}$ digit cannot be $44,47,74$ or $77$, a contradiction. So every limit point of $E$ belongs to $E$, which means $E$ is closed. Being bounded and closed implies being compact in $R^1$ (Theorem 2.41).

\textit{perfect}: We have proved that $E$ is closed. If there is a element $x$ of $E$ that is not a limit point of $E$, which means there is a neighborhood $N_r(x)$ contains no element of $E$, let $N$ be large enough so $10^{-N}<r$, and let $y$ be an element of $E$ that is the same with $x$ at the first $N$ digit but different at the $(N+1)^{th}$ digit, then $|y-x|<10^{-N}<r$, so $y\in E$ is in $N_r(x)$, a contradiction. So every element of $E$ is a limit point of $E$. Together with the fact that $E$ is closed, we proved that $E$ is perfect.

\paragraph{18.}
Let $E_0=[a_0,b_0]$, $a_0,b_0$ are irrational. Enumerate all the rational number in $[a_0,b_0]$ as $r_1,r_2,\cdots$. For $a_0<r_1<b_0$, found irrational number $a_1,b_1$ that such that $a_0<b_1<r_1<a_1<b_0$, and remove $(b_1,a_1)$ to get $E_1=[a_0,b_1]\cup[a_1,b_0]$. Continue in this way to construct $E_2,E_3,\cdots$ by removing segments around $r_2,r_3,\cdots$ with irrational numbers being the end points, then $E_1\supset E_2\supset E_3\supset\cdots$. Let $P=\bigcap_{n=1}^\infty E_n$. It is obvious that $E_n$ is compact, so by Theorem 2.36, $P$ is not empty. From the construction, $P$ contains no rational number.

It is obvious that $P$ is closed. If $x\in P$, let $S$ be a neighborhood of $x$. Let $I_n$ be that interval of $E_n$ which contains x. Choose $n$ large enough so that $I_n\subset S$ (It is possible because the length of $I_n$ can be arbitrary small, due to the fact that rational numbers are dense). Let $x_n$ be an endpoint of $I_n$, such that $x_n\neq x$. It follows from the construction of $P$ that $x_n\in P$. Hence $x$ is a limit point of $P$, and $P$ is perfect. Therefore, $P$ is not empty, perfect and contains no rational number, which satisfies the conditions.

\paragraph{19.}
(a) $A$ and $B$ being disjoint implies $A\cap B=\phi$. From Theorem 2.27, because $A$ and $B$ are closed, $A=\bar{A}$ and $B=\bar{B}$. So $A\cap\bar{B}=\bar{A}\cap B=A\cap B=\phi$,         which means $A$ and $B$ are separated.
\medskip

(b) If $A\cap B=\phi$ but $A\cap\bar{B}\neq\phi$, then there is a limit point $x$ of $B$ being included in $A$. Because $A$ is open, there is a neighborhood $N_r(x)\subset A$. But because $x$ is also a limit point of $B$, there is an element of $B$ contained in $N_r(x)$, and therefore contained in $A$. So $A$ and $B$ have a common element, a contradiction. So $A\cap\bar{B}=\phi$, similarly $\bar{A}\cap B=\phi$, so $A$ and $B$ are separated.
\medskip

(c) It is obvious that $A$ and $B$ are disjoint open sets, so by (b), $A$ and $B$ are separated.
\medskip

(d) Let $E$ be a connected metric space with at least two points. Assume $E$ is countable. Find two points $a$ and $b$. The set of real number between $0$ and $d(a,b)$ is uncountable, but the set of distances between $a$ and other elements are countable, so there exist a $\delta$ such that $0<\delta<d(a,b)$ and $\delta$ is not equal to any distance between $a$ and other elements. So $E=\{x|d(a,x)<\delta\}\cup\{x|d(a,x)>\delta\}$, which means $E$ is not connected by (c), a contradiction. So $E$ must be uncountable.

\paragraph{20.}
Let $\bar{E}$ be a closure of a connected set $E$. Assume $\bar{E}$ is not connected, so there are two nonempty sets $A$ and $B$ such that $\bar{E}=A\cup B$ and $\bar{A}\cap B=A\cap\bar{B}=\phi$. Note that
\[E=\bar{E}\cap E=(A\cup B)\cap E=(A\cap E)\cup(B\cap E)\]

If $A\cap E=\phi$, then $A\subset E'$ and $E\subset B$, so $A\subset E'\subset\bar{E}\subset\bar{B}$, which means $A\cap\bar{B}\neq\phi$, a contradiction. So $A\cap E\neq\phi$, and similarly $B\cap E\neq\phi$.
\smallskip

$A\cap E\subset A$,\; $\overline{(A\cap E)}\subset\overline{A}$,\; $B\cap E\subset B$,\; $\overline{(B\cap E)}\subset\overline{B}$. So $\overline{(A\cap E)}\cap(B\cap E)\subset\overline{A}\cap B=\phi$, and $(A\cap E)\cap\overline{(B\cap E)}\subset A\cap\overline{B}=\phi$, which means $A\cap E$ and $B\cap E$ are two nonempty separated sets, so $E$, being the union of them, is not connected, a contradiction. So $\bar{E}$ must be connected.
\medskip

The interior of a connected set can be not connected. Consider a set $E$ in $R^2:$
\[
E=\{\V{x}:|\V{x}-(-2,0)|<1\}\cup\{\V{x}:|\V{x}-(2,0)|<1\}\cup\{\V{x}:\V{x}=(k,0),-2<k<2\}
\]
which means $E$ consists of two balls and a line connecting them. It is obvious that $E$ is connected, but its interior, being $\{\V{x}:|\V{x}-(-2,0)|<1\}\cup\{\V{x}:|\V{x}-(2,0)|<1\}$, is not connected.

\paragraph{21.}
(a) If $x\in A_0'$, so $x$ is a limit point of $A_0$, then every neighborhood $N_{r_0}(x)$ contains a point $y\neq x$ such that $y\in A_0$. Consider a neighborhood of $\V{p}(x)$ with radius $r$. Let $r_0=\frac{r}{|\V{a}|+|\V{b}|}$, then there is a $y\in A_0$ such that $|y-x|<r_0=\frac{r}{|\V{a}|+|\V{b}|}$. Then $|\V{p}(y)-\V{p}(x)|=|-(y-x)\V{a}+(y-x)\V{b}|\leq|y-x|(|\V{a}|+|\V{b}|)<r$, so $\V{p}(y)\in A$ is in the neighborhood of $P(x)$, which means $\V{p}(x)$ is a limit point of $A$. Therefore, if $x\in A_0'$, then $\V{p}(x)\in A'$. It implies that if $x\in\bar{A}_0$, then $\V{p}(x)\in\bar{A}$. Similarly, if $x\in\bar{B}_0$, then $\V{p}(x)\in\bar{B}$.

$A$ and $B$ are separated, so $\bar{A}\cap B=A\cap\bar{B}=\phi$. If $x\in B_0$, $\V{p}(x)\in B$, then $\V{p}(x)\not\in \bar{A}$, so $x\not\in \bar{A}_0$. It implies $\bar{A}_0\cap B_0=\phi$. Similarly, $A_0\cap\bar{B}_0=\phi$. So $A_0$ and $B_0$ are separated.
\medskip

(b)
Let $(0,1)=I$. $(A_0\cup B_0)\cap I=(A_0\cap I)\cup(B_0\cap I)\subset I$. Because $A_0$ and $B_0$ are separated, so $A_0\cap I$ and $B_0\cap I$ are separated, but $I=(0,1)$ is connected, so $(A_0\cup B_0)\cap I$ is a proper subset of $I$. So there must exist a $t_0\in(0,1)$ but $t_0\not\in A_0\cup B_0$ , which means $\V{p}(t_0)\not\in A\cup B$.
\medskip

(c) If a subset $E$ of $R^k$ is not connected, then $E$ is the union of two nonempty separated sets $A$ and $B$. Let $\V{a}\in A\in E$, $\V{b}\in B\in E$, then by (b) there is a $t_0\in(0,1)$ such that $(1-t)\V{a}+t\V{b}\not\in A\cup B=E$. However, if $E$ is convex, then whenever $\V{a}\in E$, $\V{b}\in E$ and $0<t<1$, we must have $(1-t)\V{a}+t\V{b}\in E$, which means that $E$ is connected.

\paragraph{22.}
Consider the set of points which have only rational coordinates, $Q^k$. Because the set of rational numbers is countable, so by Theorem 2.13 we knows $Q^k$ is countable. Consider any point $\V{x}=(x_1,x_2,\cdots,x_k)\in R^k$, and consider a neighborhood of $\V{x}$ with radius $r$. Find rational numbers $a_i$ such that $x_i-\frac{r}{\sqrt{k}}<a_i<x_i+\frac{r}{\sqrt{k}},\;i=1,2,\cdots,k$ (They exist by Theorem 1.20(b)). Then $|\V{a}-\V{x}|=\sqrt{\sum_k(a_i -x_i)^2}<r$, so $\V{a}\in Q^k$ is in the neighborhood of $\V{x}$, which means $\V{x}$ is a limit point of $Q^k$, so $Q^k$ is dense in $R^k$. Therefore, $Q^k$ is a countable dense subset of $R^k$, which means $R^k$ is separable.

\paragraph{23.}
Let $X$ be a separable metric space, and let $C$ be a countable dense subset of $X$. Let $\mathcal{B}$ be the collection of all neighborhoods centered at some point of $C$ with rational radius, which means
\[
\mathcal{B}=\{N_r(x):r\in Q,\;x\in C \}
\]
$Q$ and $C$ are countable, so $\mathcal{B}$ is countable by Corollary of Theorem 2.12.

If $G$ is an open set in $X$ and $x\in G$, then there is a neighborhood $N_{\varepsilon}(x)\subset G$. Let $h$ be a rational number such that $0<h<\frac{\varepsilon}{2}$ (it exists by Theorem 1.20 (b)). $C$ is dense in $X$, so $x\in C$ or $x$ is a limit point of $C$, in either cases there is a $q\in C$ such that $q\in N_h(x)$. So $x\in N_h(q)$ (because $d(x,q)<h$), and $N_h(q)\subset N_\varepsilon(x)\subset G$ (because if $y\in N_h(q)$, then $d(y,x)\leq d(y,q)+d(q,x)<h+h=2h<\varepsilon$). Also note that $N_h(q)\in\mathcal{B}$ (because $h\in Q$ and $q\in C$).

Therefore, for every $x\in X$ and every open set $G\subset X$ such that $x\in G$, we have $N_h(q)\in\mathcal{B}$ such that $x\in N_h(q)\subset G$, so $\mathcal{B}$ is a countable base of $X$. So every separable metric space has a countable base.

\paragraph{24.}
If the process of choosing $x_{j+1}$ from $x_1,\cdots,x_j$ does not stop after a finite number of steps, then $x_1,x_2,\cdots$ form an infinite subset of $X$, and therefore has a limit point $p$ in $X$. Then the neighborhood $N_{\frac{\delta}{2}}(p)$ contains infinite many points of $x_1,x_2,\cdots$ (Theorem 2.20), in specific, two points $x_i$ and $x_j$, so $d(x_i,x_j)=d(x_i,p)+d(p,x_j)<\frac{\delta}{2}+\frac{\delta}{2}=\delta$, a contradiction. So the process must stop after a finite number of steps.

Therefore, $X$ can be covered by finitely many neighborhoods of radius $\delta$, which means we can find $E_\delta=\{x_{\delta1},x_{\delta2},\cdots,x_{\delta k} \}$ such that
\[
X\subset\bigcup_{j=1}^kN_\delta(x_{\delta j})
\]
for every $\delta>0$. Let
\[
E=\bigcup_{n=1}^\infty E_{\frac{1}{n}}
\]
Because $E_{\frac{1}{n}}$ is finite, $E$ is countable by Theorem 2.12.

For every $x\in X$, let $N_r(x)$ be any neighborhood of $x$, and let $N$ be a positive integer such that $\frac{1}{N}<r$, then $x\in N_{\frac{1}{N}}(y)$ for some $y\in E_{\frac{1}{N}}\subset E$ (because $X$ is covered by neighborhoods of radius $\frac{1}{N}$), and therefore $y\in N_r(x)$ (because $d(y,x)<\frac{1}{N}<r$). So for every $x\in X$, every neighborhood of $x$ contains a point $y\in E$, which means  $x\in E$ or $x$ is a limit point of $E$, and that means $E$ is dense in $X$. So $X$ contains a countable dense subset $E$, which means $X$ is separable.

\paragraph{25.}
For every compact metric space $K$, the collection of neighborhoods centered at every $x\in K$ with radius $\frac{1}{n}$ forms a open cover of $K$, so it has a finite subcover covering $K$. Let $E_{\frac{1}{n}}$ be the finite subcover, and let
\[
E=\bigcup_{n=1}^\infty E_{\frac{1}{n}}
\]

$E$ is countable by Theorem 2.12. If $G$ is an open set in $K$ and $x\in G$, then there is a neighborhood $N_\varepsilon(x)\subset G$. Let $N$ be an integer such that $0<\frac{1}{N}<\frac{\varepsilon}{2}$. Because $E_{\frac{1}{N}}$ covers $K$, there is an open set $V\in E$ with center $q$ such that $x\in V$. And $V\subset N_{\varepsilon}(x)\subset G$ (because if $y\in V$, then $d(y,x)<d(y,q)+d(q,x)<\frac{\varepsilon}{2}+\frac{\varepsilon}{2}=\varepsilon$). Therefore, for every $x\in K$ and every open set $G\subset K$ such that $x\in G$, we have $V\subset E$ such that $x\in V\subset G$, which means $E$ is a countable base of $K$.

Let $C$ be the set of centers of neighborhoods in $E$. $C$ is countable because $E$ is countable. For every $x\in K$ and every neighborhood $N_r(x)$, we can find $x\in V\subset N_r(x)$ where $V\in E$, so the center of $V$, which is an element of $C$, is in $N_r(x)$. So every neighborhood of $x$ contains a point of $C$, which means $x$ is a point or a limit point of $C$, so $C$ is dense in $K$. Therefore, $C$ is a countable dense subset of $K$, which means $K$ is separable.
\medskip

(Or alternatively, note that every infinite subset of $K$ has a limit point in $K$ (Theorem 2.37), so $K$ is separable (Exercise 24), and therefore has a countable base (Exercise 23).)

\paragraph{26.}
Every infinite subset of $X$ has a limit point, so $X$ is separable (Exercise 24), and therefore has a countable base (Exercise 23). It follows that every open cover of $X$ has a countable subcover $\{G_n\},\,n=1,2,3,\cdots$ (because every open set is in the union of a subcollection of the countable base). If no finite subcollection of $\{G_n\}$ covers $X$, then the complement $F_n$ of $G_1\cup\cdots\cup G_n$ is nonempty for each $n$, but $\bigcap F_n$ is empty. Let $E$ be a set contains a point from each $F_n$, which means $E=\{x_1,x_2,\cdots\}$ with $x_n\in F_n$, then $E$ is obviously infinite (otherwise there will be an element of $E$ belongs to infinitely many $F_n$, which implies $\bigcap F_n$ being non-empty). So $E$ being infinite implies there is a limit point $p$ of $E$, let $p\in G_k$, and there is a neighborhood $N_r(p)\in G_k\subset G_1\cup\cdots\cup G_k$. For $i\geq k$, $x_i\in F_i$ so $x_i\not\in G_1\cup\cdots\cup G_k$, which means there are at most $k$ elements of $E$ belongs to $G_1\cup\cdots\cup G_k$ and therefore possibly belongs to $N_r(p)$, contradicts to the fact that $p$ is a limit point of $E$ (Theorem 2.20).  So there must be a finite subcollection of $\{G_n\}$ covers $X$, which means $X$ is compact.

\paragraph{27.}
Let $\{V_n\}$ be a countable base of $R^k$, and let $W$ be the union of those $V_n$ for which $E\cap V_n$ is at most countable.

If $x\in P^c$, then there is a neighborhood $N_r(x)$ containing at most countably many points of $E$. By the definition of countable base,  there is a $V_n\in\{V_n\}$ such that $x\in V_n\subset N_r(x)$. $E\cap V_n\subset E\cap N_r(x)$ is at most countable, so $V_n\subset W$, and therefore $x\in W$. This implies $P^c\subset W$.

If $x\in W$, then there is a $V_n$ such that $x\in V_n$ and $E\cap V_n$ is at most countable. Let $N_r(x)$ be a neighborhood such that $N_r(x)\subset V_n$, then $N_r(x)\cap E\subset V_n\cap E$ is at most countable, which means $N_r(x)$ contains at most countably many points of $E$, so $x\not\in P$. This implies $W\subset P^c$.

From the above two statements, we have $P^c=W$. So
\[
P^c\cap E=W\cap E=\bigcup_{n=1}^\infty V_n\cap E
\]
Every $V_n\cap E$ is at most countable, so $P^c\cap E$ is at most countable, which means at most countably many points of $E$ are not in $P$.
\medskip

Let $x$ be a limit point of $P$, then in every neighborhood $N_r(x)$, there is a $y\in P$ in $N_r(x)$. Let $r'=r-d(x,y)$, then the neighborhood $N_{r'}(y)\subset N_r(x)$, and it contains uncountably many points of E because $y\in P$, so $N_r(x)$ also contains uncountably many points of $E$. So $x\in P$, which means $P$ is closed.

Let $x\in P$ and $N_r(x)$ be a neighborhood of $x$, then $N_r(x)$ contains uncountably many points of $E$. If $N_r(x)$ contains no elements of $P$ other than $x$, then $N_r(x)\subset\{x\}\cup P^c$, and $N_r(x)\cap E\subset \{x\}\cup(P^c\cap E)$ is at most countable, contradicting to the fact that $N_r(x)$ contains uncountably many points of $E$. Therefore, $N_r(x)$ contains an element of $P$ other then $x$, which means $x$ is a limit point of $P$.

Therefore, $P$ is closed, and every point of $P$ is a limit point of $P$, which means $P$ is perfect.

\paragraph{28.}
Let $P$ be defined as in Exercise 27. Every point of $P$ is a limit point of $E$, and $E$ is closed, so $P\subset E$, which means $P\cap E=P$.
\[
E=(P\cap E)\cup(P^c\cap E)=P\cup(P^c\cap E)
\]
The result in Exercise 27 is not restricted to $R^k$, so $P$ is perfect, and $P^c\cap E$ is at most countable. So $E$ is the union of a perfect set and a set which is at most countable. \medskip

\textit{Corollary}\quad Let $E$ be a closed set in $R^k$. If it has no isolated point, then it is perfect and is therefore uncountable (Theorem 2.43). So every countable closed set in $R^k$ has isolated point.

\paragraph{29.}
From Theorem 22 and 23, $R^1$ is separable and has a countable base $\{V_\alpha\}$. For every open set $E$, let $\{V_{\alpha'}\}$ be the collection of all $V_{\alpha'}$ such that $x\in V_{\alpha'}\subset E$ for some $x\in E$. Every $V_{\alpha'}\subset E$, so $\bigcup_{\alpha'}V_{\alpha'}\subset E$. For every $x\in E$, $x\in V_{\alpha'}$ for some $\alpha'$, so $E\subset\bigcup_{\alpha'}V_{\alpha'}$. Therefore $E=\bigcup_{\alpha'}V_{\alpha'}$. $\{V_{\alpha}\}$ is countable, so  $\{V_{\alpha'}\}$ is also countable, and note that $V_{\alpha'}$ is a segment, so $\bigcup_{\alpha'}V_{\alpha'}$ is the union of at most countable collection of disjoint segments.

\paragraph{30.}
Let $G_n$ be a dense open subset of $R^k$, for $n=1,2,3,\cdots$.
Let $G$ be an nonempty set in $R^k$, and let $N_r(x)\subset G$ be an neighborhood in $G$. $G_1$ is dense in $R^k$, so $N_r(x)$ contains an element of $G_1$, which means $N_r(x)\cap G_1\neq\varnothing$. Both $G_1$ and $N_r(x)$ are open, so $N_r(x)\cap G_1$ is open. Let $N_{r_1}(x_1)$ be a neighborhood such that $\overline{N_{r_1}}\subset N_r(x)\cap G_1$ (It is easy to find it if we first choose a neighborhood with radius $\varepsilon$ in $N_r(x)\cap G_1$, and let $N_{r_1}(x_1)$ be a neighborhood centered at the same point and with radius $\frac{\varepsilon}{2}$). Similarly, $N_{r_1}(x_1)\cap G_2$ is nonempty and open, so we can find $N_{r_2}(x_2)$ such that $\overline{N_{r_2}(x_2)}\subset N_{r_1}(x_1)\cap G_2$. Repeat the process, we have
\begin{alignat*}{2}
    & \overline{N_{r_1}(x_1)} && \subset N_r(x)\cap G_1\\
    & \overline{N_{r_2}(x_2)} && \subset N_{r_1}(x_1)\cap G_2\\
    & && \vdots \\
    & \overline{N_{r_n}(x_n)} && \subset N_{r_{n-1}}(x_{n-1})\cap G_n
\end{alignat*}
Every $\overline{N_{r_n}(x_n)}$ is closed and bounded and therefore compact. $\overline{N_{r_{n+1}}(x_{n+1})}\subset N_{r_n}(x_n) \subset\overline{N_{r_n}(x_n)}$, so
\[
\overline{N_{r_1}(x_1)}\supset \overline{N_{r_2}(x_2)}\supset\cdots
\]
By Theorem 2.36,
\[
\bigcap_{n=1}^\infty\overline{N_{r_n}(x_n)}\neq\varnothing
\]
$\overline{N_{r_n}(x_n)}\subset G_n$, so
\[
\bigcup_{n=1}^\infty G_n\supset\bigcap_{n=1}^\infty\overline{N_{r_n}(x_n)}\neq\varnothing
\]
The equivalent statement is proved.
\medskip

If $R^k=\bigcup_1^\infty F_n$, where every $F_n$ is closed and has empty interior, then $F_n^c$ is open and dense in $R^k$ (Every neighborhood of $x\in F_n$ contains a point not in $F_n$, so $F_n\subset(F_n^c)'$, and $R^k=F\cup F^c\subset(F^c)'\cup F^c$, which means $F^c$ is dense in $R^k$). Then from the equivalent statement, we have
\[
\bigcap_{n=1}^\infty F_n^c\neq\varnothing
\]
which means there is an element not contained in every $F_n$, a contradiction. Therefore, at least one $F_n$ has a nonempty interior.

\end{document}

Principles of Mathematical Analysis/Chapter 02/main.tex