%
% firstly set up on Jan 2012
%
% fully derived the ERI in OS framework
% derived the overlap, kinetic and nuclear integral in OS framework
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{OS Method}
%
%
%
%
OS method is based on two cognitions for the integral of Gaussian primitive
functions. The first cognition is that all of integral could be reduced into the
form of three body overlap integrals. The second cognition is based on
derivatives of Gaussian primitive function:
\begin{equation}
 \label{OS_general_int_eq:1}
\frac{\partial \chi}{\partial R_{x}} = \frac{\partial
(x^{l}y^{m}z^{n}e^{-\alpha r^{2}})}
{\partial R_{x}} =  -lx^{l-1}y^{m}z^{n}e^{-\alpha r^{2}} + 2\alpha
x^{l+1}y^{m}z^{n}e^{-\alpha r^{2}}
\end{equation}
Here the $x$ is expressed as:
\begin{equation}
 x = x_{e} - R_{x}
\end{equation}
In such relation, it's clear that the $\chi(l,m,n)$, its derivatives and the
higher angular momentum one $\chi(l+1,m,n)$ are connected with each other so
that it provides an potential opportunity to link the $\chi(l+1,m,n)$
and $\chi(l,m,n)$ together through $\chi$'s derivatives.

Now following the definition in the OS method, we can express such
relation as:
\begin{equation}
 \label{OS_general_int_eq:2}
 \frac{\partial \chi(r,\alpha,l,R)}{\partial R_{i}} =
2\alpha\chi(r,\alpha,l+\iota_{i},R) - N_{i}(l)\chi(r,\alpha,l-\iota_{i},R)
\end{equation}
as $i = x, y, z$. Original $\chi$ is $\chi(r,\alpha,l,R)$, so $r$ is the
electron coordinate, $R$ is the nuclear coordinate, $\alpha$ is the exponent
and $l$ is the angular momentum (actually it's a three dimensional vector).
$\iota$ characterizes the arising or descending of the angular momentum,
it's actually Kronecker symbol:
\begin{equation}
 \iota_{i} = (\delta_{ix}, \delta_{iy}, \delta_{iz})
\label{OS_general_int_eq:3}
\end{equation}
Similarly, $N_{i}(l)$ is:
\begin{equation}
N_{i}(l) =
\begin{cases}
 l_{x} & i = x \\
 l_{y} & i = y \\
 l_{z} & i = z
\end{cases}
 \label{OS_general_int_eq:4}
\end{equation}

By moving the exponent to the left side, the \ref{OS_general_int_eq:2}
could be further expressed into:
\begin{equation}
 \label{OS_general_int_eq:5}
\chi(r,\alpha,l+\iota_{i},R) =
\frac{1}{2\alpha}\frac{\partial \chi(r,\alpha,l,R)}{\partial R_{i}}
+ \frac{N_{i}(l)}{2\alpha}\chi(r,\alpha,l-\iota_{i},R)
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Three Center Overlap Integral}
%
%
%
The purpose for this section, is to employ the relation in the \ref{OS_general_int_eq:5}
to derive a recursive relation for evaluating the three center overlap integral
in terms of the corresponding lower angular momentum integrals.

Now let's suggest a three body overlap integral between $\chi_{a}, \chi_{b}$
and $\chi_{c}$:
\begin{equation}
 \begin{split}
(a|b|c) &= \int \chi_{a}(r)\chi_{b}(r)\chi_{c}(r) dr \\
&= \int x^{l_{A}}_{A}y^{m_{A}}_{A}z^{n_{A}}_{A}e^{-\alpha r_{A}^{2}}
        x^{l_{B}}_{B}y^{m_{B}}_{B}z^{n_{B}}_{B}e^{-\beta  r_{B}^{2}}
        x^{l_{C}}_{C}y^{m_{C}}_{C}z^{n_{C}}_{C}e^{-\gamma r_{C}^{2}}dr
 \end{split}
\label{OS_three_overlap_int_eq:1}
\end{equation}
A,B and C could be the same center, or different centers. From the previous
chapter to evaluate the overlap integral, we know that we could combine
$\chi_{a}$ and $\chi_{b}$ together and then combine the new Gaussian primitive
which centers at $p$ with the $\chi_{c}$. The integral could be generally expressed as:
\begin{equation}
\label{general_expression_for_3_overlap_os}
\begin{split}
 \int \chi_{a}(r)\chi_{b}(r)\chi_{c}(r) dr &=
\kappa_{abc}I_{abc}^{x}I_{abc}^{y}I_{abc}^{z} \\
&= e^{-\frac{\alpha\beta}{\alpha+\beta}|AB|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}} \\
& \int x^{l_{A}}_{A}y^{m_{A}}_{A}z^{n_{A}}_{A}
       x^{l_{B}}_{B}y^{m_{B}}_{B}z^{n_{B}}_{B}
       x^{l_{C}}_{C}y^{m_{C}}_{C}z^{n_{C}}_{C}
e^{-(\alpha+\beta+\gamma)|r_{G}|^{2}} dr
\end{split}
\end{equation}
In the combination of Gaussian primitives, new centers generated are given as:
\begin{equation}
 \begin{split}
  \overrightarrow{P} &= \frac{\alpha \overrightarrow{A} +
\beta \overrightarrow{B}}{\alpha+\beta}
\Rightarrow \\
  \overrightarrow{G} &= \frac{(\alpha+\beta)\overrightarrow{P} + \gamma
\overrightarrow{C}}{ \alpha+\beta +\gamma } \\
    &= \frac{\alpha \overrightarrow{A} + \beta \overrightarrow{B} +
\gamma \overrightarrow{C}}{ \alpha+\beta +\gamma }
 \end{split}
\label{OS_three_overlap_int_eq:2}
\end{equation}
Here we intentionally do not expand the multiplication of
$x^{l_{A}}_{A}y^{m_{A}}_{A}z^{n_{A}}_{A}$ etc. since we want to keep it
into some symmetrical form. The essence for deriving the three center of
overlap integral, is not to really calculate it; but gain some recursive relationship
among the integrals. Here the symmetry of the integral \ref{general_expression_for_3_overlap_os}
is some key feature.

Firstly, for the pre-factor we could express it into:
\begin{equation}
\kappa_{abc} = e^{-\frac{\alpha\beta}{\alpha+\beta}|AB|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}}
\label{OS_three_overlap_int_eq:3}
\end{equation}
Now we expand the \ref{OS_three_overlap_int_eq:3} into (We use $A_{i}$, $B_{i}$
and $C_{i}$ to represent it's component on X, Y or Z direction, i could be
x, y, or z):
\begin{equation}
 \begin{split}
 &e^{-\frac{\alpha\beta}{\alpha+\beta}(A_{i}-B_{i})^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}(P_{i}-C_{i})^{2}} \\
&=e^{-\frac{\alpha\beta}{\alpha+\beta}(A_{i}-B_{i})^{2}}
e^{-\frac{\gamma}{(\alpha+\beta)(\alpha+\beta+\gamma)}
((\alpha+\beta)C_{i}-\alpha A_{i} - \beta B_{i})^{2}} \\
 \end{split}
\label{OS_three_overlap_int_eq:4}
\end{equation}
For the exponents we have:
\begin{equation}
 \begin{split}
 & \frac{\alpha\beta}{\alpha+\beta}(A_{i}-B_{i})^{2}
+ \frac{\gamma}{(\alpha+\beta)(\alpha+\beta+\gamma)}
((\alpha+\beta)C_{i} -\alpha A_{i} - \beta B_{i})^{2} \\
&=  \frac{\alpha\beta(\alpha+\beta+\gamma)(A_{i}-B_{i})^{2}
+ \gamma((\alpha+\beta)C_{i} -\alpha A_{i} - \beta B_{i})^{2}}
{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&= \frac{\alpha^{2}\beta(A_{i}-B_{i})^{2}
+ \alpha\beta^{2}(A_{i}-B_{i})^{2}+\alpha\beta\gamma(A_{i}-B_{i})^{2}}
{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&+ \frac{\gamma(\alpha+\beta)^{2}C_{i}^{2}+\alpha^{2}\gamma A_{i}^{2} +
\beta^{2}\gamma B_{i}^{2} }{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&+ \frac{-2\alpha\gamma(\alpha+\beta)A_{i}C_{i}
- 2\beta\gamma(\alpha+\beta)B_{i}C_{i} + 2\alpha\beta\gamma A_{i}B_{i}}
{(\alpha+\beta)(\alpha+\beta+\gamma)}  \\
 \end{split}
\label{OS_three_overlap_int_eq:5}
\end{equation}
Now let's re-arrange the terms in terms of the order of $\alpha, \beta$
and $\gamma$:
\begin{equation}
 \begin{split}
  & \frac{\alpha\beta}{\alpha+\beta}(A_{i}-B_{i})^{2}
+ \frac{\gamma}{(\alpha+\beta)(\alpha+\beta+\gamma)}
((\alpha+\beta)C_{i}-\alpha A_{i} - \beta B_{i})^{2} \\
&= \frac{\alpha^{2}\beta(A_{i}-B_{i})^{2}
+ \alpha\beta^{2}(A_{i}-B_{i})^{2}+
\alpha^{2}\gamma(A_{i}-C_{i})^{2}
+ \beta^{2}\gamma(B_{i}-C_{i})^{2}}{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
& +\frac{
  \alpha\beta\gamma(A_{i}^{2}+B_{i}^{2}+2C_{i}^{2}-2A_{i}C_{i}-2B_{i}C_{i})}
{(\alpha+\beta)(\alpha+\beta+\gamma)}  \\
&= \frac{\alpha^{2}\beta(A_{i}-B_{i})^{2}
+ \alpha\beta^{2}(A_{i}-B_{i})^{2}+
\alpha^{2}\gamma(A_{i}-C_{i})^{2}
+ \beta^{2}\gamma(B_{i}-C_{i})^{2}}{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&+\frac{
  \alpha\beta\gamma\left( (C_{i}-A_{i})^{2} + (C_{i}-B_{i})^{2}\right)}
{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&= \frac{\alpha\beta(A_{i}-B_{i})^{2}(\alpha+\beta) +
\alpha\gamma(A_{i}-C_{i})^{2}(\alpha+\beta)
+ \beta\gamma(B_{i}-C_{i})^{2}(\alpha+\beta)}
{(\alpha+\beta)(\alpha+\beta+\gamma)} \\
&= \frac{\alpha\beta(A_{i}-B_{i})^{2} +
\alpha\gamma(A_{i}-C_{i})^{2}
+ \beta\gamma(B_{i}-C_{i})^{2}}
{(\alpha+\beta+\gamma)}
 \end{split}
\label{OS_three_overlap_int_eq:6}
\end{equation}
The expression in \ref{OS_three_overlap_int_eq:6} is symmetric. Furthermore, we
could re-form it by using the \ref{OS_three_overlap_int_eq:2} since $G$ will also
appears in the integral part:
\begin{equation}
 \begin{split}
 &\frac{\alpha\beta(A_{i}-B_{i})^{2} + \alpha\gamma(A_{i}-C_{i})^{2}  +
\beta\gamma(B_{i}-C_{i})^{2}}
 {(\alpha+\beta+\gamma)} \\
&= -(\alpha+\beta+\gamma)\left( G_{i}^{2} - \frac{\alpha A_{i}^{2} + \beta
B_{i}^{2} + \gamma C_{i}^{2}}
{\alpha+\beta+\gamma}\right)
 \end{split}
\label{OS_three_overlap_int_eq:7}
\end{equation}
Therefore, for the pre-factor we have:
\begin{align}
\kappa_{abc} &= e^{-\frac{\alpha\beta}{\alpha+\beta}|A-B|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|P-C|^{2}} \nonumber \\
&= e^{(\alpha+\beta+\gamma)\left( |G|^{2} - \frac{\alpha |A|^{2} + \beta |B|^{2} + \gamma |C|^{2}}
{\alpha+\beta+\gamma}\right)}
\label{OS_three_overlap_int_eq:8}
\end{align}
Its derivatives for the $R_{i}$ is:
\begin{equation}
 \label{OS_three_overlap_int_eq:9}
\frac{\partial \kappa_{abc}}{R_{i}} = (2\alpha G_{Ai} - 2\alpha
A_{i})\kappa_{abc}
\end{equation}

Now let's expand the integral of $I^{x}_{abc}$:
\begin{equation}
 \begin{split}
  I^{x}_{abc}(l_{A},l_{B},l_{C}) &= \sum_{l_{1}=0}^{l_{A}}\sum_{l_{2}=0}^{l_{B}}
\sum_{l_{3}=0}^{l_{C}}
\binom{l_{A}}{l_{1}}\binom{l_{B}}{l_{2}}\binom{l_{C}}{l_{3}} \\
&(G_{x}-A_{x})^{(l_{A}-l_{1})}
 (G_{x}-B_{x})^{(l_{B}-l_{2})}
 (G_{x}-C_{x})^{(l_{C}-l_{3})} \\
&\int (x-G_{x})^{l_{1}+l_{2}+l_{3}}
e^{-(\alpha+\beta+\gamma)(x-G_{x})^{2}} dx \\
&= \sqrt{\frac{\pi}{\alpha+\beta+\gamma}}\sum_{l_{1}=0}^{l_{A}}\sum_{l_{2}=0}^{l_{B}}
\sum_{l_{3}=0}^{l_{C}}
\binom{l_{A}}{l_{1}}\binom{l_{B}}{l_{2}}\binom{l_{C}}{l_{3}} \\
&(G_{x}-A_{x})^{(l_{A}-l_{1})}
 (G_{x}-B_{x})^{(l_{B}-l_{2})}
 (G_{x}-C_{x})^{(l_{C}-l_{3})} \\
&\frac{(l_{1}+l_{2}+l_{3}-1)!!}
{\left\lbrace 2(\alpha+\beta+\gamma)\right\rbrace^{l_{1}+l_{2}+l_{3}} }
 \end{split}
\label{OS_three_overlap_int_eq:10}
\end{equation}
We note that $l_{1}+l_{2}+l_{3}$ should be even number else the integral is zero. For
the integral on the y, z direction, we have the similar result, too.
It's derivative could be expressed as:
\begin{equation}
\begin{split}
 \frac{\partial I^{x}_{abc}}{\partial R_{x}} &=
l_{A}\left( \frac{\alpha}{\alpha+\beta+\gamma} -1\right)I^{x}_{abc}(l_{A}-1,l_{B},l_{C}) \\
&+ l_{B}\left( \frac{\alpha}{\alpha+\beta+\gamma}\right)I^{x}_{abc}(l_{A},l_{B}-1,l_{C}) \\
&+ l_{C}\left( \frac{\alpha}{\alpha+\beta+\gamma}\right)I^{x}_{abc}(l_{A},l_{B},l_{C}-1)
\end{split}
 \label{OS_three_overlap_int_eq:11}
\end{equation}
We note that for the derivatives of $I^{i}_{abc}$ in terms of $R_{j}$ ($j \neq i$), the result
is obviously zero.

Now let's combine the result in \ref{OS_three_overlap_int_eq:9} and \ref{OS_three_overlap_int_eq:11},
and also employing the relation in \ref{OS_general_int_eq:5}; we can arrive at some symmetrical
recursive relation for the $(a|b|c)$:
\begin{equation}
 \begin{split}
 (a+\iota_{x}|b|c) &= \frac{1}{2\alpha}\frac{\partial }{\partial R_{Ax}}(a|b|c)
+ \frac{l_{A}}{2\alpha}(a-\iota_{x}|b|c) \\
&= (G_{Ax} - A_{x})(a|b|c) +
l_{A}\left(\frac{1}{2(\alpha+\beta+\gamma)} -\frac{1}{2\alpha}\right)(a-\iota_{x}|b|c) \\
&+ l_{B}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b-\iota_{x}|c)  \\
&+ l_{C}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b|c-\iota_{x}) +
\frac{l_{A}}{2\alpha}(a-\iota_{x}|b|c) \\
&= (G_{Ax} - A_{x})(a|b|c) +
l_{A}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a-\iota_{x}|b|c) \\
&+
l_{B}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b-\iota_{x}|c) \\
&+
l_{C}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b|c-\iota_{x})
 \end{split}
\label{OS_three_overlap_int_eq:12}
\end{equation}
Such relation could be generalized into the derivative for $R_{Xi}$ for all of
center of X and all of components of $i=x,y,z$. The relation is the starting point for
all of following derivations.

At last, let's consider that if one of primitive function is ``S'' type of
function, how to reduce the recursive relation in
\ref{OS_three_overlap_int_eq:12}. For the S type of function it does not have
the angular momentum part, the pre-factor part part still exists; but for the
integral in \ref{OS_three_overlap_int_eq:10}, the derivatives for the S type
function will be zero. For example, suggest that $a$ is the S type of function,
then it's obvious that:
\begin{equation}
\begin{split}
 \frac{\partial I^{x}_{abc}}{\partial R_{x}} &=
l_{B}\left(
\frac{\alpha}{\alpha+\beta+\gamma}\right)I^{x}_{abc}(l_{A},l_{B}-1,l_{C}) \\
&+ l_{C}\left(
\frac{\alpha}{\alpha+\beta+\gamma}\right)I^{x}_{abc}(l_{A},l_{B},l_{C}-1)
\end{split}
 \label{OS_three_overlap_int_eq:13}
\end{equation}
Then combined with \ref{OS_three_overlap_int_eq:12}, it gives:
\begin{equation}
 \begin{split}
 (0+\iota_{x}|b|c) &= \frac{1}{2\alpha}\frac{\partial }{\partial R_{Ax}}(0|b|c)
\\
&= (G_{Ax} - A_{x})(0|b|c)
+ l_{B}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(0|b-\iota_{x}|c) \\
&+ l_{C}\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(0|b|c-\iota_{x})
 \end{split}
\label{OS_three_overlap_int_eq:14}
\end{equation}
For the other S type centers we have the similar relation, too.

From the above derivation, the bottom integral of three center
overlap could be expressed as:
\begin{equation}
 \begin{split}
  (0_{A}|0_{B}|0_{C}) &= \int e^{-\alpha r_{A}^{2}}e^{-\beta  r_{B}^{2}}
             e^{-\gamma r_{C}^{2}}dr \\
          &= e^{-\frac{\alpha\beta}{\alpha+\beta}|AB|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}}
\int e^{-(\alpha+\beta+\gamma)|r_{G}|^{2}} dr \\
          &= e^{-\frac{\alpha\beta}{\alpha+\beta}|AB|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}}
\left( \frac{\pi}{\alpha+\beta+\gamma}\right)^{\frac{3}{2}}
 \end{split}
 \label{OS_bottom_three_overlap_int_1}
\end{equation}

We can also write the above integral in another form:
\begin{equation}
 \begin{split}
  (0_{A}|0_{B}|0_{C}) &= e^{-\frac{\alpha\beta}{\alpha+\beta}|AB|^{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}}
\left( \frac{\pi}{\alpha+\beta+\gamma}\right)^{\frac{3}{2}} \\
&= (0_{A}|0_{B})\left( \frac{\alpha+\beta}{\alpha+\beta+\gamma}\right)^{\frac{3}{2}}
e^{-\frac{(\alpha+\beta)\gamma}{\alpha+\beta+\gamma}|PC|^{2}}
 \end{split}
 \label{OS_bottom_three_overlap_int_2}
\end{equation}
where $(0_{A}|0_{B})$ is the overlap integral in \ref{overlap_direct_int_eq:1}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Electron Repulsion Integrals}
\label{os_eri}
%
%
%
%
Now we begin to use the conclusion got in the previous section to solve the
real problems. This section we are going to tackle down the most difficult one,
the double electrons integral.

Let's consider some electronic repulsion integral over the
Gaussian primitive functions:
\begin{equation}
 \label{OS_ERI_eq:1}
(ab|cd) = \int dr \int dr^{'} \chi_{a}(r)\chi_{b}(r)\frac{1}{|r-r^{'}|}
\chi_{c}(r^{'})\chi_{d}(r^{'})
\end{equation}
a,b,c,d are just some general Gaussian primitive functions.

Firstly we do transformation to the $\frac{1}{|r-r^{'}|}$:
\begin{equation}
 \frac{1}{|r-r^{'}|} = \frac{2}{\pi^{1/2}}\int^{\infty}_{0}
e^{-(r-r^{'})^{2}u^{2}}du
\end{equation}
Here $(r-r^{'})^{2}$ is
\begin{equation}
(r-r^{'})^{2} = (x_{r}-x_{r^{'}})^{2} +  (y_{r}-y_{r^{'}})^{2} +
(z_{r}-z_{r^{'}})^{2}
\end{equation}
We note the $r$ and $r^{'}$ are more like the A, B defined in the
\ref{OS_three_overlap_int_eq:4}. Based on this transformation,
the integral could be reformed as:
\begin{equation}
 \begin{split}
 (ab|cd) &= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du
\int dr \int dr^{'} \chi_{a}(r)\chi_{b}(r) e^{(r-r^{'})^{2}u^{2}}
\chi_{c}(r^{'})\chi_{d}(r^{'}) \\
&= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du
\int dr^{'}\chi_{c}(r^{'})\chi_{d}(r^{'})
\left( \int dr  \chi_{a}(r)\chi_{b}(r) e^{-(r-r^{'})^{2}u^{2}}\right) \\
&= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du
\int dr^{'}\chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}|b) \\
&= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du (ab|u|cd)
 \end{split}
\label{OS_ERI_eq:2}
\end{equation}
Therefore, the two electron integral now is converted into the three
center overlap integral.

Before we move on, it's useful to remind us the key idea of the derivation
we are going to. We are going to use the recursive relation for the three
center overlap integral, to derive the potential recursive relation for the
ERI. Furthermore, before we really move into the ERI section, actually there are
some very fancy formulas needed to be introduced first. Suggest that there are
three variables, $u$, $\epsilon$ and $\eta$, they are all independent with each
other; we can prove that:
\begin{equation}
 \frac{1}{\epsilon+u^{2}} = \frac{1}{\epsilon}\left( 1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right) - \frac{1}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}
\label{OS_ERI_eq:3}
\end{equation}
Where the $\rho$ is:
\begin{equation}
 \rho = \frac{\epsilon\eta}{\epsilon+\eta}
\end{equation}
This intelligent identity is not so obvious by judging from its appearance.
However, this identity possesses a key path to the final form of expression.
Now let's go to see how to prove it.
\begin{equation}
 \begin{split}
 &\frac{u^{2}}{\rho+u^{2}}\left( \frac{\rho}{\epsilon^{2}} +
\frac{1}{\epsilon+\eta}\frac{u^{2}}{\epsilon+u^{2}}\right) \\
&= \frac{u^{2}}{\rho+u^{2}}\left(
\frac{\epsilon\eta}{\epsilon^{2}(\epsilon+\eta)} +
\frac{1}{\epsilon+\eta}\frac{u^{2}}{\epsilon+u^{2}}\right) \\
&= \frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon+\eta}\left(
\frac{\epsilon\eta}{\epsilon^{2}} +
\frac{u^{2}}{\epsilon+u^{2}}\right) \\
&= \frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon+\eta}\left(
\frac{\eta}{\epsilon} +
\frac{u^{2}}{\epsilon+u^{2}}\right) \\
&= \frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon+\eta}
\frac{\epsilon\eta + \eta u^{2} + \epsilon u^{2}}{\epsilon(\epsilon+u^{2})} \\
&= \frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon+\eta}
\frac{\epsilon\eta + (\eta+ \epsilon)u^{2}}{\epsilon(\epsilon+u^{2})} \\
&= \frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon+\eta}
\frac{(\rho + u^{2})(\eta+ \epsilon)}{\epsilon(\epsilon+u^{2})} \\
&= \frac{u^{2}}{\epsilon(\epsilon+u^{2})}
 \end{split}
\label{OS_ERI_eq:4}
\end{equation}
Now let's combine the result in (\ref{OS_ERI_eq:4}) with the last term in
\ref{OS_ERI_eq:3}, then it gives:
\begin{equation}
 \begin{split}
  \frac{1}{\epsilon}-\frac{u^{2}}{\epsilon(\epsilon+u^{2})}
= \frac{1}{\epsilon}\left( \frac{\epsilon}{\epsilon+u^{2}}\right)
= \frac{1}{\epsilon+u^{2}}
 \end{split}
\label{OS_ERI_eq:5}
\end{equation}
Which is the final result in \ref{OS_ERI_eq:3}. Here we note, that the result
in the \ref{OS_ERI_eq:3} will provide us a chance to link the primitives on
$r$ and primitives on $r^{'}$ in \ref{OS_ERI_eq:1}.

Now let's firstly solve this integral of $(a|0_{r^{'}}|b)$. We would apply
the recursive relation we got in the \ref{OS_three_overlap_int_eq:12}:
\begin{equation}
 \begin{split}
 (a+\iota_{i}|b|c)
&= (G_{Ai} - A_{i})(a|b|c) +
N_{i}(A)\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a-\iota_{i}|b|c) \\
&+
N_{i}(B)\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b-\iota_{i}|c) \\
&+
N_{i}(C)\left(\frac{1}{2(\alpha+\beta+\gamma)}\right)(a|b|c-\iota_{i})
 \end{split}
\label{OS_ERI_eq:6}
\end{equation}
Here we extended it to the general form, and the $\iota_{i}$ and $N_{i}$ are just
the same as \ref{OS_general_int_eq:4} etc. $i$ could be $x,y, z$.

Let's consider to fit it to $(a|0_{r^{'}}|b)$. Here the $\gamma$ is $u^{2}$, and
for the center B (it's the $r^{'}$) we only have a S type of orbital so the
expression could be further expressed as:
\begin{equation}
 \begin{split}
  (a+\iota_{i}|0_{r^{'}}|b)
&=(G_{Ai} - A_{i})(a|0_{r^{'}}|b) +
N_{i}(A)\left(\frac{1}{2(\alpha+\beta+u^{2})}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\alpha+\beta+u^{2})}\right)(a|0_{r^{'}}|b-\iota_{i}) \\
&=(G_{Ai} - A_{i})(a|0_{r^{'}}|b) +
N_{i}(A)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a|0_{r^{'}}|b-\iota_{i})
 \end{split}
\label{OS_ERI_eq:7}
\end{equation}

According to the \ref{OS_ERI_eq:3}, $\dfrac{1}{\epsilon+u^{2}}$ could be
directly expanded; so the result could be reformed into:
\begin{equation}
 \begin{split}
  (a+\iota_{i}|0_{r^{'}}|b)
&=(G_{Ai} - A_{i})(a|0_{r^{'}}|b) \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&-\frac{N_{i}(A)}{2}\left(\frac{1}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+ \frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a|0_{r^{'}}|b-\iota_{i}) \\
&-\frac{N_{i}(B)}{2}\left(\frac{1}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}\right)(a|0_{r^{'}}|b-\iota_{i})
 \end{split}
\label{OS_ERI_eq:8}
\end{equation}
The $\eta$ and corresponding $\rho$ could be referred later. Now they are only
arbitrary numbers ($\rho$ depends on $\eta$ and $\epsilon$).

Now we are trying to wrap up some terms in the \ref{OS_ERI_eq:8} into a new
form:
\begin{equation}
 \begin{split}
  &(a|0_{r^{'}}+\iota_{i}|b) \\
  & =(0_{r^{'}}+\iota_{i}|a|b)  \\
  &= \left( \frac{\alpha A_{i} + \beta B_{i} + u^{2}r^{'}_{i}}
{\alpha +\beta + u^{2}} - r^{'}_{i}\right)(a|0_{r^{'}}|b)\\
&+
N_{i}(A)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a|0_{r^{'}}|b-\iota_{i})
 \end{split}
\label{OS_ERI_eq:9}
\end{equation}
Since
\begin{equation}
 \begin{split}
  \frac{\alpha A_{i} + \beta B_{i} + u^{2}r^{'}_{i}}
{\alpha +\beta + u^{2}} - r^{'}_{i} =
 \frac{\alpha A_{i} + \beta B_{i} -r^{'}_{i}(\alpha+\beta)}
{\epsilon + u^{2}} = \frac{P_{i}\epsilon -r^{'}_{i}\epsilon}
{\epsilon + u^{2}}
 \end{split}
\end{equation}
where
\begin{equation}
 P_{i} = \frac{\alpha A_{i} + \beta B_{i}}{\alpha+\beta}
\end{equation}
and $\epsilon = \alpha+\beta$, therefore the \ref{OS_ERI_eq:9} could be
expressed as:
\begin{equation}
 \begin{split}
&(a|0_{r^{'}}+\iota_{i}|b) \\
&=-\frac{\epsilon}{\epsilon + u^{2}}(r^{'}_{i} - P_{i})(a|0_{r^{'}}|b) \\
&+
N_{i}(A)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\epsilon+u^{2})}\right)(a|0_{r^{'}}|b-\iota_{i})
 \end{split}
\label{OS_ERI_eq:10}
\end{equation}
Here we note that our purpose here is try to build some expression, which
could reduce the integral into some potential recursive forms.

Now we can use the $(a|0_{r^{'}}+\iota_{i}|b)$ to transform the
\ref{OS_ERI_eq:8}:
\begin{equation}
 \begin{split}
    (a+\iota_{i}|0_{r^{'}}|b)
&=(G_{Ai} - A_{i})(a|0_{r^{'}}|b) \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+ \frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a|0_{r^{'}}|b-\iota_{i}) \\
&-\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}{\rho+u^{2}}(a|0_{r^{'}}+\iota_{i}|b) \\
&-\frac{\epsilon}{\epsilon+u^{2}}
\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}{\rho+u^{2}}(r^{'}_{i} - P_{i})((a|0_{r^{'}}|b))
 \end{split}
\label{OS_ERI_eq:11}
\end{equation}

Now let's use the relation defined in the \ref{OS_ERI_eq:3}
to expand the $(G_{Ai} - A_{i})$. We note that the $G_{Ai}$ is:
\begin{equation}
 G_{Ai} = \frac{\alpha A_{i} + \beta B_{i} + u^{2} r^{'}_{i}}{\alpha + \beta +
u^{2}}
 = \frac{\alpha A_{i} + \beta B_{i} + u^{2} r^{'}_{i}}{\epsilon + u^{2}}
\end{equation}
Hence, for $(G_{Ai} - A_{i})$ according to \ref{OS_ERI_eq:3} it's:
\begin{equation}
 \begin{split}
 G_{Ai} - A_{i} &= \left( \frac{\alpha A_{i} + \beta B_{i}}{\epsilon} -
A_{i}\right) +
\frac{u^{2} r^{'}_{i}}{\epsilon} \\
&-(\alpha A_{i} + \beta B_{i} + u^{2} r^{'}_{i})\left(\frac{\rho}{\epsilon^{2}}
\frac{u^{2}}{\rho+u^{2}} + \frac{1}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}
\right)  \\
&= \left( P_{i} - A_{i}\right) + \frac{u^{2} r^{'}_{i}}{\epsilon} \\
&-\left( \frac{u^{2}r^{'}_{i}}{\epsilon} + P_{i}\right)
\left(\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}} + \frac{\epsilon}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}
\right)
 \end{split}
\label{OS_ERI_eq:12}
\end{equation}

Now let's combine the terms for the $(a|0_{r^{'}}|b)$ in the \ref{OS_ERI_eq:11}
and \ref{OS_ERI_eq:12}. For the $P_{i}$ term, we can see that:
\begin{equation}
 \left( P_{i} - A_{i}\right)(a|0_{r^{'}}|b)
-P_{i}\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}(a|0_{r^{'}}|b)
\label{OS_ERI_eq:13}
\end{equation}
the terms for the $\dfrac{\epsilon}{\epsilon+\eta}
\dfrac{u^{2}}{\epsilon+u^{2}}\dfrac{u^{2}}{\rho+u^{2}} $ canceled.

For the $r_{i}^{'}$, the remaining terms are:
\begin{equation}
 \begin{split}
&\frac{u^{2} r^{'}_{i}}{\epsilon}
-\frac{u^{2}r^{'}_{i}}{\epsilon}
\left(\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}} + \frac{\epsilon}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}
\right) \\
&-\frac{\epsilon}{\epsilon+u^{2}}
\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}{\rho+u^{2}}r^{'}_{i}
 \end{split}
\end{equation}
We do not include the integral of $(a|0_{r^{'}}|b)$ here since they are similar
terms in terms of $(a|0_{r^{'}}|b)$.

Here we have:
\begin{equation}
\frac{\epsilon}{\epsilon+\eta}
\frac{u^{2}}{\epsilon+u^{2}}\frac{u^{2}}{\rho+u^{2}}\left(
1+\frac{u^{2}}{\epsilon} \right)r^{'}_{i} =
\frac{u^{2}}{\epsilon+\eta}
\frac{u^{2}}{\rho+u^{2}}r^{'}_{i}
\end{equation}
Then
\begin{equation}
\begin{split}
&\frac{u^{2}}{\epsilon+\eta}
\frac{u^{2}}{\rho+u^{2}}r^{'}_{i} +
\frac{u^{2}r^{'}_{i}}{\epsilon}
\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}} = \\
&{u^{2}}r^{'}_{i}
\frac{u^{2}}{\rho+u^{2}}\left(\frac{1}{\epsilon+\eta} +
\frac{\rho}{\epsilon^{2}} \right) \\
&= {u^{2}}r^{'}_{i}
\frac{u^{2}}{\rho+u^{2}}\left(\frac{1}{\epsilon+\eta} +
\frac{1}{\epsilon+\eta}\frac{\eta}{\epsilon} \right) \\
&= {u^{2}}r^{'}_{i}
\frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon}
\end{split}
\end{equation}
Finally
\begin{equation}
\frac{u^{2} r^{'}_{i}}{\epsilon}
-{u^{2}}r^{'}_{i}
\frac{u^{2}}{\rho+u^{2}}\frac{1}{\epsilon} = r^{'}_{i}
\frac{u^{2}}{\rho+u^{2}}\frac{\rho}{\epsilon}
\end{equation}
Surprisingly, this term is directly corresponding to the terms for $P_{i}$
in the \ref{OS_ERI_eq:13}, so totally we have the result that:
\begin{equation}
\begin{split}
&(G_{Ai} - A_{i})(a|0_{r^{'}}|b)
-\frac{\epsilon}{\epsilon+u^{2}}
\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}{\rho+u^{2}}(r^{'}_{i} -
P_{i})(a|0_{r^{'}}|b)  \\
&= \left( P_{i} - A_{i}\right)(a|0_{r^{'}}|b) +
(r^{'}_{i}-P_{i})\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}(a|0_{r^{'}}|b)
\end{split}
\label{OS_ERI_eq:14}
\end{equation}

By using the \ref{OS_ERI_eq:14}, the \ref{OS_ERI_eq:8} could be finally
expressed as:
\begin{equation}
 \begin{split}
  (a+\iota_{i}|0_{r^{'}}|b)
&=(P_{i} - A_{i})(a|0_{r^{'}}|b) \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a-\iota_{i}|0_{r^{'}}|b) \\
&+ \frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)(a|0_{r^{'}}|b-\iota_{i}) \\
&+(r^{'}_{i}-P_{i})\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}(a|0_{r^{'}}|b)
-\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}{\rho+u^{2}}(a|0_{r^{'}}+\iota_{i}|b)
 \end{split}
\label{OS_ERI_eq:15}
\end{equation}

Now let's set the value of $\eta$ and $\rho$, so that to make the $(a+\iota_{i}|0_{r^{'}}|b)$
related to the outer integral on $\chi_{c}$ and $\chi_{d}$:
\begin{equation}
 \label{OS_ERI_eq:16}
\eta = \alpha^{'} + \beta^{'}
\end{equation}
where $\alpha^{'}$ is the exponent factor for $\chi_{c}$, and $\beta^{'}$ is the exponent
factor for $\chi_{d}$. Therefore, the $\rho$ could be expressed as:
\begin{equation}
 \label{OS_ERI_eq:17}
\rho = \frac{(\alpha+\beta)(\alpha^{'} + \beta^{'})}{(\alpha+\beta)+(\alpha^{'} + \beta^{'})}
\end{equation}

Let's consider the outer integral over $r^{'}$, it's easy to see that:
\begin{equation}
\label{OS_ERI_eq:18}
 -\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}} +\iota_{i} |b)
= \int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r} + \iota_{i}|d)
\end{equation}
This is because that for the term of $0_{r} + \iota_{i}$, which is converted from
$r^{'}_{i} - r_{i}$ into $r_{i}-r^{'}_{i}$.Therefore, for the term of
$\dfrac{u^{2}}{\epsilon+\eta}\dfrac{u^{2}}
{\rho+u^{2}}(a|0_{r^{'}}+\iota_{i}|b)$ in the integral it could be converted into:
\begin{equation}
 \label{OS_ERI_eq:19}
\begin{split}
&-\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}+\iota_{i}|b) \\
&=\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)u^{2}(c|0_{r}+\iota_{i}|d)
\end{split}
\end{equation}
While according to the \ref{OS_ERI_eq:10}, the term of $u^{2}(c|0_{r}+\iota_{i}|d)$
is:
\begin{equation}
 \begin{split}
  u^{2}(c|0_{r}+\iota_{i}|d) &=
-\eta(r_{i} - Q_{i})(c|0_{r}|d) \\
&+
\left(\frac{N_{i}(C)}{2}\right)(c-\iota_{i}|0_{r}|d) \\
&+
\left(\frac{N_{i}(D)}{2}\right)(c|0_{r}|d-\iota_{i}) \\
&-\eta(c|0_{r}+\iota_{i}|d)
 \end{split}
\label{OS_ERI_eq:20}
\end{equation}
and
\begin{equation}
 Q_{i} = \frac{\alpha^{'}C + \beta^{'}D}{\alpha^{'} + \beta^{'}}
\end{equation}

Now let's take the result of \ref{OS_ERI_eq:20} into \ref{OS_ERI_eq:19}, it's:
\begin{equation}
 \begin{split}
  &-\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}+\iota_{i}|b) \\
&=Q_{i}\frac{\eta}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d) \\
&+
\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c-\iota_{i}|0_{r}|d) \\
&+
\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d-\iota_{i}) \\
&-\eta \frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r) r_{i} (c|0_{r}|d) \\
&-\eta\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}+\iota_{i}|d)
 \end{split}
\label{OS_ERI_eq:21}
\end{equation}

Now let's look into the details of \ref{OS_ERI_eq:21}. In terms of its last
two terms, actually we have:
\begin{equation}
 \begin{split}
 r_{i}(c|0_{r}|d) +(c|0_{r}+\iota_{i}|d)
&=
\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
r_{i}e^{u^{2}(r^{'}-r)^{2}} \\
&+
\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
(r^{'}_{i}-r_{i})e^{u^{2}(r^{'}-r)^{2}}
 \end{split}
\label{OS_ERI_eq:22}
\end{equation}
Here according to our traditional notation (see \ref{OS_three_overlap_int_eq:4}),
$r$ and $r^{'}$ represent the points in the space, and $i$ denotes its components
on the X, Y or Z axis. Therefore, it's clear that:
\begin{equation}
  r_{i}(c|0_{r}|d) +(c|0_{r}+\iota_{i}|d) =
\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
r^{'}_{i}e^{u^{2}(r^{'}-r)^{2}}
\label{OS_ERI_eq:23}
\end{equation}
If we go over integral by $r$, it yields:
\begin{equation}
\begin{split}
&\int dr \chi_{a}(r)\chi_{b}(r) \int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
r^{'}_{i}e^{(r^{'}-r)^{2}} \\
&= \int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'}) r^{'}_{i}
\int dr \chi_{a}(r)\chi_{b}(r) e^{u^{2}(r^{'}-r)^{2}} \\
&= \int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'}) r^{'}_{i}(a|0_{r^{'}}|b)
\end{split}
\label{OS_ERI_eq:24}
\end{equation}
Therefore the \ref{OS_ERI_eq:21} could be converted into:
\begin{equation}
 \begin{split}
  &-\frac{u^{2}}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}+\iota_{i}|b) \\
&=Q_{i}\frac{\eta}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d) \\
&+
\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c-\iota_{i}|0_{r}|d) \\
&+
\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d-\iota_{i}) \\
&-\eta \frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'}) r^{'}_{i}(a|0_{r^{'}}|b)
 \end{split}
\label{OS_ERI_eq:25}
\end{equation}

Now let's combine the result in \ref{OS_ERI_eq:25} with the result in \ref{OS_ERI_eq:15}.
By multiplying $\chi_{c}$ and $\chi_{d}$ and integrate over $r^{'}$ in
\ref{OS_ERI_eq:15}, we can get:
\begin{equation}
 \begin{split}
&\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a+\iota_{i}|0_{r^{'}}|b) \\
&=(P_{i} - A_{i})\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}|b) \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
(a-\iota_{i}|0_{r^{'}}|b) \\
&+ \frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
(a|0_{r^{'}}|b-\iota_{i}) \\
&-P_{i}\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}|b) \\
&+\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})r^{'}_{i}(a|0_{r^{'}}|b) \\
&+Q_{i}\frac{\eta}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d) \\
&+
\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c-\iota_{i}|0_{r}|d) \\
&+
\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d-\iota_{i}) \\
&-\eta \frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'}) r^{'}_{i}(a|0_{r^{'}}|b) \\
&= (P_{i} - A_{i})\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}|b) \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
(a-\iota_{i}|0_{r^{'}}|b) \\
&+ \frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})
(a|0_{r^{'}}|b-\iota_{i}) \\
&+\left(W_{i} -P_{i}\right)
\frac{u^{2}}{\rho+u^{2}}\int dr^{'} \chi_{c}(r^{'})\chi_{d}(r^{'})(a|0_{r^{'}}|b) \\
&+
\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c-\iota_{i}|0_{r}|d) \\
&+
\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}\int dr \chi_{a}(r)\chi_{b}(r)(c|0_{r}|d-\iota_{i})
 \end{split}
\label{OS_ERI_eq:26}
\end{equation}
Where in this long expression, it's clear that the integral term containing
$r^{'}_{i}$ vanished, and we combine the terms of $P_{i}$ and $Q_{i}$ together
so to give $W_{i}$:
\begin{equation}
 W_{i} = \frac{\epsilon P_{i} + \eta Q_{i}}{\epsilon + \eta}
\end{equation}
We note, that this surprising result has very beautiful symmetry among the
resulting integrals.

By using the expression of $(ab|u|cd)$ in \ref{OS_ERI_eq:2}, the expression for
the \ref{OS_ERI_eq:26} could be further simplified as:
\begin{equation}
 \begin{split}
((a+\iota_{i})b|u|cd) &= (P_{i} - A_{i})(ab|u|cd) +
\left(W_{i} -P_{i}\right)
\frac{u^{2}}{\rho+u^{2}}(ab|u|cd) \\
&+\frac{N_{i}(A)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)
((a-\iota_{i})b|u|cd) \\
&+\frac{N_{i}(B)}{2\epsilon}\left(1-\frac{\rho}{\epsilon}
\frac{u^{2}}{\rho+u^{2}}\right)
(a(b-\iota_{i})|u|cd) \\
&+\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}(ab|u|(c-\iota_{i})d) \\
&+\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}\frac{u^{2}}
{\rho+u^{2}}(ab|u|c(d-\iota_{i}))
\end{split}
\label{OS_ERI_eq:27}
\end{equation}

Now let's define some auxiliary integral function:
\begin{equation}
\label{OS_ERI_eq:28}
 (ab|cd)^{(m)} = \frac{2}{\sqrt{\pi}}\int^{\infty}_{0} du \left( \frac{u^{2}}
{\rho+u^{2}}\right)^{m}(ab|u|cd)
\end{equation}
Then by multiplying with $\left( \dfrac{u^{2}}
{\rho+u^{2}}\right)^{m}$ and integrating over $u$
the above result could be written as:
\begin{equation}
 \begin{split}
((a+\iota_{i})b|cd)^{(m)} &= (P_{i} - A_{i})(ab|cd)^{(m)} +
\left(W_{i} -P_{i}\right)(ab|cd)^{(m+1)} \\
&+\frac{N_{i}(A)}{2\epsilon}\left(((a-\iota_{i})b|cd)^{(m)}-\frac{\rho}{
\epsilon }((a-\iota_{i})b|cd)^{(m+1)}\right)  \\
&+\frac{N_{i}(B)}{2\epsilon}\left((a(b-\iota_{i})|cd)^{(m)}-\frac{\rho}{
\epsilon }(a(b-\iota_{i})|cd)^{(m+1)}\right)  \\
&+\left(\frac{N_{i}(C)}{2}\right)\frac{1}{\epsilon+\eta}
(ab|(c-\iota_{i})d)^{(m+1)} \\
&+\left(\frac{N_{i}(D)}{2}\right)\frac{1}{\epsilon+\eta}
(ab|c(d-\iota_{i}))^{(m+1)}
\end{split}
\label{OS_ERI_result}
\end{equation}
We note that the true ERI is $(ab|cd)^{(0)}$. This is the final result
for deriving the ERI in the OS framework.

Finally, let's make some complementary work. In the \ref{OS_ERI_result},
it's clear all of integrals could be derived from the basic integral of
$(00|00)^{(m)}$, which is in form of:
\begin{equation}
 \begin{split}
 (00|00)^{(m)} &= \frac{2}{\sqrt{\pi}} \int_{0}^{\infty} du \left( \frac{u^{2}}
{\rho+u^{2}}\right)^{m} (00|u|00) \\
&=\frac{2}{\sqrt{\pi}} \int_{0}^{\infty} du \left( \frac{u^{2}}
{\rho+u^{2}}\right)^{m}
\int dr^{'}  e^{-\alpha^{'} (r^{'}_{C})^{2}}e^{-\beta^{'} (r^{'}_{D})^{2}} \\
&\int dr  e^{-\alpha r_{A}^{2}} e^{-\beta r_{B}^{2}} e^{-(r-r^{'})^{2}u^{2}}
\end{split}
\end{equation}
As for the integral over $r$, by using the three body integral result in
\ref{OS_bottom_three_overlap_int_2}, we can rewrite it as:
\begin{equation}
 \begin{split}
  \int dr  e^{-\alpha r_{A}^{2}} e^{-\beta r_{B}^{2}} e^{-(r-r^{'})^{2}u^{2}} &=
  (0_{A}|0_{B})\left( \frac{\alpha+\beta}{\alpha+\beta+u^{2}}\right)^{\frac{3}{2}}
e^{-\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}|r^{'}-P|^{2}}
 \end{split}
 \label{OS_ERI_eq:30}
\end{equation}
This is equivalent to treat $e^{(r-r^{'})^{2}u^{2}}$ as a S type of Gaussian, where
the electron in $r$ centers on ``nuclei'' of $r^{'}$.

The RHS of \ref{OS_ERI_eq:30} is still like a Gaussian of $r^{'}$ centering
on $P$, so once again by using the \ref{OS_bottom_three_overlap_int_2};
it's able to integrate over $r^{'}$. Before we move on, let's do some prepare
work. Firstly, considering the combination of Gaussian on $P$ and Gaussian
on $C$ and $D$, for the exponent coefficient it gives:
\begin{equation}
 \begin{split}
  \frac{\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}\times
  (\alpha^{'}+\beta^{'})}{\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}
  +\alpha^{'}+\beta^{'}}
  &= \frac{(\alpha^{'}+\beta^{'})(\alpha+\beta)u^{2}}
  {(\alpha+\beta+u^{2})(\alpha^{'}+\beta^{'})+(\alpha+\beta)u^{2}} \\
  &= \frac{u^{2}}{1+\frac{u^{2}}{\alpha+\beta}+\frac{u^{2}}{\alpha^{'}+\beta^{'}}} \\
  &= \frac{u^{2}}{1+u^{2}\left( \frac{1}{\alpha+\beta}+\frac{1}{\alpha^{'}+\beta^{'}}
  \right) } \\
  &= \frac{u^{2}}{1+\frac{u^{2}}{\rho}} \\
  &= \frac{\rho u^{2}}{\rho+ u^{2}}
 \end{split}
 \label{OS_ERI_eq:31}
 \end{equation}
 Here we use the definition for variable of $\rho$ in \ref{OS_ERI_eq:17}.

 So the integral over $r^{'}$ becomes:
\begin{equation}
 \begin{split}
   &\int dr^{'}  e^{-\alpha^{'} (r^{'}_{C})^{2}}e^{-\beta^{'} (r^{'}_{D})^{2}}
   \int dr  e^{-\alpha r_{A}^{2}} e^{-\beta r_{B}^{2}} e^{-(r-r^{'})^{2}u^{2}} \\
&= (0_{A}|0_{B})\left( \frac{\alpha+\beta}{\alpha+\beta+u^{2}}\right)^{\frac{3}{2}}
  \int dr^{'}  e^{-\alpha^{'} (r^{'}_{C})^{2}}e^{-\beta^{'} (r^{'}_{D})^{2}}
   e^{-\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}|r^{'}-P|^{2}} \\
&= (0_{A}|0_{B})(0_{C}|0_{D})
\left( \frac{\alpha+\beta}{\alpha+\beta+u^{2}}\right)^{\frac{3}{2}}
\left( \frac{\alpha^{'}+\beta^{'}}{\alpha^{'}+\beta^{'}+
\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}}\right)^{\frac{3}{2}}
e^{-\frac{\rho u^{2}}{\rho+ u^{2}}|PQ|^{2}}
\end{split}
\label{OS_ERI_eq:32}
\end{equation}
This is using the result of \ref{OS_ERI_eq:31}. Combing the term in \ref{OS_ERI_eq:32},
it gives:
\begin{equation}
\begin{split}
 &\left( \frac{\alpha+\beta}{\alpha+\beta+u^{2}}\right)^{\frac{3}{2}}
\left( \frac{\alpha^{'}+\beta^{'}}{\alpha^{'}+\beta^{'}+
\frac{(\alpha+\beta)u^{2}}{\alpha+\beta+u^{2}}}\right)^{\frac{3}{2}} \\
&= \left( \frac{(\alpha+\beta)(\alpha^{'}+\beta^{'})}
{(\alpha+\beta+u^{2})(\alpha^{'}+\beta^{'})+(\alpha+\beta)u^{2}}\right)^{\frac{3}{2}}\\
&= \left(\frac{1}{1+\frac{u^{2}}{\rho}}\right)^{\frac{3}{2}} \\
&= \left(\frac{\rho}{\rho+u^{2}}\right)^{\frac{3}{2}}
\end{split}
 \label{OS_ERI_eq:33}
\end{equation}
So after integrate over $r$ and $r^{'}$ the bottom integral becomes:
\begin{equation}
 \begin{split}
 (00|00)^{(m)} &=\frac{2}{\sqrt{\pi}}(0_{A}|0_{B})(0_{C}|0_{D})
 \int_{0}^{\infty} du \left( \frac{u^{2}}{\rho+u^{2}}\right)^{m}
 \left(\frac{\rho}{\rho+u^{2}}\right)^{\frac{3}{2}}
 e^{-\frac{\rho u^{2}}{\rho+ u^{2}}|PQ|^{2}}
 \end{split}
\label{OS_ERI_eq:34}
\end{equation}
If we set $t^{2} = \frac{u^{2}}{\rho+ u^{2}}$, and it's easy to know
that
\begin{equation}
 du = (1-t^{2})^{-\frac{3}{2}}\rho^{1/2} dt
 \label{OS_ERI_eq:35}
\end{equation}
so \ref{OS_ERI_eq:34} becomes:
\begin{equation}
 \begin{split}
 (00|00)^{(m)} &= 2\left( \frac{\rho}{\pi}\right)^{\frac{1}{2}}(0_{A}|0_{B})
(0_{C}|0_{D})\int^{1}_{0} t^{2m} e^{-(\rho|PQ|^{2})t^{2}} dt
 \end{split}
\label{OS_ERI_complementary_result}
\end{equation}

Where we have the arguments as:
\begin{align}
 \overrightarrow{P} &= \frac{\alpha \overrightarrow{A} + \beta
\overrightarrow{B}}{\alpha + \beta} \nonumber \\
\overrightarrow{Q} &= \frac{\alpha^{'} \overrightarrow{C} + \beta^{'}
\overrightarrow{D}}{\alpha^{'} + \beta^{'}} \nonumber \\
\rho &= \frac{(\alpha+\beta)(\alpha^{'}+\beta^{'})}
{(\alpha+\beta)+(\alpha^{'}+\beta^{'})}
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Overlap Integral}
%
%
%
the basic overlap integral is:
\begin{equation}
 \label{OS_overlap_eq:1}
I = \int dr \chi_{a}(r) \chi_{b}(r)
\end{equation}

By using the recursive relation derived in the three center overlap
integral (see \ref{OS_three_overlap_int_eq:12}), set the middle Gaussian
primitive to be zero; we can get the recursive relation for overlap:
\begin{equation}
\begin{split}
(a+\iota_{i}|b) &=
(P_{i} - A_{i})(a|b) +
N_{i}(A)\left(\frac{1}{2(\alpha+\beta)}\right)(a-\iota_{i}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\alpha+\beta)}\right)(a|b-\iota_{i})
\end{split}
\label{OS_overlap_result}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Derivatives of Basis Sets in Overlap}
%
%
%
Before we derive the recursive relation for kinetic energy, let's firstly
go to see another type of integral of
$\left( \dfrac{\partial a}{\partial x}|b\right)$.

Firstly, we note that the derivatives can not directly be applied to the
recursive relation like \ref{OS_overlap_result}:
\begin{equation}
\begin{split}
(\frac{\partial (a+\iota_{i})}{\partial x}|b) & \neq
(P_{i} - A_{i})(\frac{\partial a}{\partial x}|b) +
N_{i}(A)\left(\frac{1}{2(\alpha+\beta)}\right)(\frac{\partial(a-\iota_{i})}{\partial x}|b) \\
&+
N_{i}(B)\left(\frac{1}{2(\alpha+\beta)}\right)(\frac{\partial a}{\partial x}|b-\iota_{i})
\end{split}
\end{equation}

Let's prove this with some simple example. Suggest we have two Gaussian
primitives:
\begin{align}
 \chi_{i} &= x^{l_{i}}y^{m_{i}}z^{n_{i}} e^{-\alpha_{i} r^{2}} \nonumber \\
 \chi_{j} &= x^{l_{j}}y^{m_{j}}z^{n_{j}} e^{-\alpha_{j} r^{2}} \nonumber \\
 \gamma   &= \alpha_{i} + \alpha_{j}
 \end{align}

According to the \ref{derivative_overlap_direct_int_eq:2} and recursive relation
for the overlap integral, we can have:
\begin{equation}
 \begin{split}
 \left(\frac{\partial \chi_{i}}{\partial x}|\chi_{j}\right)  &=
 l_{i}(\chi_{i}^{l-1mn}|\chi_{j}) - 2\alpha_{i} (\chi_{i}^{l+1mn}|\chi_{j}) \\
 &= l_{i}\left[ PA_{k}(\chi_{i}^{l-1mn}-\iota_{k}|\chi_{j}) +
 \frac{N_{k}(A)}{2 \gamma}(\chi_{i}^{l-1mn}-2\iota_{k}|\chi_{j})  \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(\chi_{i}^{l-1mn}-\iota_{k}|\chi_{j}-\iota_{k})
 \right] \\
 &-2\alpha_{i} \left[ PA_{k}(\chi_{i}^{l+1mn}-\iota_{k}|\chi_{j}) +
 \frac{N_{k}(A)}{2 \gamma}(\chi_{i}^{l+1mn}-2\iota_{k}|\chi_{j}) \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(\chi_{i}^{l+1mn}-\iota_{k}|\chi_{j}-\iota_{k})
 \right]
 \end{split}
 \label{deriv_os_overlap:1}
\end{equation}
Here the index of $i$ and $j$ are omitted for l, m and n. If the l, m and n do not
change, they are not listed neither.

It's easy to see that if $k = y$ or $k = z$ then the above equation could be
written as:
\begin{equation}
 \begin{split}
  \left(\frac{\partial \chi_{i}}{\partial x}|\chi_{j}\right)  &=
 l_{i}(\chi_{i}^{l-1mn}|\chi_{j}) - 2\alpha_{i} (\chi_{i}^{l+1mn}|\chi_{j}) \\
 &=  PA_{k}(\frac{\partial(\chi_{i}^{lmn}-\iota_{k})}{\partial x}|\chi_{j}) +
 \frac{N_{k}(A)}{2 \gamma}(\frac{\partial(\chi_{i}^{lmn}-2\iota_{k})}{\partial x}|\chi_{j})
 \\
 &+ \frac{N_{k}(B)}{2 \gamma}
 (\frac{\partial (\chi_{i}^{lmn}-\iota_{k}) }{\partial x}|\chi_{j}-\iota_{k})
 \end{split}
\end{equation}
However, if $k = x$, the above equation does not hold.

For $k = x$, the \ref{deriv_os_overlap:1} could be expressed as:
\begin{equation}
 \begin{split}
 \left(\frac{\partial \chi_{i}}{\partial x}|\chi_{j}\right)  &=
 l_{i}(\chi_{i}^{l-1mn}|\chi_{j}) - 2\alpha_{i} (\chi_{i}^{l+1mn}|\chi_{j}) \\
 &= l_{i}\left[ PA_{x}(\chi_{i}^{l-2mn}|\chi_{j}) +
 \frac{N_{x}(A)}{2 \gamma}(\chi_{i}^{l-3mn}|\chi_{j})  \right. \\
 &+ \left. \frac{N_{x}(B)}{2 \gamma}(\chi_{i}^{l-2mn}|\chi_{j}^{l-1mn})
 \right] \\
 &-2\alpha_{i} \left[ PA_{x}(\chi_{i}|\chi_{j}) +
 \frac{N_{x}(A)}{2 \gamma}(\chi_{i}^{l-1mn}|\chi_{j}) \right. \\
 &+ \left. \frac{N_{x}(B)}{2 \gamma}(\chi_{i}|\chi_{j}^{l-1mn})
 \right] \\
 &= PA_{x} \left( l_{i}(\chi_{i}^{l-2mn}|\chi_{j}) -2\alpha_{i} (\chi_{i}|\chi_{j})
 \right) \\
 &+ \frac{N_{x}(A)}{2 \gamma}\left(
 l_{i}(\chi_{i}^{l-3mn}|\chi_{j}) -2\alpha_{i} (\chi_{i}^{l-1mn}|\chi_{j})
 \right) \\
 &+ \frac{N_{x}(B)}{2 \gamma}\left(
 l_{i}(\chi_{i}^{l-2mn}|\chi_{j}^{l-1mn}) -2\alpha_{i} (\chi_{i}|\chi_{j}^{l-1mn})
 \right) \\
 &= PA_{x} (\frac{\partial \chi_{i}^{l-1mn}}{\partial x}|\chi_{j}) +
 PA_{x} (\chi_{i}^{l-1mn}|\chi_{j}) \\
 &+ \frac{N_{x}(A)}{2 \gamma}(\frac{\partial \chi_{i}^{l-2mn}}{\partial x}|\chi_{j})
 + 2\frac{N_{x}(A)}{2 \gamma}(\chi_{i}^{l-2mn}|\chi_{j}) \\
 &+ \frac{N_{x}(B)}{2 \gamma}(\frac{\partial \chi_{i}^{l-1mn}}{\partial x}|\chi_{j}^{l-1mn})
 + \frac{N_{x}(B)}{2 \gamma}(\chi_{i}^{l-1mn}|\chi_{j}^{l-1mn}) \\
 &= PA_{x} (\frac{\partial \chi_{i}^{l-1mn}}{\partial x}|\chi_{j}) +
 \frac{N_{x}(A)}{2 \gamma}(\frac{\partial \chi_{i}^{l-2mn}}{\partial x}|\chi_{j}) \\
 &+ \frac{N_{x}(B)}{2 \gamma}(\frac{\partial \chi_{i}^{l-1mn}}{\partial x}|\chi_{j}^{l-1mn}) \\
 &+ PA_{x} (\chi_{i}^{l-1mn}|\chi_{j}) + \frac{N_{x}(A)}{2 \gamma}(\chi_{i}^{l-2mn}|\chi_{j}) \\
 &+ \frac{N_{x}(B)}{2 \gamma}(\chi_{i}^{l-1mn}|\chi_{j}^{l-1mn}) \\
 &+ \frac{N_{x}(A)}{2 \gamma}(\chi_{i}^{l-2mn}|\chi_{j})
 \end{split}
 \label{deriv_os_overlap:2}
\end{equation}
Therefore, we have additional terms in \ref{deriv_os_overlap:2}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Kinetic Energy Integral}
%
%
%
According to the \ref{kinetic_direct_int_eq:2}, the kinetic energy integral is:
\begin{align}
 \label{OS_kinetic_eq:1}
I &= \frac{1}{2}\int dr (\nabla\chi_{i}(r)) \cdotp (\nabla\chi_{j}(r)) \nonumber \\
  &= \frac{1}{2}\int d x \frac{\partial \chi_{i}(r)}{\partial x}
  \frac{\partial \chi_{j}(r)}{\partial x}
  +  \frac{1}{2}\int d y \frac{\partial \chi_{i}(r)}{\partial y}
  \frac{\partial \chi_{j}(r)}{\partial y}
  +  \frac{1}{2}\int d z \frac{\partial \chi_{i}(r)}{\partial z}
  \frac{\partial \chi_{j}(r)}{\partial z}
\end{align}
So the kinetic integral is actually a linear combination of overlap integrals,
and the kinetic integral itself could be decomposed into three integrals sum:
\begin{equation}
 I = I_{x} + I_{y} + I_{z}
\end{equation}
In the following derivation, we will concentrate on one component, which is
in general named as $I_{i}$.

For a general Gaussian primitive function of $\chi = x^{l}y^{m}z^{n}e^{-\alpha r^{2}}$, who
centers on $A$; we can express its derivatives as:
\begin{align}
 \frac{\partial \chi^{lmn}_{A}}{\partial v} &=
 N_{i}(A)(\chi_{A}^{lmn}-\iota_{i}) - 2\alpha(\chi_{A}^{lmn}+\iota_{i}) \nonumber \\
 &= N_{i}(A)(-1)_{i} - 2\alpha(+1)_{i}
 \label{OS_kinetic_eq:0}
\end{align}
$v$ denotes the possible derivatives, could be x, y or z.

Therefore, suggest that in \ref{OS_kinetic_eq:1} the $\chi_{i}$ resides
on $A$ with $\alpha$ exponential factor, and $\chi_{j}$ is on $B$ with
$\beta$ exponential factor; we can have:
\begin{equation}
\begin{split}
\left(  \frac{\partial \chi_{A}}{\partial v}|\frac{\partial \chi_{B}}{\partial v}
\right)  &= N_{i}(A)N_{i}(B)(-1|-1)_{i} -2\alpha N_{i}(B)(+1|-1)_{i} \\
&-2\beta N_{i}(A)(-1|+1)_{i} + 4\alpha\beta(+1|+1)_{i}
\end{split}
\label{OS_kinetic_eq:2}
\end{equation}
the $i$ is determined from the v. If v is x, then $N_{i}(A) = l_{A}$ and
$N_{i}(B) = l_{B}$; if v is y, then $N_{i}(A) = m_{A}$ and
$N_{i}(B) = m_{B}$ and if v is z, then $N_{i}(A) = n_{A}$ and
$N_{i}(B) = n_{B}$.

By expanding all of overlap integrals into its RR form, we can have:
\begin{equation}
 \begin{split}
 \left(  \frac{\partial \chi_{A}}{\partial v}|\frac{\partial \chi_{B}}{\partial v}
\right)  &=  N_{i}(A)N_{i}(B)
\left[ PA_{k}(-1-\iota_{k}|-1)_{i} + \frac{N_{k}(A)}{2 \gamma}(-1-2\iota_{k}|-1)_{i} \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(-1-\iota_{k}|-1-\iota_{k})_{i} \right] \\
&- 2\alpha N_{i}(B)
\left[ PA_{k}(+1-\iota_{k}|-1)_{i} + \frac{N_{k}(A)}{2 \gamma}(+1-2\iota_{k}|-1)_{i} \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(+1-\iota_{k}|-1-\iota_{k})_{i} \right] \\
&- 2\beta  N_{i}(A)
\left[ PA_{k}(-1-\iota_{k}|+1)_{i} + \frac{N_{k}(A)}{2 \gamma}(-1-2\iota_{k}|+1)_{i} \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(-1-\iota_{k}|+1-\iota_{k})_{i} \right] \\
&+ 4\alpha\beta
\left[ PA_{k}(+1-\iota_{k}|+1)_{i} + \frac{N_{k}(A)}{2 \gamma}(+1-2\iota_{k}|+1)_{i} \right. \\
 &+ \left. \frac{N_{k}(B)}{2 \gamma}(+1-\iota_{k}|+1-\iota_{k})_{i} \right]
 \end{split}
 \label{OS_kinetic_eq:3}
\end{equation}
where $\gamma = \alpha + \beta$. $k$ denotes possible RR direction, which is
also x, y or z. $k$ is different from the $v$ here.

Firstly, let's go to see a simple case that the derivatives direction $i$ is not
same with RR direction $k$. It's easy to see, in this case the above result
turns into:
\begin{equation}
 \begin{split}
 \left(  \frac{\partial \chi_{A}}{\partial v}|\frac{\partial \chi_{B}}{\partial v}
\right)  &= PA_{k}
 \left(\frac{\partial (\chi_{A}-\iota_{k})}{\partial v}|
 \frac{\partial \chi_{B}}{\partial v} \right) +
\frac{N_{k}(A)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-2\iota_{k})}{\partial v}|
 \frac{\partial \chi_{B}}{\partial v} \right) \\
&+\frac{N_{k}(B)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-\iota_{k})}{\partial v}|
 \frac{\partial(\chi_{B}-\iota_{k})}{\partial v} \right)
 \end{split}
 \label{OS_kinetic_eq:4}
\end{equation}

For the case that RR direction $k$ is same with derivatives direction of $i$, according
to the equation of \ref{OS_kinetic_eq:3}, we have:
\begin{equation}
 \begin{split}
 \left(  \frac{\partial \chi_{A}}{\partial v_{i=k}}|
 \frac{\partial \chi_{B}}{\partial v_{i=k}} \right)  &=  N_{i}(A)N_{i}(B)
\left[ PA_{i}(-2|-1)_{i} + \frac{N_{i}(A)-2}{2 \gamma}(-3|-1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)-1}{2 \gamma}(-2|-2)_{i} \right] \\
&- 2\alpha N_{i}(B)
\left[ PA_{i}(0|-1)_{i} + \frac{N_{i}(A)}{2 \gamma}(-1|-1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)-1}{2 \gamma}(0|-2)_{i} \right] \\
&- 2\beta  N_{i}(A)
\left[ PA_{i}(-2|+1)_{i} + \frac{N_{i}(A)-2}{2 \gamma}(-3|+1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)+1}{2 \gamma}(-2|0)_{i} \right] \\
&+ 4\alpha\beta
\left[ PA_{i}(0|+1)_{i} + \frac{N_{i}(A)}{2 \gamma}(-1|+1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)+1}{2 \gamma}(0|0)_{i} \right] \\
&= PA_{i} \Bigg\{
(N_{i}(A)-1)N_{i}(B)(-2|-1)_{i} - 2\alpha N_{i}(B)(0|-1)_{i}  \\
&- 2\beta(N_{i}(A)-1)(-2|+1)_{i} +4\alpha\beta (0|+1)_{i} \Bigg\}  \\
&+ PA_{i}\Bigg\{ N_{i}(B)(-2|-1)_{i} -2\beta(-2|+1)_{i} \Bigg\} \\
&+\frac{N_{i}(A)}{2 \gamma} \Bigg\{
(N_{i}(A)-2)N_{i}(B)(-3|-1)_{i} - 2\alpha N_{i}(B)(-1|-1)_{i}  \\
&-2\beta(N_{i}(A)-2)(-3|+1)_{i} + 4\alpha\beta(-1|+1)_{i} \Bigg \} \\
&+\frac{N_{i}(B)}{2 \gamma} \Bigg\{
(N_{i}(A)-1)(N_{i}(B)-1)(-2|-2)_{i} - 2\alpha (N_{i}(B)-1)(0|-2)_{i} \\
&- 2\beta(N_{i}(A)-1)(-2|0)_{i} + 4\alpha\beta(0|0)_{i} \Bigg\} \\
&+\frac{N_{i}(B)(N_{i}(B)-1)}{2 \gamma}(-2|-2)_{i} -
\frac{2\beta N_{i}(A)}{2 \gamma} (-2|0)_{i} \\
&-\frac{2\beta N_{i}(B)}{2 \gamma} (-2|0)_{i}
\end{split}
 \label{OS_kinetic_eq:5}
\end{equation}

The above expression could be re-fomulated into more clearly way:
\begin{equation}
 \begin{split}
 \left(  \frac{\partial \chi_{A}}{\partial v_{i=k}}|
 \frac{\partial \chi_{B}}{\partial v_{i=k}} \right)  &=
 PA_{i}
 \left(\frac{\partial (\chi_{A}-\iota_{i})}{\partial v}|
 \frac{\partial \chi_{B}}{\partial v} \right) +
\frac{N_{i}(A)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-2\iota_{i})}{\partial v}|
 \frac{\partial \chi_{B}}{\partial v} \right) \\
&+\frac{N_{i}(B)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-\iota_{i})}{\partial v}|
 \frac{\partial(\chi_{B}-\iota_{i})}{\partial v} \right) \\
&+ PA_{i}\left[ N_{i}(B)(-2|-1)_{i} -2\beta(-2|+1)_{i} \right] \\
&+\frac{N_{i}(B)(N_{i}(B)-1)}{2 \gamma}(-2|-2)_{i} -
\frac{2\beta N_{i}(A)}{2 \gamma} (-2|0)_{i} \\
&-\frac{2\beta N_{i}(B)}{2 \gamma} (-2|0)_{i}
\end{split}
 \label{OS_kinetic_eq:6}
\end{equation}

\begin{comment}

%

\begin{equation}
 \begin{split}
 \left(  \frac{\partial \chi_{A}}{\partial v_{i=k}}|
 \frac{\partial \chi_{B}}{\partial v_{i=k}} \right)  &=  N_{i}(A)N_{i}(B)
\left[ PA_{i}(-2|-1)_{i} + \frac{N_{i}(A)-2}{2 \gamma}(-3|-1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)-1}{2 \gamma}(-2|-2)_{i} \right] \\
&- 2\alpha N_{i}(B)
\left[ PA_{i}(0|-1)_{i} + \frac{N_{i}(A)}{2 \gamma}(-1|-1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)-1}{2 \gamma}(0|-2)_{i} \right] \\
&- 2\beta  N_{i}(A)
\left[ PA_{i}(-2|+1)_{i} + \frac{N_{i}(A)-2}{2 \gamma}(-3|+1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)+1}{2 \gamma}(-2|0)_{i} \right] \\
&+ 4\alpha\beta
\left[ PA_{i}(0|+1)_{i} + \frac{N_{i}(A)}{2 \gamma}(-1|+1)_{i} \right. \\
 &+ \left. \frac{N_{i}(B)+1}{2 \gamma}(0|0)_{i} \right] \\
&= PA_{i}
 \left(\frac{\partial (\chi_{A}-\iota_{i})}{\partial v_{i}}|
 \frac{\partial \chi_{B}}{\partial v_{i}} \right) +
\frac{N_{i}(A)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-2\iota_{i})}{\partial v_{i}}|
 \frac{\partial \chi_{B}}{\partial v_{i}} \right) \\
&+\frac{N_{i}(B)}{2 \gamma}
 \left(\frac{\partial (\chi_{A}-\iota_{i})}{\partial v_{i}}|
 \frac{\partial(\chi_{B}-\iota_{i})}{\partial v_{i}} \right) \\
&+\Biggl(
-\frac{2 N_{i}(A)N_{i}(B)}{2\gamma}(-3|-1)_{i} -
\frac{N_{i}(A)N_{i}(B)}{2\gamma}(-2|-2)_{i} \\
&-
\frac{2 \alpha N_{i}(B)}{2\gamma}(0|-2)_{i} +
\frac{4 \beta N_{i}(A)}{2\gamma}(-3|+1)_{i} \\
&-
\frac{2 \beta N_{i}(A)}{2\gamma}(-2|0)_{i}  +
\frac{4 \alpha\beta}{2\gamma}(0|0)_{i}
\Biggr)
 \end{split}
 \label{OS_kinetic_eq:5}
\end{equation}

\end{comment}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Three Body Kinetic Integral}
%
%
%
According to the \ref{kinetic_direct_int_eq:2}, the three body kinetic enegy
could also be expressed as:
\begin{equation}
\frac{1}{2}\sum_{v = x, y, z}\int \chi_{A}(r)\chi_{B}(r)
\frac{\partial^{2}}{\partial v^{2}} \chi_{C}(r) dr
= \frac{1}{2}\int \nabla(\chi_{A}(r)\chi_{B}(r)) \cdot \nabla\chi_{C}(r) dr
 \label{three_body_kinetic_integral_eq:1}
\end{equation}

According to the \ref{OS_kinetic_eq:0}, we have:
\begin{align}
 \frac{\partial \chi^{lmn}_{A}}{\partial v} &=
 N_{i}(A)(\chi_{A}^{lmn}-\iota_{i}) - 2\alpha(\chi_{A}^{lmn}+\iota_{i}) \nonumber \\
 &= N_{i}(A)(-1)_{i} - 2\alpha(+1)_{i}
 \label{three_body_kinetic_integral_eq:2}
\end{align}
We can further generate derivtives for \ref{three_body_kinetic_integral_eq:1}
as:
\begin{equation}
 \begin{split}
&\int \nabla(\chi_{A}(r)\chi_{B}(r)) \cdot \nabla\chi_{C}(r) dr \\
&= \int \left[ (\nabla\chi_{A}(r)\chi_{B}(r) + \chi_{A}(r)\nabla\chi_{B}(r)\right]
\cdot \nabla\chi_{C}(r) dr \\
&= \sum_{i = x, y, z} \int
[ N_{i}(A)(\chi_{A}-\iota_{i}) - 2\alpha(\chi_{A}+\iota_{i})] \chi_{B} \\
&[ N_{i}(C)(\chi_{C}-\iota_{i}) - 2\gamma(\chi_{C}+\iota_{i})] dr \\
&+ \sum_{i = x, y, z} \int
\chi_{A}(r) \left[
N_{i}(B)(\chi_{B}-\iota_{i}) - 2\beta(\chi_{B}+\iota_{i})\right] \\
&\left[ N_{i}(C)(\chi_{C}-\iota_{i}) - 2\gamma(\chi_{C}+\iota_{i})\right]  dr
 \end{split}
\label{three_body_kinetic_integral_eq:3}
\end{equation}
$\alpha$ is the expotential factor for $\chi_{A}$, $\beta$ is for $\chi_{B}$
and $\gamma$ is for $\chi_{C}$.

Now let's expand all the terms:
\begin{equation}
 \begin{split}
&\int \nabla(\chi_{A}(r)\chi_{B}(r)) \cdot \nabla\chi_{C}(r) dr \\
&= \sum_{i = x, y, z} \int
[ N_{i}(A)(\chi_{A}-\iota_{i}) - 2\alpha(\chi_{A}+\iota_{i})] \chi_{B} \\
&[ N_{i}(C)(\chi_{C}-\iota_{i}) - 2\gamma(\chi_{C}+\iota_{i})] dr \\
&+ \sum_{i = x, y, z} \int
\chi_{A}(r) \left[
N_{i}(B)(\chi_{B}-\iota_{i}) - 2\beta(\chi_{B}+\iota_{i})\right] \\
&\left[ N_{i}(C)(\chi_{C}-\iota_{i}) - 2\gamma(\chi_{C}+\iota_{i})\right]  dr \\
&= \sum_{i = x, y, z} \int
 N_{i}(A)N_{i}(C)(\chi_{A}-\iota_{i})\chi_{B}(\chi_{C}-\iota_{i}) dr \\
&- \sum_{i = x, y, z} \int
 2\alpha N_{i}(C)(\chi_{A}+\iota_{i})\chi_{B}(\chi_{C}-\iota_{i}) dr \\
&- \sum_{i = x, y, z} \int
 2\gamma N_{i}(A)(\chi_{A}-\iota_{i})\chi_{B}(\chi_{C}+\iota_{i}) dr \\
&+ \sum_{i = x, y, z} \int
 4\alpha\gamma   (\chi_{A}+\iota_{i})\chi_{B}(\chi_{C}+\iota_{i}) dr \\
&+ \sum_{i = x, y, z} \int
 N_{i}(B)N_{i}(C)\chi_{A}(\chi_{B}-\iota_{i})(\chi_{C}-\iota_{i}) dr \\
&- \sum_{i = x, y, z} \int
 2\beta  N_{i}(C)\chi_{A}(\chi_{B}+\iota_{i})(\chi_{C}-\iota_{i}) dr \\
&- \sum_{i = x, y, z} \int
 2\gamma N_{i}(B)\chi_{A}(\chi_{B}-\iota_{i})(\chi_{C}+\iota_{i}) dr \\
&+ \sum_{i = x, y, z} \int
 4\beta\gamma    \chi_{A}(\chi_{B}+\iota_{i})(\chi_{C}+\iota_{i}) dr
 \end{split}
\label{three_body_kinetic_integral_eq:4}
\end{equation}

Particularly, for the bottom $SSS$ type integrals, it has the expression as:
\begin{equation}
\begin{split}
 &\int \nabla(0_{A}0_{B}) \cdot \nabla 0_{C} dr \\
 &= \sum_{i = x, y, z} \int
 4\alpha\gamma   (0_{A}+\iota_{i})0_{B}(0_{C}+\iota_{i}) dr \\
 &+ \sum_{i = x, y, z} \int
 4\beta\gamma    0_{A}(0_{B}+\iota_{i})(0_{C}+\iota_{i}) dr \\
\end{split}
\label{three_body_kinetic_integral_eq:5}
\end{equation}
By using the RR expression for three body overlap integral, it becomes:
\begin{equation}
 \begin{split}
 &\int \nabla(0_{A}0_{B}) \cdot \nabla 0_{C} dr \\
 &= \sum_{i = x, y, z} \int
 4\alpha\gamma   (0_{A}+\iota_{i})0_{B}(0_{C}+\iota_{i}) dr \\
 &+ \sum_{i = x, y, z} \int
 4\beta\gamma    0_{A}(0_{B}+\iota_{i})(0_{C}+\iota_{i}) dr \\
 &= \sum_{i = x, y, z} \int
 4\alpha\gamma\left\lbrace (G_{i}-C_{i})(0_{A}+\iota_{i})0_{B}0_{C}
 +\frac{1}{2(\alpha+\beta+\gamma)}0_{A}0_{B}0_{C} \right\rbrace dr \\
 &+ \sum_{i = x, y, z} \int
 4\beta\gamma \left\lbrace (G_{i}-C_{i})0_{A}(0_{B}+\iota_{i})0_{C}
 +\frac{1}{2(\alpha+\beta+\gamma)}0_{A}0_{B}0_{C} \right\rbrace dr \\
 &= \sum_{i = x, y, z} \int
 4\alpha\gamma\left\lbrace (G_{i}-C_{i})(G_{i}-A_{i})0_{A}0_{B}0_{C}
 +\frac{1}{2(\alpha+\beta+\gamma)}0_{A}0_{B}0_{C} \right\rbrace dr \\
 &+ \sum_{i = x, y, z} \int
 4\beta\gamma \left\lbrace (G_{i}-C_{i})(G_{i}-B_{i})0_{A}0_{B}0_{C}
 +\frac{1}{2(\alpha+\beta+\gamma)}0_{A}0_{B}0_{C} \right\rbrace dr \\
 &= \sum_{i = x, y, z} \left\lbrace
 4\gamma(G_{i}-C_{i}) \left[ \alpha(G_{i}-A_{i}) + \beta(G_{i}-B_{i})\right]
 + \frac{2\gamma(\alpha+\beta)}{\alpha+\beta+\gamma}
 \right\rbrace \int 0_{A}0_{B}0_{C} dr
\end{split}
\label{three_body_kinetic_integral_eq:6}
\end{equation}

\begin{comment}
 &+ \sum_{i = x, y, z} \int \Bigl{
\chi_{A}(r) \left[
N_{i}(B)(\chi_{B}-\iota_{i}) - 2\beta(\chi_{B}+\iota_{i})\right]
\left[ N_{i}(C)(\chi_{C}-\iota_{i}) - 2\gamma(\chi_{C}+\iota_{i})\right] \Bigr} dr
\end{comment}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Nuclear Attraction Integral}
%
%
%
In the section of \ref{direct_NAI_derivation}, we have derived the nuclear
attraction integral explicitly. Here in this section, we will use the recursive
relation to derive a simple algorithm to calculate the NAI.

As we know, a general NAI is expressed as:
\begin{equation}
 \begin{split}
  (a|\Lambda_{c}|b) &= \int \chi_{i}(r)\frac{1}{r_{C}}\chi_{j}(r) dr \\
&= \int x^{l_{A}}_{A}y^{m_{A}}_{A}z^{n_{A}}_{A}e^{-\alpha r_{A}^{2}}
        \frac{1}{r_{C}}
        x^{l_{B}}_{B}y^{m_{B}}_{B}z^{n_{B}}_{B}e^{-\beta  r_{B}^{2}} dr
 \end{split}
\end{equation}
$r_{A}, r_{B}$ and $r_{c}$ denotes the distance between electron position and
the given nuclear (A, B or C).

Through transformation, the $\frac{1}{r_{C}}$ becomes:
\begin{equation}
\label{OS_nuclear_eq:1}
\frac{1}{r_{C}} = \frac{2}{\pi^{1/2}}\int^{\infty}_{0}e^{-u^{2}(r-C)^{2}} du
\end{equation}
Then it's fully converted into a S type of primitive function.

Therefore, for the $(a|0_{c}|b)$ it could be expressed as:
\begin{equation}
 \label{OS_nuclear_eq:2}
\begin{split}
(a|\Lambda_{c}|b) &= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du
 \int dr x^{l_{A}}_{A}y^{m_{A}}_{A}z^{n_{A}}_{A}e^{-\alpha r_{A}^{2}}
        e^{-u^{2}(r-C)^{2}}
        x^{l_{B}}_{B}y^{m_{B}}_{B}z^{n_{B}}_{B}e^{-\beta  r_{B}^{2}} \\
&= \frac{2}{\pi^{1/2}}\int^{\infty}_{0} du  (a|0_{c}|b)
\end{split}
\end{equation}
Then the NAI is converted back to the three center overlap integral.

According to the recursive relation in \ref{OS_three_overlap_int_eq:12},
the $(a|0_{c}|b)$ could be expressed as:
\begin{equation}
 \begin{split}
  (a+\iota_{i}|0_{c}|b)
&= \left( \frac{\alpha A_{i} + \beta B_{i} + u^{2}C_{i}}{\alpha+\beta+u^{2}} -
A_{i}\right) (a|0_{c}|b)  \\
&+
N_{i}(A)\left(\frac{1}{2(\alpha+\beta+u^{2})}\right)(a-\iota_{i}|0_{c}|b) \\
&+
N_{i}(C)\left(\frac{1}{2(\alpha+\beta+u^{2})}\right)(a|0_{c}|b-\iota_{i}) \\
&= \left( P_{i}  - A_{i}\right) (a|0_{c}|b) - (P_{i} - C_{i})
\frac{u^{2}}{\alpha+\beta+u^{2}}(a|0_{c}|b)  \\
&+
\frac{N_{i}(A)}{2(\alpha+\beta)}\left(1-\frac{u^{2}}{(\alpha+\beta+u^{2})}
\right)(a-\iota_{i}|0_{ c }|b) \\
&+
\frac{N_{i}(C)}{2(\alpha+\beta)}\left(1-\frac{u^{2}}{(\alpha+\beta+u^{2})}
\right)(a|0_{c}|b-\iota_{i}) \\
 \end{split}
\label{OS_nuclear_eq:3}
\end{equation}
Where $P_{i}$ is:
\begin{equation}
 P_{i} = \frac{\alpha A_{i} + \beta B_{i}}{\alpha+\beta}
\end{equation}
Here, we are carefully modifying the expression so that to make the result
similar to the one we derived in ERI(see \ref{OS_ERI_eq:27}). Therefore,
here for \ref{OS_nuclear_eq:3} a similar auxiliary function (see
\ref{OS_ERI_eq:28}) could be defined($\epsilon = \alpha+\beta$):
\begin{equation}
\label{OS_nuclear_eq:4}
  (a|0_{c}|b)^{(m)} = \frac{2}{\sqrt{\pi}}\int du \left( \frac{u^{2}}
{\epsilon+u^{2}}\right)^{m}(ab|u|cd)
\end{equation}
and we have:
\begin{equation}
 \begin{split}
  (a+\iota_{i}|0_{c}|b)^{(m)} &=
\left( P_{i}  - A_{i}\right) (a|0_{c}|b)^{(m)} - (P_{i} - C_{i})
(a|0_{c}|b)^{(m+1)}  \\
&+
\frac{N_{i}(A)}{2\epsilon}\left(
(a-\iota_{i}|0_{ c }|b)^{(m)}-
(a-\iota_{i}|0_{ c }|b)^{(m+1)}
\right) \\
&+
\frac{N_{i}(C)}{2\epsilon}\left(
(a|0_{c}|b-\iota_{i})^{(m)}-
(a|0_{c}|b-\iota_{i})^{(m+1)}
\right) \\
 \end{split}
\label{OS_nuclear_eq:5}
\end{equation}
The corresponding integral of $(0_{a}|0_{c}|0_{b})^{(m)}$ is:
\begin{equation}
\label{OS_nuclear_eq:6}
 (0_{a}|0_{c}|0_{b})^{(m)} = 2\left(
\frac{\epsilon}{\pi}\right)^{1/2}(0_{a}|0_{b})
\int^{1}_{0} t^{2m} e^{-(\epsilon|PC|^{2})t^{2}} dt
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{comment}
%%%
%%%  the description here is not quite what we want. So just screen the
%    contents.
%%%

\subsection{Implementation Considerations}
%
%
%
Now let's give some deep discussion on how to realize the algorithm. For the
OS and its derived algorithm, the first thing we can note is that the recursive
relationship is actually expressed based on ``shell'' rather than the basis set
orders (for example, shell P has three basis set orders; Px, Py and Pz).

This is easy to understand. Suggest for an arbitrary overlap integral,
$(a|b)$, there will be $n_{a}n_{b}$ basis set pairs ($n$ is the number of
Cartesian basis set). For the $(a+\iota_{i}|b)$, depending on the literal
meaning the basis set pairs would be $3n_{a}n_{b}$ since $\iota_{i}$ loop
over x, y and z. However, if shell a is incremented to the shell a+1 (like
from shell P to shell D), the basis set pairs would be:
\begin{equation}
 N_{1} = n_{b}\left(\frac{(L+2)(L+3)(L+4)-(L+1)(L+2)(L+3)}{6} \right)
\end{equation}
$L$ is the angular momentum number for the shell a. If we expand the
$3n_{a}n_{b}$ in terms of $L$, it's:
\begin{equation}
N_{2} = 3n_{b}\left(\frac{(L+1)(L+2)(L+3)-(L+1)(L+2)L}{6} \right)
\end{equation}
Therefore $N_{1} - N_{2}$ gives:
\begin{equation}
 \begin{split}
 N_{1} - N_{2} &= n_{b}\left( \frac{(L+2)(L+3)(L+4)-(L+1)(L+2)(L+3)}{6}\right.
\\
&-\left. \frac{3(L+1)(L+2)(L+3)-3(L+1)(L+2)L}{6}\right) \\
&=  n_{b}(L+2)\left( \frac{(L+3)(L+4)-(L+1)(L+3)}{6}\right. \\
&-\left.  \frac{3(L+1)(L+3)-3(L+1)L}{6}\right) \\
&= n_{b}(L+2)\left( \frac{(L+3)(L+4)+3(L+1)L-4(L+1)(L+3)}{6}\right) \\
&= n_{b}(L+2)\left( \frac{(L+3)(-3L)+3(L+1)L}{6}\right) \\
&= n_{b}(L+2)L\left( \frac{-3(L+3)+3(L+1)}{6}\right) \\
&= n_{b}(L+2)L\left( \frac{-6}{6}\right) \\
&< 0
 \end{split}
\end{equation}
Therefore, The incremental on the integral could be fully expressed by shell
rather than basis set orders. What's more, it also indicates that for all of
recursive relations in the OS framework, the integral is meaningful to the
``shells'', we need not to consider it in the basis set order level.

\end{comment}


% Created 2021-07-26 Mon 11:04
% Intended LaTeX compiler: pdflatex
\documentclass[presentation,aspectratio=1610]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{khpreamble, euscript}
\DeclareMathOperator{\atantwo}{atan2}
\newcommand*{\ctrb}{\EuScript{C}}
\newcommand*{\obsv}{\EuScript{O}}
\usetheme{default}
\author{Kjartan Halvorsen}
\date{\today}
\title{Output feedback (observer)}
\hypersetup{
 pdfauthor={Kjartan Halvorsen},
 pdftitle={Output feedback (observer)},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.3 (Org mode 9.4.6)},
 pdflang={English}}
\begin{document}

\maketitle

\section{Apollo moon lander}
\label{sec:orgf367148}
\begin{frame}[label={sec:orga00b35e}]{Example - The Apollo lunar module}
\begin{center}
\includegraphics[width=\linewidth]{fig-apollo}
\end{center}
\end{frame}

\begin{frame}[label={sec:org4e808de}]{Example - The Apollo lunar module}
State variables: \(x = \begin{bmatrix} x_1 & x_2 & x_3 \end{bmatrix}^T = \begin{bmatrix} \dot{\theta} & \theta & \dot{z} \end{bmatrix}^T\). With dynamics
\[ \begin{cases} \dot{x}_1 =  \ddot{\theta} = k_1 u\\ \dot{x}_2 = \dot{\theta} = x_1\\ \dot{x}_3 = \ddot{z} = k_2\theta = k_2x_2 \end{cases} \]

\[ \dot{x} = \begin{bmatrix} \dot{x}_1\\\dot{x}_2\\\dot{x}_3\end{bmatrix} = \underbrace{\begin{bmatrix} \textcolor{red!60!black}{0} & \textcolor{red!60!black}{0} &\textcolor{red!60!black}{0} \\\textcolor{red!60!black}{1} & \textcolor{red!60!black}{0}& \textcolor{red!60!black}{0}\\ \textcolor{red!60!black}{0}& \textcolor{red!60!black}{k_2} &\textcolor{red!60!black}{0} \end{bmatrix}}_{A} \begin{bmatrix} x_1\\x_2\\x_3\end{bmatrix} + \underbrace{\begin{bmatrix} \textcolor{red!60!black}{k_1} \\ \textcolor{red!60!black}{0} \\\textcolor{red!60!black}{0}  \end{bmatrix}}_{B} u \]
\end{frame}

\begin{frame}[label={sec:org03fd31b}]{Example - The Apollo lunar module}
 \begin{align*}
  x(kh+h) &= \mathrm{e}^{Ah} x(kh) + \int_{0}^{h} \mathrm{e}^{As} B u(kh+h-s) ds\\
   &= \underbrace{\mathrm{e}^{Ah}}_{\Phi(h)} x(kh) + \underbrace{\left(\int_{0}^h \mathrm{e}^{As} B ds \right)}_{\Gamma(h)} u(kh)\\
   &= \begin{bmatrix} 1 & 0 & 0\\h & 1 & 0\\\frac{h^2k_2}{2} & hk_2 & 1\end{bmatrix} x(kh) + k_1 \begin{bmatrix} h\\ \frac{h^2}{2} \\ \frac{k_2 h^3}{6} \end{bmatrix} u(kh)
\end{align*}
\end{frame}

\section{State feedback with observer}
\label{sec:org1049069}
\begin{frame}[label={sec:orge0b900b}]{State feedback with reconstructed states}
\end{frame}

\begin{frame}[label={sec:org7f98d83}]{State feedback with reconstructed states}
\begin{center}
\includegraphics[width=0.9\linewidth]{fig-apollo}
\end{center}
\end{frame}

\begin{frame}[label={sec:org5b63c86}]{State feedback}
Given
 \begin{equation}
 \begin{split}
  x(k+1) &= \Phi x(k) + \Gamma u(k)\\
  y(k) &= C x(k)
 \end{split}
 \label{eq:ssmodel}
\end{equation}
and measurements (or estimates) of the state vector \(x(k)\).

\alert{Linear state feedback} is the control law
\begin{equation*}
\begin{split}
 u(k) &= f\big((x(k), u_c(k)\big) = -l_1x_1(k) - l_2x_2(k) - \cdots - l_n x_n(k) + l_0u_c(k)\\
      &= -Lx(k) + l_0u_c(k),
\end{split}
\end{equation*}
where \[ L = \bbm l_1 & l_2 & \cdots & l_n \ebm. \]
Substituting the control law in the state space model \eqref{eq:ssmodel} gives
 \begin{equation}
 \begin{split}
  x(k+1) &= \left(\Phi -\Gamma L \right) x(k) + l_0\Gamma u_c(k)\\
  y(k) &= C x(k)
 \end{split}
 \label{eq:closedloop}
\end{equation}
\end{frame}

\begin{frame}[label={sec:org71af002}]{Observer design}
Given model
 \begin{equation*}
 \begin{split}
  x(k+1) &= \Phi x(k) + \Gamma u(k)\\
  y(k) &= C x(k)
 \end{split}
 \label{eq:ssmodel}
\end{equation*}
and measurements of the output signal \(y(k)\).

The obserser is given by
\begin{equation*}
\begin{split}
\hat{x}(k+1) &= \underbrace{\Phi \hat{x}(k) + \Gamma u(k)}_{\text{simulation}} + \underbrace{K\big(y(k) - C\hat{x}(k)\big)}_{\text{correction}} = \left(\Phi - KC\right)\hat{x}(k) +  \Gamma u(k) + Ky(k)
\end{split}
\end{equation*}
with poles given by the eigenvalues of the matrix \(\Phi_o = \Phi - KC\)

\alert{Rule-of-thumb} Choose the poles of the observer (eigenvalues of \(\Phi-KC\)) at least twice as fast as the poles (eigenvalues) of \(\Phi-\Gamma L\).
\end{frame}

\begin{frame}[label={sec:org8c2ca3d}]{Observer design}
\alert{Rule-of-thumb} Choose the poles of the observer (eigenvalues of \(\Phi-KC\)) at least twice as fast as the poles (eigenvalues) of \(\Phi-\Gamma L\).

In continuous time (the s-plane), choosing a pole to be twice as fast, means moving the pole to twice the disance from the origin. Given a discrete pole \(p_1\), the discrete pole in
\[ p_2 = \text{exp}\left( 2 \frac{\ln p_1}{h} h\right) = \text{exp} \big( 2 \ln p_1 \big) = p_1^2\]
corresponds to a response that is twice as fast.
\end{frame}

\begin{frame}[label={sec:org71f4946}]{Control by feedback from reconstructed states}
The design problem can be separates into two problems
\begin{enumerate}
\item Determine the gain vector \(\textcolor{orange!80!black}{L}\) and the gain \(l_0\) of the control law
\[ u(k) = -\textcolor{orange!80!black}{L} \hat{x}(k) + l_0 u_c(k)\]
so that the closed-loop system has good reference tracking.
\item Determine the gain vector \(\textcolor{red}{K}\) of the observer
\begin{equation*}
\begin{split}
\hat{x}(k+1) &= \Phi \hat{x}(k) + \Gamma u(k) + \textcolor{red}{K} \big(y(k) - C\hat{x}(k)\big)
\end{split}
\end{equation*}
to get a good balance between disturbance rejection and noise attenuation.
\end{enumerate}
\end{frame}

\begin{frame}[label={sec:orgff3fa4d}]{Computing the observer gain}
A matrix \(M\) and its transpose \(M\transp\) have the same eigenvalues. Hence, the problem of determining the gain \(K\) to obtain desired eigenvalues of
\[\Phi- KC\] is equivalent to determining the gain \(K\) in
\[(\Phi-KC)\transp = \Phi\transp - C\transp K\transp.\]
The last problem has the exact same form as the problem of determining \(L\) to obtain desired eigenvalues of
\[\Phi - \Gamma L\]

So, the same matlab function can be used for both problems.
\end{frame}

\begin{frame}[label={sec:org9d34dd5},fragile]{Computing the observer gain}
 \begin{enumerate}
\item \alert{Ackerman's method}
\begin{verbatim}
K = acker(Phi', C', po)'
\end{verbatim}
\item \alert{More numerically stable method}
\begin{verbatim}
K = place(Phi', C', pd)'
\end{verbatim}
\end{enumerate}
\end{frame}
\end{document}


\documentclass[a4paper,11pt]{article}

\usepackage{physics}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm, mathtools}
%\usepackage{hyperref}
\usepackage{color}
\usepackage{jheppub}
\usepackage[T1]{fontenc} % if needed

% My Documents
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bes}{\begin{equation*}}
\newcommand{\ees}{\end{equation*}}
\newcommand{\bea}{\begin{flalign*}}
\newcommand{\eea}{\end{flalign*}}

%\linespread{1.0}
%\setlength{\parindent}{0em}
%\setlength{\parskip}{0.8em}

\title{\textbf{Notes on General Relativity}}
\author{Aditya Vijaykumar}
\affiliation{International Centre for Theoretical Sciences, Bengaluru, India.}
\emailAdd{aditya.vijaykumar@icts.res.in}

\begin{document}
\maketitle
\section{Tensors}
The Newtonian equations of motion are often phrased in the language of vectors. For example, take Newton's law of gravitation which gives the gravitational force between two bodies of mass $ m_1 $ and $ m_2 $ with a separation vector $ \va{r} $ pointing from $ m_1 $ to $ m_2 $
\begin{equation}\label{key}
\va{F}_{12} = - G \dfrac{m_1 m_2}{\abs{\va{r}}^3} \va{r}  \qq{.}
\end{equation}
Here, $ \va{F}_{12} $ is the force on $ m_2 $ due to $ m_1 $. There are two ways of looking at this equation:
\begin{itemize}
	\item A \textit{coordinate-free way}, where we look at these objects as just vectors. The equations written in this form have the advantage that they don't demand any coordinate system to be chosen.
	\item A \textit{coordinate-dependent way}, where we look at these component-wise.
\end{itemize}

Before diving straight in to general relativity and the Einstein equations, one should be comfortable with the basic mathematical language that the theory is written in -- tensors. One can think of tensors to be a generalization of vectors; in fact, in the formalism we develop, it would be easy to see that vectos are tensors of a specific kind. Tensor equations can also be looked at in a coordinate-free and coordinate-dependent way; but it is the latter that we will choose to work with here.
\subsection{Tensor Algebra}
\subsubsection{Manifolds}
A tensor is a geometrical object defined on a \textit{manifold}. One can define a manifold in a detailed geometric way, but we (hopefully) won't need that for the purposes of these notes. Instead, we will just say that a manifold in $ n $-dimensions is something that \textit{locally} looks like $ n $-dimensional Euclidean (flat) space $\mathbb{R}^n $. As a simple illustration, let's consider a 2-sphere $ S^2 $. $ S^2 $ and $ \mathbb{R}^2 $ are definitely not the same globally. But a small bit of $ S^2 $ does look like $ \mathbb{R}^2 $. For example, even though the earth is (approximately) spherical, we as \textit{local} humans perceieve it as being flat.

A manifold is then simply a set of points such that each point possesses a set of $ n $-coordinates $ (x^1, x^2, \ldots, x^n) $ which are all real numbers. These could be thought of as the counterpart of distances and angles in the Euclidean plane. Too add to this, it might even be impossible to cover a manifold in full by a non-degenerate coordinate system. Take a Euclidean example: plane polar coordinates have a degeneracy at the origin where $ \phi $ becomes indeterminate, though we could make do with Cartesian coordinates in this case. But in other cases, this freedom might not be available. For example, it can be shown that there is no coordinate system that covers the whole of $ S^2 $ without degeneracy. For example, the ``flat'' map of the world (the so called Mercator projection) misses the poles.

As an illustrative example of the above, let's consider the stereographic projection which maps a sphere onto a plane. Let $ A = (x^1, x^2, x^3) $ be the coordinates of a point on the sphere. Consider also the plane $ \mathcal{P} $ defined by $ x^3 = -1 $. The stereographic projection involves drawing a line passing through the north pole and $ A $ and finding the intercept of this line on $ \mathcal{P} $; let's denote the intercept by $ A' = (y^1, y^2) $. We can show that,
\begin{equation}\label{key}
(y^1, y^2) = \qty(\dfrac{2x^1}{1 - x^3}, \dfrac{2x^2}{1 - x^3})
\end{equation}

As can be seen from the above equation, this mapping fails to capture the north pole itself (it maps a finite point onto $ \infty $). For us to include the north pole, we have to redefine the steoreographic mapping by considering a line passing through south pole and $ A $. \textcolor{red}{Think about this a bit more}.

Often, it is convenient to work with only one of these coordinate systems and keep track of the points that aren't included. This coordinate system is called  a coordinate patch, and a set of coordinate patches that covers the entire manifold is called an atlas.

\subsubsection{Curves and Surfaces}
Given a manifold, we would be interested in the subset of points that form curves and surfaces. We shall often define them parametrically. For example, since a curve has one degree of freedom, it will depend only on one \textit{parameter}; we can define it by:
\begin{equation}\label{key}
x^a = x^a(u) \qq{,}
\end{equation}
where $ u $ is the parameter and $ x^1(u), x^2(u), \ldots, x^n(u) $ are all functions of $ u $. Similarly, since a surface of $ m $ dimensions will have m degrees of freedom, we can define it by a set of $ m $ parameters:
\begin{equation}\label{key}
x^a = x^a(u^1, u^2, \ldots, u^m) \qq{.}
\end{equation}
In particular, if $ m=n-1 $, the surface is called a \textit{hypersurface}. Here, one can eliminate $ n-1 $ parameters from $ n $ equations to give one equation connecting the coordinates \textit{ie.},
\begin{equation}\label{hyp}
f(x^1, x^2, \ldots, x^n) = 0 \qq{.}
\end{equation}
Equivalently, if a point on an $ n $-dimensional manifold is constrained to lie on a hypersurface, it should follow eq. \ref{hyp}. Similarly, points on an $ m $-dimensional surface should follow $ n-m $ such constraints.

\subsubsection{Transformation of Coordinates}
While writing down tensor equations, we would like to have it hold in all coordinate systems. Hence, we would like to see how one can realize coordinate transformations.

Let's consider a transformation of coordinates $ x^a $ to $ x'^a =  f^a (x_1, x_2,\ldots, x_n)$, where $ f^a $'s are single-valued, continuous, differentiable functions. We can view this as passively assigning a point with coordinates $ (x^1, x^2,\ldots, x^n) $ the new coordinates $ (x'^1,x'^2, \ldots, x'^n) $. More succintly, we will just use the notation $ x'^a = x'^a(x) $

We now want to see what the transformation will look like. Hence, we differentiate $ x' $ with respect to $ x $ -- this will give us a matrix of coefficients:

\begin{equation}\label{jaco}
\mqty[\pdv{x'^a}{x^b}] = \mqty[\pdv{x'^1}{x^1} & \pdv{x'^1}{x^2} & \ldots & \pdv{x'^1}{x^n} \\
\pdv{x'^2}{x^1} & \pdv{x'^2}{x^2} & \ldots & \pdv{x'^2}{x^n} \\
\vdots & & & \\
\pdv{x'^n}{x^1} & \pdv{x'^n}{x^2} & \ldots & \pdv{x'^n}{x^n}
]
\end{equation}

The determinant of the above transformation matrix is called the Jacobian $ J' $ of the transformation. If we assume that $ J' $ is non-zero, we can solve eq \ref{jaco} and find the inverse transformation $ x^a = x^a(x') $. Using the product rule of determinants, the Jacobian of the inverse transformation $ J = 1/J'$

How would the total differential of $ x'^a $ relate to the transformation matrix? We write,
\begin{equation}\label{difftransform}
\dd{x'^a} = \sum_{b = 1}^{n} \pdv{x'^a}{x^b} \dd{x^b} = \pdv{x'^a}{x^b} \dd{x^b}  \qq{,}
\end{equation}

where we invoke the \textit{Einstein summation convention} to simplify our equations -- we drop the summation altogether and understand that whenever an index is repeated, it should be summed over. This repeated index is also often called the \textit{bound index} or the \textit{dummy index}.

As an aside, we will also define the \textit{Kronecker delta} to be a quantity which is either $ 0 $ or $ 1 $ according to

\begin{equation}\label{key}
\delta^a_b = \begin{cases}
1 \qq{if} a = b\\
0 \qq{if} a \ne b
\end{cases} \implies \pdv{x^a}{x^b} = \pdv{x'^a}{x'^b} = \delta^a_b \qq{.}
\end{equation}

\subsubsection{Contravariant Tensors}
We now want to define geometrical quantities with reference to their transformation properties under transformations described in the previous section. Before defining contravariant tensors in general, let's first define a contravariant vector.

Consider two neighbouring points on a manifold $ P $ and $ Q $ with coordinates $ x^a $ and $ x^a + \dd{x^a} $. This forms an infinitesimal vector $ \va{PQ} $ attached at $ P $ and directed to $ Q $, whose components in this coordinate system are $ \dd{x^a} $. This vector will get transformed to $ \dd{x'^a} $ in the new coordinate system, where $ \dd{x'^a} $ is given by eq. \ref{difftransform}. Note that the transformation matrix in this case will be evaluated at point $ P $.

We then define a \textit{contravariant vector} $ X^a $ as a set of of quantities associated with point $ P $ which transform under a change of coordinates according to

\begin{equation}\label{key}
X'^a = \pdv{x'^a}{x^b} X^b \qq{,}
\end{equation}
with the transformation matrix evaluated at $ P $. This definition of the contravariant vector can then be generalized to \textit{contravariant tensors}. A contravariant tensor of rank $ m $ in $ n $-dimensions is a set of $ n^m $ quantities associated with a point $ P $ that follow a certain transformation law. For illustrative purposes, in case of $ m=2 $, $ X^{ab} $ is a contravariant tensor if,
\begin{equation}\label{key}
X'^{ab} =  \pdv{x'^a}{x^c}  \pdv{x'^b}{x^d} X^{cd} \qq{.}
 \end{equation}
The transformation properties of higher rank tensors can be obtained in an analogous manner. A special case is a tensor of rank zero -- which is basically a scalar! This transforms according to $ \phi' = \phi $.

\subsubsection{Covariant and Mixed Tensors}
Consider a real, continuous, differentiable scalar $ \phi = \phi(x) $. We have seen that $ x^a $ can be written as a function of $ x'^a $. Then, we can imagine differentiating $ \phi $ with respect to $ x'^a $,
\begin{equation}\label{key}
\pdv{\phi}{x'^a} = \pdv{\phi}{x^b} \pdv{x^b}{x'^a} \qq{.}
\end{equation}
Note that this involves the inverse tranformation from a coordinate system $ x' $ to $ x $. This motivates us to define a covariant vector $ X_a $ as a set of quantities that follows
\begin{equation}\label{key}
X'_a = \pdv{x^b}{x'^a} X_b \qq{,}
\end{equation}
and analogously we can define a rank $ 2 $ covariant tensor by the law
\begin{equation}\label{key}
X'_{ab} = \pdv{x^c}{x'^b} \pdv{x^d}{x'^c} X_{cd} \qq{,}
\end{equation}
and so on for higher rank tensors. In the same spirit, we can define mixed tensors of rank $ 3 $ by the law

\begin{equation}\label{key}
X'^{a}_{bc} =  \pdv{x'^a}{x^d} \pdv{x^e}{x'^b} \pdv{x^f}{x'^c} X^d_{ef} \qq{.}
\end{equation}

If a mixed tensor has contravariant rank $ p $ and covariant rank $ q $, it is said to have \textit{type}  or \textit{valence} $ (p,q) $.

Let's say we find two tensors $ X_{ab} $ and $ Y_{ab} $ which are equal component-by-component in a certain coordinate system \textit{ie.} $ X_{ab} = Y_{ab} $. Will the tensors still be equal in a transformed coordinate system? Yes! We can see this by multiplying on both sides by the transformation matrix. In other words, the equality of two tensors would hold true in any and all coordinate systems! We might be interested in introducing coordinate systems for the purposes of a specific problem, but tensorial equations are essentially coordinate-independent.

\subsubsection{Tensor Fields}
In vector analysis, a \textit{vector field} defined in a region is the association of a vector to every point in that region. Analogously, a tensor field defined in a region is the association of a tensor with the same valence to every point in the region; \textit{ie},
\begin{equation}\label{key}
P \rightarrow T^{a \ldots}_{b\ldots} (P) \qq{,}
\end{equation}
where $  T^{a \ldots}_{b\ldots} (P) $ is the value of the tensor at $ P $. As one might expect, the tensor field is called continuous and differentiable if its coordinates are continuous and differentiable functions. The tensor field is called smooth is its components are differentiable to all orders, denoted mathematically by saying that the components are $ C^\infty $.

\subsubsection{Elementary Operations}

\begin{itemize}
	\item $X^a_{bc} = Y^a_{bc} + Z^a_{bc}$
	\item $ X^a_{bc} = \alpha W^a_{bc} $, where $ \alpha $ is a scalar.
	\item A covariant tensor of rank $ 2 $,  $ X_{ab} $, is said to be symmetric if $ X_{ab} = X_{ba} $. In this case, it has $ \frac{n(n+1)}{2} $ independent components.
	\item A covariant tensor of rank $ 2 $,  $ X_{ab} $, is said to be anti-symmetric if $ X_{ab} = -X_{ba} $. In this case, it has $ \frac{n(n-1)}{2} $ independent components.
	\item Given a covariant tensor of rank $ 2 $, one can write it as a sum of a symmetric tensor and an anti-symmetric tensor,
	\begin{align*}
	X_{ab} = &X_{(ab)} + X_{[ab]} \qq{,} \\
	\qq{where} X_{(ab)} = \dfrac{X_{ab} + X_{ba}}{2} &\qq{and} X_{[ab]} = \dfrac{X_{ab} - X_{ba}}{2} \qq{.}
	\end{align*}
	\item In general,
	\begin{align*}
		X_{(a_1 a_2 \ldots a_r)} &= \dfrac{1}{r!} \text{(sum over all permutations of indices)} \\
		X_{[a_1 a_2 \ldots a_r]} &= \dfrac{1}{r!} \text{(alternating sum over all permutations of indices)} 	\qq{.}
	\end{align*}
	For example,
	\begin{equation}\label{key}
	X_{[abc] }  = \dfrac{1}{6!} \qty(X_{abc} -X_{acb} + X_{cab} - X_{cba} + X_{bca} - X_{bac}) \qq{.}
	\end{equation}
	\item We can multiply a type $ (p_1, q_1) $ tensor and a type $ (p_2, q_2) $ tensor to get a type $ (p_1+p_2, q_1+q_2) $ tensor, \textit{eg.} $ X^a_{bcd}  = Y^a_b Z_{cd}$

	\item Given a tensor of type $ (p,q) $, we can construct a type $ (p-1, q-1) $ tensor by the process of contraction \textit{ie} said a raised index equal to the lower index, \textit{eg} $ X^{a}_{bcd} \rightarrow_{contraction}  X^{a}_{acd}  = \delta_a^b X^{a}_{acd} = Y_{cd}$.

\end{itemize}

\subsubsection{Index-free interpretation of covariant tensor fields}

In the $ x^a $-coordinate system, let's introduce the following notation,
\begin{equation}\label{key}
\partial_a = \pdv{x^a} \qq{.}
\end{equation}
We then define an operator $ X $ as,
\begin{equation}\label{key}
X = X^a \partial_a \implies Xf = X^a \partial_a f = X^a (\partial_a f) \qq{,}
\end{equation}
where $ f $ is an arbitrary real-valued function. It can be proved that the operator $ X $ is does not depend on the choice of the coordinate system and hence $ X = X^a \pdv{x^a} =X'^a \pdv{x'^a}  $. Hence, operating $ X $ on $ f $ will lead to the same result irrespective of the coordinate system used.

Since any vector at $ P $ is given by the above equation, we can think of the quantities $ [\partial_a]_P $ as forming the basis for all the vectors at $ P $, and $ [X^a]_P $ being the components. The vector space of all the contravariant vectors at $ P $ is called the \textit{tangent space} at $ P $ and it denoted by $T_P(M)$.

Given two vector fields $ X $ and $ Y $, we can define a new vector field called the \textit{commutator} or the \textit{Lie bracket} of $ X $ and $ Y $ by
\begin{equation}\label{key}
\qty[X, Y] = XY - YX \qq{.}
\end{equation}
How are we sure the commutator is indeed a vector field? Consider the action of the commutator on a scalar function $ f $,
\begin{align*}
	\qty[X, Y] f &= XYf - YXf \\
	&= X^a \partial_a ( Y^b \partial_b f  ) - Y^b \partial_b (X^a \partial_a ) f \\
	&=\qty(X^a \partial_a Y^b \partial_b    - Y^b \partial_b X^a \partial_a ) f  + \qty(X^a Y^b \partial_a  \partial_b f - Y^b X^a \partial_b \partial_a f) \\
	& = \qty(X^b \partial_b Y^a     - Y^b \partial_b X^a ) \partial_a f \qq{,}
\end{align*}
which proves that $ \qty[X,Y] $ is a vector field.

The properties of the Lie bracket are:
\begin{itemize}
	\item  $ \qty[X,X] = 0 $
	\item $ \comm{X}{Y} = - \comm{Y}{X} $
	\item \textit{Jacobi Identity}: $ \comm{X}{\comm{Y}{Z}} + \comm{Y}{\comm{Z}{X}} + \comm{Z}{\comm{X}{Y}} = 0 $
\end{itemize}

\subsection{Tensor Calculus}
\subsubsection{Partial Differentiation of Tensors does not yield a Tensor}

Consider,
\begin{align}
\partial'_c X'^a &= \pdv{x'^c} \qty(\pdv{x'^a}{x^b} X^b) \\
&= \pdv{x^d}{x'^c} \pdv{x^d} \qty(\pdv{x'^a}{x^b} X^b) \\
&= \pdv[2]{x'^a}{x^b}{ x^d} \pdv{x^d}{x'^c} X^b + \pdv{x^d}{x'^c} \pdv{x'^a}{x^b} \pdv{X^b}{x^d}
\end{align}
This exercise clearly shows that the partial derivative \textit{does not} transform as a tensor.

Why is this so? Taking a partial derivative really means taking the difference between two points $ P $ and $ Q $, dividing it by the separation, and taking the limit as separation goes to zero. The transformation law of tensors depends on each point, hence the difference of two vectors can have different magnitudes in different coordinate systems. So, the difference of two vectors \textit{is not a vector}, and hence the derivative of a tensor does not transform as a vector in general.

\subsubsection{The Lie Derivative}
A \textit{congruence of curves} is defined as a set of curves such that exactly one curve passes through a given point on the manifold. This is denoted by $ x^a = x^a(u) $. Given this, we can define the tangent vector field $ \dv{x^a}{u} $ along the curve. Doing this for every curve in the congruence, we end up with a vector field $ X^a $ given by $ \dv{x^a}{u} $ at each point and defined over the whole manifold.

Conversely, we can think of a vector field $ X^a(u) $ defined on the manifold and can then define a congruence of curves on the manifold, called \textit{orbits} or \textit{trajectories} of $ X^a $. These curves can be obtained by solving the equation
\begin{equation}\label{key}
\dv{x^a}{u} = X^a(x(u)) \qq{.}
\end{equation}

Say we have an arbitrary tensor $ T^{a \ldots}_{b \ldots} $ and quantities $ T_P $ and $ T_Q $ defined at two points $ P $ and $ Q $.

\end{document}