\documentclass[aspectratio=169,9pt]{beamer}
%	***********
%	* PACKAGE *
%	***********
\usepackage{amsmath,amssymb,amsfonts,pgfpages,graphicx,subfigure,xcolor,bm,multirow,microtype,wasysym,multimedia,hyperref,tabularx,amscd,pgfgantt,mhchem}
\usetikzlibrary{shapes.gates.logic.US,trees,positioning,arrows}
\usetheme{Pittsburgh}
\usecolortheme{seahorse}
\usepackage{mathpazo,libertine}

\usepackage{algorithmicx,algorithm,algpseudocode}
\algnewcommand\algorithmicassert{\texttt{assert}}
\algnewcommand\Assert[1]{\State \algorithmicassert(#1)}
%\algrenewcommand{\algorithmiccomment}[1]{$\triangleright$ #1}

%\usepackage[version=4]{mhchem}
\usepackage{amsmath,amsfonts,amssymb,bm,microtype,graphicx,wrapfig,geometry,physics,eurosym,multirow,pgfgantt}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=cyan,
    filecolor=magenta,
    urlcolor=blue,
    citecolor=purple
}

% operators
\newcommand{\hI}{\Hat{1}}
\newcommand{\hH}{\Hat{H}}
\newcommand{\hT}[2]{\Hat{T}_{#1}^{#2}}
\newcommand{\bH}{\mathbold{H}}
\newcommand{\br}{\mathbold{r}}
\newcommand{\la}{\lambda}
\newcommand{\si}{\sigma}

\newcommand{\cJ}{\mathcal{J}}
\newcommand{\cK}{\mathcal{K}}

% wave functions
\newcommand{\PsiO}{\Psi_0}
\newcommand{\PsiHF}{\Psi_\text{RHF}}
\newcommand{\PsiFCI}{\Psi_\text{FCI}}
\newcommand{\PsiCC}{\Psi_\text{CC}}
\newcommand{\PsiCCD}{\Psi_\text{CCD}}

\newcommand{\amp}[2]{t_{#1}^{#2}}
\newcommand{\Det}[2]{\Psi_{#1}^{#2}}

% energies
\newcommand{\EHF}{E_\text{HF}}
\newcommand{\EO}{E_\text{0}}
\newcommand{\ECC}{E_\text{CC}}
\newcommand{\EVCC}{E_\text{VCC}}
\newcommand{\ECCD}{E_\text{CCD}}

\newcommand{\nEl}{n}
\newcommand{\nBas}{N}

\newcommand{\ba}{\bm{a}}
\newcommand{\bb}{\bm{b}}
\newcommand{\bA}{\bm{A}}
\newcommand{\bB}{\bm{B}}
\newcommand{\bo}{\bm{0}}
\newcommand{\sbra}[1]{[ #1 |}
\newcommand{\sket}[1]{| #1 ]}
\newcommand{\sexpval}[1]{[ #1 ]}
\newcommand{\sbraket}[2]{[ #1 | #2 ]}
\newcommand{\smel}[3]{[ #1 | #2 | #3 ]}


\definecolor{darkgreen}{RGB}{0, 180, 0}
\definecolor{fooblue}{RGB}{0,153,255}
\definecolor{fooyellow}{RGB}{234,187,0}
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\definecolor{inchworm}{rgb}{0.7, 0.93, 0.36}
\newcommand{\violet}[1]{\textcolor{lavender}{#1}}
\newcommand{\orange}[1]{\textcolor{orange}{#1}}
\newcommand{\purple}[1]{\textcolor{purple}{#1}}
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
\newcommand{\green}[1]{\textcolor{darkgreen}{#1}}
\newcommand{\yellow}[1]{\textcolor{fooyellow}{#1}}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\newcommand{\highlight}[1]{\textcolor{fooblue}{#1}}
\newcommand{\pub}[1]{\small \textcolor{purple}{#1}}
\newcommand{\mc}{\multicolumn}

\newcommand{\mycirc}[1][black]{\Large\textcolor{#1}{\ensuremath\bullet}}

\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\usetikzlibrary{decorations.pathmorphing}

\tikzset{snake it/.style={
decoration={snake, 
    amplitude = .4mm,
    segment length = 2mm},decorate}}
    

%	*************
%	* HEAD DATA *
%	*************
	\title[HF and post-HF methods]{
		\purple{Hartree-Fock and post-Hartree-Fock methods: \\
		Computational aspects}
	} 

	\author[PF Loos]{Pierre-Fran\c{c}ois LOOS}
	\date{Online ISTPC 2021 school --- April 27th, 2021}
	\institute[CNRS@LCPQ]{	
		Laboratoire de Chimie et Physique Quantiques (UMR 5626),\\
		Universit\'e de Toulouse, CNRS, UPS, Toulouse, France.
	}     
	\titlegraphic{
		\includegraphics[width=0.3\textwidth]{fig/peppa}
		\\
		\vspace{0.05\textheight}
		\includegraphics[height=0.05\textwidth]{fig/UPS}
		\hspace{0.2\textwidth}
		\includegraphics[height=0.05\textwidth]{fig/ERC}
		\hspace{0.2\textwidth}
		\includegraphics[height=0.05\textwidth]{fig/LCPQ}
		\hspace{0.2\textwidth}
		\includegraphics[height=0.05\textwidth]{fig/CNRS}
	}             

\begin{document}

%%% SLIDE 1 %%%
\begin{frame}
	\titlepage
\end{frame}
%

%%% SLIDE 2 %%%
\begin{frame}{Today's program}
	\begin{itemize}
		\item How to perform a Hartree-Fock (HF) calculation in practice?
		\begin{itemize}
			\item Computation of integrals \pub{[Ahlrichs, PCCP 8 (2006) 3072]}
			\item Orthogonalization matrix \pub{[Szabo \& Ostlund, Modern Quantum Chemistry]}
			\item Construction of the Coulomb matrix \pub{[White \& Head-Gordon, JCP 104 (1996) 2620]}		
			\item Resolution of the identity \pub{[Weigend et al. JCP 130 (2009) 164106]}			
			\item DFT exchange via quadrature \pub{[Becke, JCP 88 (1988) 2547]}			
		\end{itemize}
		\bigskip
		\item Computing the 2th-order M{\o}ller-Plesset (MP2) correlation energy
		\begin{itemize}
			\item Atomic orbital (AO) to molecular orbital (MO) transformation \pub{[Frisch et al. CPL 166 (1990) 281]}
			\item Laplace transform \pub{[Alml{\"o}f, CPL 181 (1991) 319]}
		\end{itemize}
		\bigskip
		\item Coupled cluster with doubles (CCD)
		\begin{itemize}
			\item Introduction to CC methods \pub{[Shavitt \& Bartlett, \textit{``Many-Body Methods in Chemistry and Physics: MBPT and Coupled-Cluster Theory''}]}
			\item Algorithm to compute the CCD energy \pub{[Pople et al. IJQC 14 (1978) 545]}
		\end{itemize}
	\end{itemize}
\end{frame}



%%% SLIDE X %%%
\begin{frame}{How to perform a HF calculation in practice?}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{block}{The SCF algorithm (p.~146)}
				\begin{enumerate}
					\item \orange{Specify molecule} $\{\br_A\}$ and $\{Z_A\}$ and \violet{basis set} $\{\phi_\mu\}$ 
					\item Calculate integrals $S_{\mu \nu}$, $H_{\mu \nu}$ and $\langle \mu \nu | \lambda \sigma \rangle$
					\item Diagonalize $\bm{S}$ and compute $\bm{X} = \bm{S}^{-1/2}$
					\item Obtain \alert{guess density matrix} for $\bm{P}$
					\begin{enumerate}
						\item[1.] Calculate $\bm{J}$ and $\bm{K}$, then $\bm{F} = \bm{H} + \bm{J} + \bm{K}$
						\item[2.] Compute $\bm{F}' = \bm{X}^\dag \cdot  \bm{F} \cdot  \bm{X}$
						\item[3.] Diagonalize $\bm{F}'$ to obtain $\bm{C}'$ and $\bm{E}$
						\item[4.] Calculate $\bm{C}= \bm{X} \cdot  \bm{C}'$
						\item[5.] Form a \blue{new density matrix} $\bm{P} = \bm{C} \cdot \bm{C}^\dag$
						\item[6.] \alert{Am I converged?} If not go back to 1.
					\end{enumerate}
					\item Calculate stuff that you want, like $E_\text{HF}$ for example
				\end{enumerate}
			\end{block}
		\end{column}
		\begin{column}{0.3\textwidth}
			\includegraphics[width=\textwidth]{fig/Szabo}
		\end{column}
	\end{columns}
\end{frame}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{One- and two-electron integrals}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{block}{One-electron integrals: overlap \& core Hamiltonian (Appendix A)}
				\begin{equation}
					S_{\mu\nu} 
					= \braket{\mu}{\nu}
					= \int \phi_\mu(\orange{\br}) \phi_\nu(\orange{\br}) d\orange{\br}
				\end{equation}
				\begin{equation}
					H_{\mu\nu} 
					= \mel{\mu}{\hH^\text{c}}{\nu}
					= \int \phi_\mu(\orange{\br}) \hH^\text{c}(\orange{\br}) \phi_\nu(\orange{\br}) d\orange{\br}
				\end{equation}
			\end{block}
		\end{column}
		\begin{column}{0.3\textwidth}
			\includegraphics[width=\textwidth]{fig/SBG}
		\end{column}
	\end{columns}	\begin{block}{Chemist/Mulliken notation for two-electron integrals (p.~68)}
		\begin{equation}
			( \mu \nu | \lambda \sigma ) 
			= \iint \phi_\mu(\alert{\br_1}) \phi_\nu(\alert{\br_1}) \frac{1}{r_{12}} \phi_\lambda(\blue{\br_2}) \phi_\sigma(\blue{\br_2}) d\red{\br_1} d\blue{\br_2} 
		\end{equation}
		\begin{equation}
			( \mu \blue{\nu} \orange{||} \lambda \red{\sigma} ) = ( \mu \blue{\nu} | \lambda \red{\sigma} ) - ( \mu \red{\sigma} | \lambda \blue{\nu} )
		\end{equation}
	\end{block}
	\begin{block}{Physicist/Dirac notation for two-electron integrals (p.~68)}
		\begin{equation}
			\langle \mu \nu | \lambda \sigma \rangle 
			= \iint \phi_\mu(\alert{\br_1}) \phi_\nu(\blue{\br_2}) \frac{1}{r_{12}} \phi_\lambda(\alert{\br_1}) \phi_\sigma(\blue{\br_2}) d\red{\br_1} d\blue{\br_2}
		\end{equation}
		\begin{equation}
			\langle \mu \nu \orange{||} \blue{\lambda} \red{\sigma} \rangle =  \langle \mu \nu | \blue{\lambda} \red{\sigma} \rangle -  \langle \mu \nu |  \red{\sigma} \blue{\lambda} \rangle
		\end{equation}
	\end{block}
\end{frame}


\begin{frame}{Computing the electron repulsion integrals (ERIs)}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{block}{Four-center two-electron integrals}
				\small
				\begin{equation}
					\begin{split} 
						\braket{\ba_1\ba_2}{\bb_1\bb_2}	
						& \equiv \mel{\ba_1\ba_2}{\alert{r_{12}^{-1}}}{\bb_1\bb_2}	
						\\
						& = \iint \phi_{\ba_1}^{\bA_1}(\br_1) \phi_{\ba_2}^{\bA_2}(\br_2) \,\alert{\frac{1}{r_{12}}}  \,
						\phi_{\bb_1}^{\bB_1}(\br_1) \phi_{\bb_2}^{\bB_2}(\br_2) d\br_1 d\br_2
					\end{split}
				\end{equation}
				\alert{Formally, one has to compute $\order{N^4}$ ERIs!}
			\end{block}
		\end{column}
		\begin{column}{0.3\textwidth}
			\includegraphics[width=\textwidth]{fig/STO}
		\end{column}
	\end{columns}
			%
			\begin{block}{Gaussian-type orbital (GTO)}
				\small
				\begin{align*} 
					\text{\violet{Contracted} GTO} & = \ket{\ba}
					\equiv \phi_{\ba}^{\bA}(\br)
					=  \sum_k^K D_k \sket{\ba}_k
					\\
					\text{\blue{Primitive} GTO} & =  \sket{\ba}
					=  (x-A_x)^{a_x} (y-A_y)^{a_y} (z-A_z)^{a_z} e^{-\alpha \abs{ \br -\bA }^2}
				\end{align*} 
			\end{block}
	\begin{itemize}
		\item \textbf{\purple{Exponent:}} $\alpha$
		\item \textbf{\purple{Center:}} $\bA = (A_x, A_y, A_z)$
		\item \textbf{\purple{Angular momentum:}} $\ba = (a_x, a_y, a_z)$ and total angular momentum $a=a_x + a_y + a_z$
	\end{itemize}
	%
\end{frame}

\begin{frame}{The contraction problem}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{block}{Primitive vs Contracted}
				\begin{itemize}
					\item Same center $\bA$
					\item Same angular momentum $\ba$
					\item Different exponent $\violet{\alpha_k}$
					\item Contraction coefficient $\blue{D_k}$ and degree $K$
				\end{itemize}
				\begin{equation}
					\underbrace{\braket{\ba_1\ba_2}{\bb_1\bb_2}}_{\text{\green{contracted ERI}}} 
					= \sum_{k_1}^{K_1} \sum_{k_2}^{K_2} \sum_{k_3}^{K_3} \sum_{k_4}^{K_4} 
					\blue{D_{k_1} D_{k_2} D_{k_3} D_{k_4}}
					\underbrace{\sbraket{\ba_{1,k_1}\ba_{2,k_2}}{\bb_{1,k_3}\bb_{2,k_4}}}_{\text{\red{primitive ERI}}} 
				\end{equation}
				\centering
				\green{One} contracted ERI required \red{$K_1 \times K_2 \times K_3 \times K_4$} primitive ERIs!
			\end{block}
			\begin{block}{Dunning's cc-pVTZ basis for the carbon atom}
				\begin{equation}
					\green{\braket{1s1s}{1s1s}}
					= \sum_{k_1}^{10} \sum_{k_2}^{10} \sum_{k_3}^{10} \sum_{k_4}^{10} 
					\blue{D_{k_1} D_{k_2} D_{k_3} D_{k_4}}
					\red{\sbraket{s_{k_1}^{\violet{\alpha_{k_1}}} s_{k_2}^{\violet{\alpha_{k_2}}}} {s_{k_3}^{\violet{\alpha_{k_3}}} s_{k_4}^{\violet{\alpha_{k_4}}} }} 
				\end{equation}
				\centering
				The $\green{\braket{1s1s}{1s1s}}$ integral requires $10^4$ \red{$s$-type integrals}!
			\end{block}
		\end{column}
		\begin{column}{0.3\textwidth}
			\begin{equation}
				\boxed{\green{\ket{\ba}} = \sum_k^K \blue{D_k} \red{\sket{\ba_k}}}
			\end{equation}
			\\
			\bigskip
			\begin{block}{https://www.basissetexchange.org}
				\bigskip
				\centering
				\includegraphics[width=\textwidth]{fig/C}
			\end{block}
		\end{column}
	\end{columns}
\end{frame}

%%% SLIDE X %%%
\begin{frame}{Properties of Gaussian functions}
	\begin{block}{Gaussian product rule: \textit{``The product of two gaussians is a gaussian''}}
		\begin{equation}
			G_{\red{\alpha},\red{\bm{A}}}(\br) = \exp(-\red{\alpha} \abs{\br - \red{\bA}}^2)	
			\qqtext{and}
			G_{\blue{\beta},\blue{\bm{B}}}(\br) = \exp(-\blue{\beta} \abs{\br - \blue{\bB}}^2)	
			\qqtext{then}
		\end{equation}	
		\begin{equation}
		\boxed{G_{\red{\alpha},\red{\bm{A}}}(\br) G_{\blue{\beta},\blue{\bm{B}}}(\br) = \violet{K} \, G_{\violet{\zeta},\violet{\bm{P}}}(\br)}
		\qqtext{with} 
		\violet{\zeta} = \red{\alpha} + \blue{\beta} 
		\qqtext{and} 
		\violet{\bm{P}} = \frac{\red{\alpha \bA} + \blue{\beta \bB}}{\red{\alpha} + \blue{\beta} } 
		\end{equation}		
		\begin{equation}
			\violet{K} = \exp( -\frac{\red{\alpha} \blue{\beta}}{\red{\alpha} + \blue{\beta} } \abs{\red{\bA} - \blue{\bB}}^2)
		\end{equation}		
	\end{block}
	\begin{block}{Gaussian product rule for ERIs}
		\begin{equation}
			\begin{split}
			(\bm{\red{a}} \bm{\blue{b}}|\bm{\orange{c}} \bm{\green{d}}) 
			& = \iint G_{\red{\alpha},\red{\bm{A}}}(\br_1) G_{\blue{\beta},\blue{\bm{B}}}(\br_1) \frac{1}{r_{12}} G_{\orange{\gamma},\orange{\bm{C}}}(\br_2) G_{\green{\delta},\green{\bm{D}}}(\br_2) d\br_1 d\br_2
			\\
			& = \violet{K} \purple{K} \iint G_{\violet{\zeta},\violet{\bm{P}}}(\br_1) \frac{1}{r_{12}} G_{\purple{\eta},\purple{\bm{Q}}}(\br_2) d\br_1 d\br_2
		\end{split}	
		\end{equation}	
		\alert{The number of ``significant'' ERIs in a large system is $\order{N^2}$!}
	\end{block}
\end{frame}
%

\begin{frame}{Upper bounds for ERIs}
	\begin{columns}
		\begin{column}{0.35\textwidth}
			\begin{block}{A ``good'' upper bound must be}
				\begin{itemize}
					\item tight (i.e., a good estimate)
					\item simple (i.e, cheap to compute)
					\end{itemize}
			\end{block}
		\end{column}
		\begin{column}{0.65\textwidth}
		\begin{equation}
			\boxed{\abs{(\bm{\red{a}} \bm{\blue{b}}|\bm{\orange{c}} \bm{\green{d}})} \le B}
		\end{equation}
		\end{column}
	\end{columns}
	\bigskip
	\begin{block}{Cauchy-Schwartz bound}
		\begin{equation}
			\abs{(\bm{\red{a}} \bm{\blue{b}}|\bm{\orange{c}} \bm{\green{d}})} 
			\le 
			\sqrt{(\bm{\red{a}} \bm{\blue{b}}|\bm{\red{a}} \bm{\blue{b}})} 
			\sqrt{(\bm{\orange{c}} \bm{\green{d}}|\bm{\orange{c}} \bm{\green{d}})}
			\qqtext{or}
			\abs{(\bm{\violet{P}}|\bm{\purple{Q}})} 
			\le 
			\sqrt{(\bm{\violet{P}}|\bm{\violet{P}})} 
			\sqrt{(\bm{\purple{Q}}|\bm{\purple{Q}})}
		\end{equation}
	\end{block}
	\begin{block}{The family of generalized H\"older bounds}
		\begin{equation}
			\abs{(\bm{\red{a}} \bm{\blue{b}}|\bm{\orange{c}} \bm{\green{d}})} 
			\le 
			\qty[ (\bm{\red{a}} \bm{\blue{b}}|\bm{\red{a}} \bm{\blue{b}}) ]^{1/\purple{m}} 
			\qty[ (\bm{\orange{c}} \bm{\green{d}}|\bm{\orange{c}} \bm{\green{d}}) ]^{1/\violet{n}}
			\qqtext{with}
			\frac{1}{\purple{m}} + \frac{1}{\violet{n}} = 1
			\qqtext{and}
			\purple{m},\violet{n} > 1
		\end{equation}
	\end{block}
\end{frame}


\begin{frame}{Asymptotic scaling of two-electron integrals}
	\begin{block}{Number of significant two-electron integrals}
		\begin{equation}
			(\bm{\red{a}} \bm{\blue{b}}|\bm{\orange{c}} \bm{\green{d}}) \equiv (\bm{\red{a}} \bm{\blue{b}}| \mathcal{O}_2 | \bm{\orange{c}} \bm{\green{d}})
		\end{equation}
	\end{block}
	\bigskip
	\begin{block}{Long-range vs short-range operators}
		\begin{equation}
			N_\text{sig} =  c\,N^{\alpha}
		\end{equation}
		\center
		\begin{tabular}{lcrccrc}
			\hline
			\hline
			Molecule			& 	$N$ 	& 	\mc{2}{c}{\red{$\mathcal{O}_2 = r_{12}^{-1}$}} 		&& 	\mc{2}{c}{\orange{$\mathcal{O}_2 = e^{-\la r_{12}^2}$ ($\la = 1$)}} 		 	\\
										\cline{3-4}								\cline{6-7}					
							& 		& 	\mc{1}{c}{$N_\text{sig}$}	& $\alpha$ 	&& 	\mc{1}{c}{$N_\text{sig}$}	& $\alpha$ 	 \\
			\hline
			propene			&	12	&	1\,625		&	---		&&	1\,650		&	---			\\
			butadiene			&	16	&	5\,020		&	3.9		&&	5\,020		&	3.9			\\
			hexatriene			&	24	&	24\,034		&	3.9		&&	23\,670		&	3.8			\\
			octatetraene		&	32	&	63\,818		&	3.4		&&	52\,808		&	2.8			\\
			decapentaene		&	40	&	119\,948		&	2.8		&&	81\,404		&	1.9			\\
			dodecaexaene		& 	48	&	192\,059		&	2.6		&&	109\,965		&	1.6			\\
			\hline
			\hline
		\end{tabular}
		\bigskip
	\end{block}
\end{frame}


\begin{frame}{Recipe for computing two-electron integrals}
\center
\begin{tikzpicture}
	\begin{scope}[very thick,
		node distance=4cm,on grid,>=stealth',
		boxRR/.style={rectangle,draw,fill=green!40},
		boxUB/.style={rectangle,draw,fill=orange!40},
		boxFI/.style={rectangle,draw,fill=red!40},
		integral/.style={rectangle,draw,fill=violet!40}],
		\node [integral, align=center]		(1)					{\textbf{The cake:} \\ Two-electron integrals \\ $\braket{\ba_1 \ba_2}{ \bb_1 \bb_2}$};
		\node [boxUB, align=center]		(2A)		[below=of 1]	{\textbf{Ingredient number 2:} \\ Recurrence relations \\ $\expval*{\ba_1^+} = \expval*{\ba_1} + \expval*{\ba_1^-}$};
		\node [boxRR, align=center] 		(2B)		[right=of 2A]	{\textbf{Ingredient number 3:} \\ Upper bounds \\ $\abs{\braket{\ba_1 \ba_2}{ \bb_1 \bb_2}} \le B$};
		\node [boxFI, align=center]		(2C)		[left=of 2A]	{\textbf{Ingredient number 1:} \\ Fundamental integrals \\ $\braket{\bo\bo}{\bo\bo}^{\bm{m}}$};
		\path 
		(1) edge [<-]			(2A)
		(1) edge [<-,bend right]			(2B)
		(1) edge [<-,bend left]					(2C)
		;
	\end{scope}
\end{tikzpicture}
\end{frame}

\begin{frame}{Late-contraction path algorithm (Head-Gordon-Pople \& PRISM inspired)}
	\begin{tikzpicture}
		\begin{scope}[
			very thick,
			node distance=1.5cm,on grid,>=stealth',
			boxSP/.style={rectangle,draw,fill=purple!40},
			box0m/.style={rectangle,draw,fill=red!40},
			boxCm/.style={rectangle,draw,fill=gray!40},
			boxA/.style={rectangle,draw,fill=red!40},
			boxAA/.style={rectangle,draw,fill=red!40},
			boxAAA/.style={rectangle,draw,fill=red!40},
			boxC/.style={rectangle,draw,fill=gray!40},
			boxCC/.style={rectangle,draw,fill=gray!40},
			boxCCC/.style={rectangle,draw,fill=orange!40},
			boxCCCCCC/.style={rectangle,draw,fill=green!40},
			],
			\node [boxSP, align=center]			(SP)									{Shell-pair \\ data};
			\node [box0m, align=center]			(0m)			[right=of 1,xshift=1.25cm]		{$\sbraket{00}{00}^{\bm{m}}$};
			\node [boxCm, align=center]			(Cm)			[right=of 0m,xshift=1.75cm]	{$\braket{00}{00}^{\bm{m}}$};
			\node [boxA, align=center] 			(A)			[below=of 0m]				{$\sbraket{0 a_2}{00}^{\bm{m}}$};
			\node [boxC, align=center] 			(C)			[right=of A,xshift=1.75cm]		{$\braket{0 a_2}{00}^{\bm{m}}$};
			\node [boxAA, align=center] 			(AA)			[below=of A]				{$\sbraket{a_1 a_2}{00}$};
			\node [boxCC, align=center] 			(CC)			[right=of AA,xshift=1.75cm]	{$\braket{a_1 a_2}{00}$};
			\node [boxCCCCCC, align=center] 		(CCCC)	[right=of CC,xshift=2cm]		{$\braket{a_1 a_2}{b_1 b_2}$};
			\path 
			(SP)		edge[->]			node[below,blue]{T$_0$}									(0m)
			(0m)		edge[->]			node[left,orange]{T$_1$}			node [right,red]{VRR$_1$}	(A)
			(0m)		edge[->,gray!70]														(Cm)
			(A)		edge[->]			node[left,orange]{T$_2$}			node [right,red]{VRR$_2$}	(AA)
			(A)		edge[->,gray!70]														(C)
			(AA)		edge[->]			node [below,blue]{CC}											(CC)
			(Cm)		edge[->,gray!70]														(C)
			(C)		edge[->,gray!70]														(CC)
			(CC)	edge[->]			node [above,orange]{T$_3$}		node [below,red]{HRR}		(CCCC)
			;
		\end{scope}
	\end{tikzpicture}
	\bigskip
	\begin{itemize}
		\item \red{HRR} = horizontal recurrence relation [Obara-Saika]
		\item \red{VRR} = vertical recurrence relation
		\item \blue{CC} = bra contraction
	\end{itemize}
\end{frame}

%\begin{frame}{Screening algorithm for two-electron integrals}
%
%\resizebox{\textwidth}{!}{
%\begin{tikzpicture}
%	\begin{scope}[very thick,
%		node distance=2.5cm,on grid,>=stealth',
%		bound2/.style={diamond,draw,fill=blue!40},
%		bound4/.style={diamond,draw,fill=blue!40},
%		bound6/.style={diamond,draw,fill=blue!40},
%		shell/.style={circle,draw,fill=green!40},
%		shellpair/.style={circle,draw,fill=green!40},
%		shellquartet/.style={circle,draw,fill=green!40},
%		shell1/.style={rectangle,draw,fill=yellow!40},
%		shell2/.style={rectangle,draw,fill=orange!40},
%		shell3/.style={rectangle,draw,fill=red!40},
%		integral/.style={rectangle,draw,fill=violet!40}],
%		\node [shell1, align=center]		(1)											{Primitive\\shells\\$\sket{a}$};
%		\node [bound2, align=center] 		(B2)			[right=of 1]				{$\sexpval{B_2}$};
%		\node [shell, align=center]			(S1T)		[above=of B2, yshift=-0.5cm]	{$\sket{a}$};
%		\node [shell, align=center]			(S1B)		[below=of B2, yshift=0.5cm]		{$\sket{b}$};
%		\node [shell2, align=center] 		(2)			[right=of B2,xshift=0.75cm]		{Contracted\\shell-pairs\\$\ket{ab}$};
%		\node [bound4, align=center]		(B4)			[right=of 2]				{$\expval{B_4}$} ;
%		\node [shellpair, align=center]		(S2T)		[above=of B4, yshift=-0.5cm]	{$\ket{a_1b_1}$};
%		\node [shellpair, align=center]		(S2B)		[below=of B4, yshift=0.5cm]		{$\ket{a_2b_2}$};
%		\node [shell3, align=center]		(3)			[right=of B4]					{Two-Electron\\integrals\\$\braket{a_1b_1}{a_2b_2}$};
%		\path 
%		(1) edge [->,bend left]				(S1T)
%		(1) edge [->,bend right]			(S1B)
%		(S1T) edge [snake it]				(B2)
%		(S1B) edge [snake it]				(B2)
%		(B2) edge [->,color=red] 	node [below] {\small Contraction}		(2)
%		(2) edge [->,bend left] 				(S2T)
%		(2) edge [->,bend right] 			(S2B)
%		(S2T) edge [snake it]				(B4)
%		(S2B) edge [snake it]				(B4)
%		(B4) edge [->] 					(3)
%		;
%	\end{scope}
%\end{tikzpicture}
%}
%\end{frame}

\begin{frame}{Orthogonalization matrix}
	\red{\bf We are looking for a matrix in order to orthogonalize the AO basis, i.e.~$\bm{X}^\dag \cdot \bm{S} \cdot  \bm{X} = \bm{1}$}
	\\
	\bigskip
	\begin{block}{Symmetric (or L\"owdin) orthogonalization}
		\begin{equation}
			\text{$\bm{X} =\bm{S}^{-1/2} = \bm{U} \cdot  \bm{s}^{-1/2} \cdot  \bm{U}^\dag$ is one solution...}
		\end{equation}
		\purple{\bf Is it working?}
		\begin{equation}
			\bm{X}^\dag \cdot \bm{S} \cdot \bm{X} 
			= \bm{S}^{-1/2} \cdot \bm{S} \cdot \bm{S}^{-1/2} 
			= \bm{S}^{-1/2} \cdot \bm{S} \cdot \bm{S}^{-1/2} 
			= \bm{I} \quad \green{\checkmark}
		\end{equation}
	\end{block}
	\begin{block}{Canonical orthogonalization}
		\begin{equation}
			\text{$\bm{X} =\bm{U} \cdot \bm{s}^{-1/2}$ is another solution (when you have linear dependencies)...}
		\end{equation}
			\purple{\bf Is it working?}
		\begin{equation}
			\bm{X}^\dag \cdot \bm{S} \cdot  \bm{X} 
			= \bm{s}^{-1/2} \cdot \underbrace{\bm{U}^{\dag} \cdot \bm{S} \cdot \bm{U}}_{\bm{s}} \cdot \bm{s}^{-1/2} 
			= \bm{I} \quad \green{\checkmark}
		\end{equation}
	\end{block}
\end{frame}

\begin{frame}{Computation of the Fock matrix and energy}
	\begin{block}{Density matrix (closed-shell system)}
		\begin{equation}
			 P_{\red{\mu \nu}} = 2 \sum_{i}^\text{occ} C_{\red{\mu} i} C_{\red{\nu} i}
			\qqtext{or} 
			\boxed{\bm{P} = \bm{C} \cdot \bm{C}^{\dag}}
		\end{equation}
	\end{block}
	\begin{block}{Fock matrix in the AO basis (closed-shell system)}
		\begin{equation}
			F_{\red{\mu\nu}} 
			= H_{\red{\mu\nu}} 
			+ \underbrace{\sum_{\blue{\la \si}} P_{\blue{\la\si}} (\red{\mu\nu}|\blue{\la\si})}_{J_{\red{\mu \nu}} = \text{ Coulomb}}
			\underbrace{ - \frac{1}{2} \sum_{\blue{\la \si}} P_{\blue{\la\si}} (\red{\mu}\blue{\si}|\blue{\la}\red{\nu})}_{K_{\red{\mu \nu}} = \text{ exchange}}
		\end{equation}
	\end{block}
	\begin{block}{HF energy in the AO basis (closed-shell system)}
		\begin{equation}
			E_\text{HF} = \sum_{\red{\mu \nu}} P_{\red{\mu \nu}} H_{\red{\mu \nu}} 
			+ \frac{1}{2} \sum_{\red{\mu \nu} \blue{\la\si}} P_{\red{\mu \nu}} \qty[ (\red{\mu \nu} | \blue{\lambda \sigma}) - \frac{1}{2} (\red{\mu} \blue{\sigma} | \red{\lambda} \blue{\nu}) ] P_{\blue{\lambda\sigma}}
			\qqtext{or} 
			\boxed{E_\text{HF} = \frac{1}{2} \text{Tr}{\qty[\bm{P} \cdot (\bm{H} + \bm{F})]}}
		\end{equation}
	\end{block}
\end{frame}

\begin{frame}{Computation of the Fock matrix and energy}
	\begin{algorithmic}
		\Procedure{Computing the Coulomb matrix}{}
			\For{$\red{\mu}=1,N$}
				\For{$\blue{\nu}=1,N$}
					\State $J_{\red{\mu}\blue{\nu}} = 0$ \Comment{Initialization of the array}
					\For{$\orange{\la}=1,N$}
						\For{$\violet{\si}=1,N$}
							\State $J_{\red{\mu}\blue{\nu}} 
							= J_{\red{\mu}\blue{\nu}} 
							+ P_{\orange{\la}\violet{\si}} (\red{\mu}\blue{\nu}|\orange{\la}\violet{\si})$ 
							\Comment{Accumulation step}
						\EndFor
					\EndFor 
				\EndFor
			\EndFor 
		\EndProcedure
		\Comment{\bf \red{This is a $\order{N^4}$ algorithm as it involves four loops}}
	\end{algorithmic}
\end{frame}

%%% SLIDE X %%%
\begin{frame}{Resolution of the identity}
	\begin{block}{Resolution of the identity (RI) = a fancy way of writing 1}
		\begin{equation}
			\boxed{\sum_{\green{A}=1}^{\red{\infty}} |\green{A}) (\green{A}| = 1 
			\qqtext{and, in practice, }
			\sum_{\green{A}=1}^{\red{K}} |\green{A}) (\green{A}| \approx 1}
		\end{equation}
	\end{block}
	\begin{block}{Computing the Coulomb matrix with the RI}
		\begin{equation}
			\begin{split}
				J_{\red{\mu\nu}} 
				& = \sum_{\blue{\la \si}} P_{\blue{\la\si}} (\red{\mu\nu}|\blue{\la\si})
				\\
				& \stackrel{\text{\green{RI}}}{=}  \sum_{\blue{\la \si}} P_{\blue{\la\si}} \sum_{\green{A}} (\red{\mu\nu}|\green{A}) (\green{A}|\blue{\la\si})
				\\
				& = \sum_{\green{A}} (\red{\mu\nu}|\green{A})  
				\underbrace{\sum_{\blue{\la \si}} P_{\blue{\la\si}} (\green{A}|\blue{\la\si})}_{\order{KN^2} \text{ and $K$ storage}}
				= \underbrace{\sum_{\green{A}} (\red{\mu\nu}|\green{A})  I_{\green{A}}}_{\order{KN^2}}
			\end{split}
		\end{equation}
		\\
		Similar (more effective) approaches are named Cholesky decomposition, low-rank approximation, etc. 
	\end{block}
\end{frame}
%

\begin{frame}{Computation of exact exchange}
	\begin{algorithmic}
		\Procedure{Computing the exchange matrix}{}
			\For{$\red{\mu}=1,N$}
				\For{$\blue{\nu}=1,N$}
					\State $K_{\red{\mu}\blue{\nu}} = 0$ \Comment{Initialization of the array}
					\For{$\orange{\la}=1,N$}
						\For{$\violet{\si}=1,N$}
							\State $K_{\red{\mu}\blue{\nu}} 
							= K_{\red{\mu}\blue{\nu}} 
							+ P_{\orange{\la}\violet{\si}} (\red{\mu}\violet{\si}|\orange{\la}\blue{\nu})$ 
							\Comment{Accumulation step}
						\EndFor
					\EndFor 
				\EndFor
			\EndFor 
		\EndProcedure
		\Comment{\bf \red{This is a $\order{N^4}$ algorithm and it's hard to play games...}}
	\end{algorithmic}
\end{frame}

\begin{frame}{Computation of DFT exchange}
	\begin{block}{LDA exchange (in theory) = cf Julien's lectures}
		\begin{gather}
			K_{\mu\nu}^\text{LDA} 
			= \int \phi_{\mu}(\br) \violet{v_\text{x}^\text{LDA}}(\br) \phi_{\nu}(\br)  d\br 
			= \frac{4}{3} C_\text{x}  \overbrace{\int \phi_{\mu}(\br) \blue{\rho^{1/3}}(\br) \phi_{\nu}(\br) d\br}^{\text{\alert{no closed-form expression in general}}}
			\\
			\blue{\rho}(\br) = \sum_{\mu \nu} \phi_{\mu}(\br) \blue{P_{\mu \nu}} \phi_{\nu}(\br)
		\end{gather}
	\end{block}
	\begin{block}{LDA exchange (in practice) = \alert{numerical integration via quadrature} = $\int f(x) dx \approx \sum_k w_k f(x_k)$}
		\begin{gather}
			\underbrace{K_{\mu\nu}^\text{LDA}}_{\green{\order{N_\text{grid} N^2}}}
			\approx \sum_{k=1}^{\purple{N_\text{grid}}} 
			\underbrace{\orange{w_k}}_{\orange{\text{weights}}} \phi_{\mu}(\red{\br_k}) \violet{v_\text{x}^\text{LDA}}(\underbrace{\red{\br_k}}_{\text{\red{roots}}}) \phi_{\nu}(\red{\br_k}) 
			= \frac{4}{3} C_\text{x} \sum_{k=1}^{\purple{N_\text{grid}}} \orange{w_k} \phi_{\mu}(\red{\br_k}) \blue{\rho^{1/3}}(\red{\br_k}) \phi_{\nu}(\red{\br_k})
			\\
			\underbrace{\blue{\rho}(\red{\br_k})}_{\green{\order{N_\text{grid} N^2}}} = \sum_{\mu \nu} \phi_{\mu}(\red{\br_k}) \blue{P_{\mu \nu}} \phi_{\nu}(\red{\br_k})
		\end{gather}
	\end{block}
\end{frame}


\begin{frame}{MP2 correlation energy}
	\begin{block}{MP2 is the simplest way of catching a good chunk of correlation:}
		\begin{equation}
			\begin{split}
				\green{E_\text{c}^\text{(2)}}
				 &= \sum_{\red{ij}}^{\text{occ}}\sum_{\blue{ab}}^{\text{virt}} 
				\frac{ \braket{\red{ij}}{\blue{ab}} (2 \braket{\red{ij}}{\blue{ab}} - \braket{\red{ij}}{\blue{ba}})}
				{\epsilon_{\red{i}} + \epsilon_{\red{j}} - \epsilon_{\blue{a}} -  \epsilon_{\blue{b}}} 
				\\
				& = \underbrace{
					2 \sum_{\red{ij}}\sum_{\blue{ab}} 
					\frac{ \braket{\red{ij}}{\blue{ab}}^2}
					{\epsilon_{\red{i}} + \epsilon_{\red{j}} - \epsilon_{\blue{a}} -  \epsilon_{\blue{b}}} 
				}_{\text{direct part}}
				- \underbrace{
					\sum_{\red{ij}}\sum_{\blue{ab}} 
					\frac{ \braket{\red{ij}}{\blue{ab}} \braket{\red{ij}}{\blue{ba}}}
					{\epsilon_{\red{i}} + \epsilon_{\red{j}} - \epsilon_{\blue{a}} -  \epsilon_{\blue{b}}} 
				}_{\text{exchange part}}
			\end{split}
		\end{equation}
		\centering
		\includegraphics[width=0.5\textwidth]{fig/MP2}
	\end{block}
\end{frame}


\begin{frame}{Computing the MP2 correlation energy}
	\begin{block}{How much does it cost to compute the MP2 correlation energy?}
		\begin{algorithmic}
			\Procedure{MP2 correlation energy}{}
				\State $\green{E_\text{c}^\text{(2)}} = 0$
				\For{$\red{i}=1,O$}
					\For{$\red{j}=1,O$}
						\For{$\blue{a}=1,V$}
							\For{$\blue{b}=1,V$}
								\State $\purple{\Delta} = \epsilon_{\red{i}} + \epsilon_{\red{j}} - \epsilon_{\blue{a}} -  \epsilon_{\blue{b}}$
								\State $\green{E_\text{c}^\text{(2)}} 
								= \green{E_\text{c}^\text{(2)}}
								+ (2 \braket{\red{ij}}{\blue{ab}}^2 - \braket{\red{ij}}{\blue{ab}}\braket{\red{ij}}{\blue{ba}})/\purple{\Delta} $
							\EndFor
						\EndFor 
					\EndFor
				\EndFor 
			\EndProcedure
			\Comment{\bf \red{$\order{N^4}$ because there are four loops!}}
		\end{algorithmic}
	\end{block}
\end{frame}
%

%%% SLIDE X %%%
\begin{frame}{AO to MO transformation (Take 1)}
	\begin{block}{The naive way...}
		\begin{equation}
			\underbrace{\green{(pq|rs)}}_{\text{\purple{\bf MO integrals}}}
			= \sum_{\red{\mu\nu\la\si}} c_{\red{\mu} \green{p}} c_{\red{\nu} \green{q}} c_{\red{\la} \green{r}} c_{\red{\si} \green{s}} 
			\underbrace{\red{(\mu\nu|\la\si)}}_{\text{\purple{\bf AO integrals}}}
		\end{equation}
	\end{block}
	\begin{algorithmic}
		\scriptsize
		\Procedure{AO-to-MO Transformation}{}
			\For{$\red{p}=1,N$}
				\For{$\blue{q}=1,N$}
					\For{$\orange{r}=1,N$}
						\For{$\violet{s}=1,N$}
							\State $(\red{p}\blue{q}|\orange{r}\violet{s}) = 0$ 
							\Comment{Initialization of the array}
							\For{$\red{\mu}=1,N$}
								\For{$\blue{\nu}=1,N$}
									\For{$\orange{\la}=1,N$}
										\For{$\violet{\si}=1,N$}
											\State
											$(\red{p}\blue{q}|\orange{r}\violet{s}) = (\red{p}\blue{q}|\orange{r}\violet{s}) 
											+ c_{\red{\mu p}} c_{\blue{\nu q}} c_{\orange{\la r}} c_{\violet{\si s}} 
											(\red{\mu}\blue{\nu}|\orange{\la}\violet{\si})$ 
											\Comment{Accumulation step}
										\EndFor
									\EndFor 
								\EndFor
							\EndFor 
						\EndFor
					\EndFor 
				\EndFor
			\EndFor 
			\Comment{\bf \red{This is a $\order{N^8}$ algorithm! You won't do much quantum chemistry with this...}}
		\EndProcedure
	\end{algorithmic}
\end{frame}
%

%%% SLIDE X %%%
\begin{frame}{AO to MO transformation (Take 2)}
	\begin{block}{Semi-direct algorithm...}
		\begin{equation}
			(\red{p}\blue{q}|\orange{r}\violet{s})
			= 
			\underbrace{
				\sum_{\red{\mu p}} c_{\red{\mu p}} 
				\underbrace{
					\qty{ \sum_{\blue{\nu q}} c_{\blue{\nu q}} 
					\underbrace{
						\qty[ \sum_{\orange{\la r}} c_{\orange{\la r}} 
						\underbrace{
							\qty( \sum_{\violet{\si s}} c_{\violet{\si s}} 
							(\red{\mu}\blue{\nu}|\orange{\la}\violet{\si})
							)
						}_{\text{\violet{Step \#1}}}
						]
					}_{\text{\orange{Step \#2}}}
					}
				}_{\text{\blue{Step \#3}}}
			}_{\text{\red{Step \#4}}}
		\end{equation}
	\end{block}
\end{frame}

%%% SLIDE X %%%
\begin{frame}{Semi-direct algorithm}
	\begin{block}{Semi-direct algorithm... \violet{Step \#1}}
		\begin{algorithmic}
			\Procedure{Semi-Direct Algorithm (\violet{Step \#1})}{}
					\State Allocate temporary array $I$ of size $N^4$
					\For{$\red{\mu}=1,N$}
						\For{$\blue{\nu}=1,N$}
							\For{$\orange{\la}=1,N$}
								\For{$\violet{\si}=1,N$}
									\For{$\violet{s}=1,N$}
									\State
									$I_{\red{\mu}\blue{\nu}\orange{\la}\violet{s}} = I_{\red{\mu}\blue{\nu}\orange{\la}\violet{s}}
									+ c_{\violet{\si s}} (\red{\mu}\blue{\nu}|\orange{\la}\violet{\si})$ 
								\EndFor
							\EndFor
						\EndFor 
					\EndFor
				\EndFor 
				\Comment{\violet{Step \#1} costs $\order{N^5}$ and $\order{N^4}$ storage}
			\EndProcedure
		\end{algorithmic}
	\end{block}
\end{frame}
%
\begin{frame}{Semi-direct algorithm}
	\begin{block}{Semi-direct algorithm... \orange{Step \#2}}
		\begin{algorithmic}
			\Procedure{Semi-Direct Algorithm (\orange{Step \#2})}{}
					\State Allocate temporary array $J$ of size $N^4$
					\For{$\red{\mu}=1,N$}
						\For{$\blue{\nu}=1,N$}
							\For{$\orange{\la}=1,N$}
								\For{$\orange{r}=1,N$}
									\For{$\violet{s}=1,N$}
									\State
									$J_{\red{\mu}\blue{\nu}\orange{r}\violet{s}} = J_{\red{\mu}\blue{\nu}\orange{r}\violet{s}}
									+ c_{\orange{\la r}} I_{\red{\mu}\blue{\nu}\orange{\la}\violet{s}}$ 
								\EndFor
							\EndFor
						\EndFor 
					\EndFor
				\EndFor 
				\Comment{\orange{Step \#2} costs $\order{N^5}$ and $\order{N^4}$ storage}
			\EndProcedure
		\end{algorithmic}
	\end{block}
\end{frame}
%
\begin{frame}{Semi-direct algorithm}
	\begin{block}{Semi-direct algorithm... \blue{Step \#3}}
		\begin{algorithmic}
			\Procedure{Semi-Direct Algorithm (\blue{Step \#3})}{}
					\For{$\red{\mu}=1,N$}
						\For{$\blue{\nu}=1,N$}
							\For{$\blue{q}=1,N$}
								\For{$\orange{r}=1,N$}
									\For{$\violet{s}=1,N$}
									\State
									$I_{\red{\mu}\blue{q}\orange{r}\violet{s}} = I_{\red{\mu}\blue{q}\orange{r}\violet{s}}
									+ c_{\blue{\nu q}} J_{\red{\mu}\blue{\nu}\orange{r}\violet{s}}$ 
								\EndFor
							\EndFor
						\EndFor 
					\EndFor
				\EndFor 
				\Comment{\blue{Step \#3} costs $\order{N^5}$ and no new storage}
			\EndProcedure
		\end{algorithmic}
	\end{block}
\end{frame}
%
\begin{frame}{Semi-direct algorithm}
	\begin{block}{Semi-direct algorithm... \red{Step \#4}}
		\begin{algorithmic}
			\Procedure{Semi-Direct Algorithm (\red{Step \#4})}{}
					\For{$\red{\mu}=1,N$}
						\For{$\red{p}=1,N$}
							\For{$\blue{q}=1,N$}
								\For{$\orange{r}=1,N$}
									\For{$\violet{s}=1,N$}
									\State
									$(\red{p}\blue{q}|\orange{r}\violet{s}) = (\red{p}\blue{q}|\orange{r}\violet{s})
									+ c_{\red{\mu p}} I_{\red{\mu}\blue{q}\orange{r}\violet{s}}$ 
								\EndFor
							\EndFor
						\EndFor 
					\EndFor
				\EndFor 
				\Comment{\red{Step \#4} costs $\order{N^5}$ and no new storage}
			\EndProcedure
		\end{algorithmic}
	\end{block}
\end{frame}

\begin{frame}{Laplace transform}
	\begin{block}{Alml{\"o}f's trick}
		\begin{equation}
			\boxed{\frac{1}{\purple{\Delta}} = \blue{\int_0^\infty} \exp(-\purple{\Delta} \blue{t}) d\blue{t}}
		\end{equation}
		\begin{equation}
			\begin{split}
				\green{E_\text{c}^\text{(2)}}
				& = \frac{1}{4} \sum_{ij}\sum_{ab}
				\frac{\mel{ij}{}{ab}^2}
				{\purple{\epsilon_{i} + \epsilon_{j} - \epsilon_{a} -  \epsilon_{b}}}
				\\
				& = \frac{1}{4} \blue{\int_0^{\infty}} \sum_{ij}\sum_{ab}
				\mel{ij}{}{ab}^2 \exp[-(\purple{\epsilon_{i} + \epsilon_{j} - \epsilon_{a} -  \epsilon_{b}}) \blue{t}] d\blue{t}
				\\
				& = \frac{1}{4} \blue{\int_0^{\infty}} \sum_{ij}\sum_{ab} \mel{i(\blue{t})j(\blue{t})}{}{a(\blue{t})b(\blue{t})}^2
				\stackrel{\text{\blue{quad.}}}{\approx} \frac{1}{4} \blue{\sum_{k=1}^{N_\text{grid}}} \blue{w_k} \sum_{ij}\sum_{ab} \mel{i(\blue{t_k})j(\blue{t_k})}{}{a(\blue{t_k})b(\blue{t_k})}^2
			\end{split}
		\end{equation}
		\begin{equation}
			\ket*{p} \equiv \ket*{\varphi_p(0)} 
			\qqtext{and}  
			\ket*{p(\blue{t})} \equiv \ket*{\varphi_p(\blue{t})} = \ket*{\varphi_p(0) e^{\pm\frac{1}{2} \purple{\epsilon_p} \blue{t}}}
		\end{equation}
		\\
		\bigskip
		At this stage, one can play more games (e.g., localized orbitals, RI, stochastic sampling, quadrature, etc)
	\end{block}
\end{frame}


%%% SLIDE 2 %%%
\begin{frame}{Coupled-Cluster Theory}
	\begin{block}{A few random thoughts about coupled cluster (CC)}
		\begin{itemize}
			\bigskip
			\item CC theory comes from \alert{nuclear physics} (Thank you Physics!)
			\bigskip
			\item The idea behind CC is to include \alert{all corrections} of a given type to \alert{infinite order}
			\bigskip
			\item The CC wave function is an \alert{exponential \textit{ansatz}}
			\bigskip
			\item The CC energy is \alert{size-extensive}, but \alert{non-variational} 
			\bigskip
			\item CC is considered as the \alert{gold standard} for weakly correlated systems
		\end{itemize}
	\end{block}
\end{frame}

%%% SLIDE 3 %%%
\begin{frame}{Theory}
	\begin{itemize}
		\item CC wave function
			\begin{equation}
				\PsiCC = \alert{e^{\hT{}{}}} \PsiO%	\qquad	\text{where $\PsiO$ is a reference wave function}
			\end{equation}
		\item Excitation operator
			\begin{equation}
				\hT{}{} = \hT{1}{} + \hT{2}{} + \ldots + \hT{\nEl}{}%	\qquad	\text{where $\nEl$ is the number of electrons}
			\end{equation}
		\item Exponential \textit{ansatz}
			\begin{equation}
			\begin{split}
				e^{\hT{}{}} 
				& = \hI + \hT{}{} + \frac{1}{2!} \hT{}{2} + \frac{1}{3!} \hT{}{3} + \ldots
				\\
				& = \hI + \hT{1}{} 
				+ \qty( \underbrace{\hT{2}{}}_{\text{\green{connected}}} + \frac{1}{2} \underbrace{\hT{1}{2}}_{\text{\alert{disconnected}}} ) 
				+ \qty( \hT{3}{} + \hT{2}{} \hT{1}{} + \frac{1}{6} \hT{3}{} )
				\\
				& + \qty( \hT{4}{} + \hT{3}{} \hT{1}{} + \frac{1}{2} \underbrace{\hT{2}{2}}_{\text{\blue{two pairs of electrons}}} + \frac{1}{2} \hT{2}{} \hT{1}{2} + \frac{1}{24} \underbrace{\hT{4}{}}_{\text{
				\purple{four electrons}}} ) 
				+ \ldots
			\end{split}
			\end{equation}
	\end{itemize}
\end{frame}

%%% SLIDE 4 %%%
\begin{frame}{Excitation operators}
	\begin{itemize}
		\item Singles
			\begin{equation}
				\hT{1}{} \PsiO = \sum_{i} \sum_{a} \underbrace{\amp{i}{a}}_{\text{\alert{amplitudes}}} \Det{i}{a}
			\end{equation}
		\item Doubles
			\begin{equation}
				\hT{2}{} \PsiO = \sum_{i<j} \sum_{a<b} \amp{ij}{ab} \underbrace{\Det{ij}{ab}}_{\text{\alert{excited determinants}}}
			\end{equation}
		\item FCI wave function
			\begin{equation}
				 \PsiFCI = ( \hI + \hT{}{}) \PsiO = ( \hI + \hT{1}{} + \hT{2}{} + \hT{3}{} + \ldots) \PsiO
			\end{equation}
	\end{itemize}
\end{frame}

%%% SLIDE 5 %%%
\begin{frame}{CC energies}
	\begin{itemize}
		\item Schr\"odinger equation
			\begin{equation}
				\hH \ket{\PsiCC} = E \ket*{\PsiCC} 
				\, \Rightarrow \, 
				\hH e^{\hT{}{}} \ket*{\PsiO} = E e^{\hT{}{}} \ket*{\PsiO}
				\, \Rightarrow \, 
				\underbrace{e^{-\hT{}{}} \hH e^{\hT{}{}}}_{\text{\green{$\Bar{H} = \text{similarity transform}$}}} \ket*{\PsiO} = E \ket*{\PsiO}
			\end{equation}
		\item Variational CC energy (\alert{factorial complexity})
			\begin{equation}
				\alert{\EVCC}
				= \frac{\mel*{\PsiCC}{\hH}{\PsiCC}}{\braket*{\PsiCC}{\PsiCC}} 
				= \frac{\mel*{e^{\hT{}{}}\PsiO}{\hH}{e^{\hT{}{}}\PsiO}}{\braket*{e^{\hT{}{}}\PsiO}{e^{\hT{}{}}\PsiO}}
			\end{equation}
		\item Projected CC energy
			\begin{equation}
				\mel*{\PsiO}{\hH}{\PsiCC} = \ECC \braket*{\PsiO}{\PsiCC}
				\quad \Rightarrow \quad 
				\boxed{\ECC = \frac{\mel*{\PsiO}{\alert{\hH e^{\hT{}{}}}}{\PsiO}}{\braket*{\PsiO}{\PsiO}}}
			\end{equation}
	\end{itemize}
\end{frame}

%%% SLIDE 6 %%%
\begin{frame}{Projected CC energy}
	Assuming that $\braket*{\PsiO}{\PsiO} = 1$, we have 
	\begin{equation}
	\begin{split}
		\ECC 
		& = \mel*{\PsiO}{\hH e^{\hT{}{}}}{\PsiO}
		\\
		& = \mel*{\PsiO}{\hH \alert{(\hI + \hT{1}{} + \hT{2}{} + \frac{1}{2} \hT{1}{2} )}}{\PsiO}
		\\
		& = \mel*{\PsiO}{\hH}{\PsiO}
		+ \mel*{\PsiO}{\hH \hT{1}{}}{\PsiO}
		+ \mel*{\PsiO}{\hH \hT{2}{}}{\PsiO}
		+ \frac{1}{2} \mel*{\PsiO}{\hH \hT{1}{2}}{\PsiO}
		\\
		& = \EO
		+ \sum_{i} \sum_{a} \amp{i}{a} \green{\mel*{\PsiO}{\hH}{\Det{i}{a}}}
		+ \frac{1}{4} \sum_{ij} \sum_{ab}(\amp{ij}{ab} + \amp{i}{a} \amp{j}{b} - \amp{i}{b} \amp{j}{a} ) \blue{\mel*{\PsiO}{\hH}{\Det{ij}{ab}}}
	\end{split}
	\end{equation}
\end{frame}


%%% SLIDE 7 %%%
\begin{frame}{CC energy with Hartree-Fock reference}
	\begin{block}{HF reference wave function}
		\begin{itemize}
			\bigskip
			\item $\orange{\EO = \EHF}$
			\bigskip
			\item $\green{\mel*{\PsiO}{\hH}{\Det{i}{a}} = \mel*{i}{f}{a} = 0} \quad \Leftrightarrow \quad \text{\alert{Brillouin's theorem}}$
			\bigskip
			\item $\blue{\mel*{\PsiO}{\hH}{\Det{ij}{ab}} = \mel*{ij}{}{ab} = \braket*{ij}{ab} - \braket*{ij}{ba}} \quad \Leftrightarrow \quad \text{\alert{Two-electron integrals}}$
			\bigskip
		\end{itemize}
		\begin{equation}
			\boxed{
			\ECC = \orange{\EHF}
			+ \frac{1}{4} \sum_{ij} \sum_{ab} (\amp{ij}{ab} + \amp{i}{a} \amp{j}{b} - \amp{i}{b} \amp{j}{a} ) \blue{\mel*{ij}{}{ab}}
			}
		\end{equation}
	\end{block}
\end{frame}

%%% SLIDE 8 %%%
\begin{frame}{Truncated CC}
	\begin{block}{CC with doubles (CCD)}
		\begin{itemize}
			\bigskip
			\item Only doubles, doubles of doubles, etc $ \Rightarrow \alert{\hT{}{} = \hT{2}{}}$
			\bigskip
			\item Still an infinite series
			\begin{equation}
			\begin{split}
				e^{\hT{2}{}} 
				= \hI + \hT{2}{} + \frac{1}{2} \hT{2}{2} + \frac{1}{6} \hT{2}{3} + \frac{1}{24} \hT{2}{4} + \ldots
			\end{split}
			\end{equation}
			\bigskip
			\item CCD energy
				\begin{equation}
					\ECCD = \EHF + \frac{1}{4} \sum_{ij} \sum_{ab} \amp{ij}{ab} \mel*{ij}{}{ab}
				\end{equation}
		\end{itemize}
	\end{block}
\end{frame}

%%% SLIDE 9 %%%
\begin{frame}{CCD equations}
	\begin{itemize}
		\item Projection of similarity-transformed Hamiltonian onto doubles
			\begin{equation}
				\mel*{\alert{\Det{ij}{ab}}}{\green{\bar{H}}}{\PsiO} = \ECC \braket*{\alert{\Det{ij}{ab}}}{\PsiO} = 0
				\quad \Rightarrow \quad 
				\mel*{\alert{\Det{ij}{ab}}}{e^{-\hT{}{}} \hH e^{\hT{}{}}}{\PsiO}= 0
			\end{equation}
		\item \alert{Residual equation}
			\begin{equation}
				\boxed{r_{ij}^{ab} = \mel*{ij}{}{ab} + \blue{\Delta_{ij}^{ab}} \amp{ij}{ab} + \green{u_{ij}^{ab}} + \alert{v_{ij}^{ab}} = 0}
				\quad \Rightarrow \quad
				\boxed{\amp{ij}{ab} = - \frac{\mel*{ij}{}{ab} + \green{u_{ij}^{ab}} + \alert{v_{ij}^{ab}}}{\blue{\Delta_{ij}^{ab}}}}
			\end{equation}
		\item Energy differences
			\begin{equation}
				\blue{\Delta_{ij}^{ab}} = \epsilon_a + \epsilon_b - \epsilon_i  - \epsilon_j
			\end{equation}
		\item \green{Linear} array
			\begin{equation}
				\green{u_{ij}^{ab}} = f(\amp{ij}{ab}) = \order*{\green{\nBas^6}}
			\end{equation}
		\item \alert{Quadratic} array
			\begin{equation}
				\alert{v_{ij}^{ab}} = f(\amp{ij}{ab}) = \underbrace{\order*{\green{\nBas^6}}}_{\green{\text{smart}}} \text{ or } \underbrace{\order*{\alert{\nBas^8}}}_{\alert{\text{dumb}}}
			\end{equation}
	\end{itemize}
\end{frame}

%%% SLIDE 10 %%%
\begin{frame}{\green{Linear} array}
	Each term of the linear term can be computed in $\order*{N^6}$:
	\begin{equation}
		\begin{split}
			u_{ij}^{ab} 
			& = \frac{1}{2} \sum_{cd} \alert{\underbrace{\mel*{ab}{}{cd}}_{VVVV}} \amp{ij}{cd} 
			+ \frac{1}{2} \sum_{kl} \green{\underbrace{\mel*{kl}{}{ij}}_{OOOO}} \amp{kl}{ab} 
			\\
			& + \sum_{kc} \qty[ - \orange{\underbrace{\mel*{kb}{}{jc}}_{OVOV}} \amp{ik}{ac} + \orange{\mel*{ka}{}{jc}} \amp{ik}{bc} 
			- \orange{\mel*{ka}{}{ic}} \amp{jk}{bc} + \orange{\mel*{kb}{}{ic}} \amp{jk}{ac} ]
		\end{split}
	\end{equation}
	\alert{\bf NB:} CCD($v_{ij}^{ab} = 0$) $=$ linear CCD (LCCD)
\end{frame}

%%% SLIDE 11 %%%
\begin{frame}{\alert{Quadratic} array: the \alert{dumb} way}
	The quadratic term is the computational bottleneck of CCD:
	\begin{equation}
		\begin{split}
			v_{ij}^{ab} 
			= \frac{1}{4} \sum_{klcd} \purple{\underbrace{\mel*{kl}{}{cd}}_{OOVV}} 
			\bigg[ 
			& \amp{ij}{cd} \amp{kl}{ab} 
			- 2(\amp{ij}{ac} \amp{kl}{bd} + \amp{ij}{bd} \amp{kl}{ac}) 
			\\
			& - 2 (\amp{ik}{ab} \amp{jl}{cd} + \amp{ik}{cd} \amp{jl}{ab}) 
			+ 4 (\amp{ik}{ac} \amp{jl}{bd} + \amp{ik}{bd} \amp{jl}{ac}) 
			\bigg]
		\end{split}
	\end{equation}
	The ``formal'' scaling of the quadratic term is $\order*{N^8}$
\end{frame}

%%% SLIDE 12 %%%
\begin{frame}{\alert{Quadratic} array: the \green{smart} way}
	One can ``sacrifice'' storage to gain in scaling:
	\begin{align}
		\underbrace{\alert{\mel*{kl}{X_1}{ij}}}_{\order*{N^6}} & = \sum_{cd} \mel*{kl}{}{cd} \amp{ij}{cd}
		&
		\underbrace{\orange{\mel*{b}{X_2}{c}}}_{\order*{N^5}} & = \sum_{kld} \mel*{kl}{}{cd} \amp{kl}{bd}
		\\
		\underbrace{\green{\mel*{k}{X_3}{j}}}_{\order*{N^5}} & = \sum_{lcd} \mel*{kl}{}{cd} \amp{jl}{cd}
		&
		\underbrace{\purple{\mel*{il}{X_4}{ad}}}_{\order*{N^6}} & = \sum_{kc} \mel*{kl}{}{cd} \amp{ik}{ac}
	\end{align}
	Now, the quadratic term can be computed in $\order*{N^6}$
	\begin{equation}
		\begin{split}
			v_{ij}^{ab} 
			& = \frac{1}{4} \sum_{kl} \alert{\mel*{kl}{X_1}{cd}} \amp{kl}{ab}
			- \frac{1}{2} \sum_{c} \qty[ \orange{\mel*{b}{X_2}{c}} \amp{ij}{ac} + \orange{\mel*{a}{X_2}{c}} \amp{ij}{cb} ]
			\\
			& - \frac{1}{2} \sum_{k} \qty[ \green{\mel*{k}{X_3}{j}} \amp{ik}{ab} + \green{\mel*{k}{X_3}{i}} \amp{kj}{ab} ]
			+ \sum_{kc} \qty[ \purple{\mel*{ik}{X_4}{ac}} \amp{jk}{bc} + \purple{\mel*{ik}{X_4}{bc}} \amp{kj}{ac} ]
		\end{split}
	\end{equation}
\end{frame}


%%% SLIDE 12 %%%
\begin{frame}{CCD algorithm}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{block}{CCD subroutine}
				\begin{algorithmic}
					\Procedure{Iterative CCD algorithm}{}
						\State Perform HF calculation to get $\epsilon_p$ and $\mel*{pq}{}{rs}$
						\State Set $\green{u_{ij}^{ab}} = 0$, and $\orange{v_{ij}^{ab}} = 0$
						\State Compute amplitudes $\red{t_{ij}^{ab}} = - \mel*{ij}{}{ab}/\Delta_{ij}^{ab}$ (MP2 guess)
						\While{$\max{\abs*{\blue{r_{ij}^{ab}}}} > \tau$}
							\State Form linear array $\green{u_{ij}^{ab}}$ 
							\State Compute intermediate arrays $\mel*{kl}{X_1}{ij}$, $\mel*{b}{X_2}{c}$, $\mel*{k}{X_3}{j}$, and $\mel*{il}{X_4}{ad}$.
							\State Form quadratic array $\orange{v_{ij}^{ab}}$
							\State Compute residues: $\blue{r_{ij}^{ab}} = \mel*{ij}{}{ab} + \Delta_{ij}^{ab} \amp{ij}{ab} + \green{u_{ij}^{ab}} + \orange{v_{ij}^{ab}}$
							\State Update amplitudes: $\red{t_{ij}^{ab}}  \leftarrow \red{t_{ij}^{ab}} - \blue{r_{ij}^{ab}}/\Delta_{ij}^{ab}$
						\EndWhile 
						\State Compute CCD energy: $\ECCD = \EHF + \frac{1}{4} \sum_{ij} \sum_{ab} \red{t_{ij}^{ab}} \mel*{ij}{}{ab}$
					\EndProcedure
				\end{algorithmic}
			\end{block}
		\end{column}
		\begin{column}{0.3\textwidth}
			\centering
			\includegraphics[width=\textwidth]{fig/Diagrams-CCD}
		\end{column}
	\end{columns}
\end{frame}

%%%% FINAL SLIDE %%%
%\begin{frame}{Further reading for CC methods}
%	\begin{itemize}
%		\item Pople et al. IJQC 14 (1978) 545
%		\bigskip
%		\item Scuseria et al, JCP 86 (1987) 2881
%		\bigskip
%		\item Jensen, \textit{``Introduction to Computational Chemistry''} (Wiley)
%		\bigskip
%		\item Crawford \& Schaefer, \textit{``An Introduction to Coupled Cluster Theory for Computational Chemists''}, Reviews in Computational Chemistry, Vol.~14 (2000)
%		\bigskip
%		\item Shavitt \& Bartlett, \textit{``Many-Body Methods in Chemistry and Physics: MBPT and Coupled-Cluster Theory''} (Cambridge University Press)
%	\end{itemize}
%\end{frame}

%%% FINAL SLIDE %%%
%-----------------------------------------------------
\section{Books}
%-----------------------------------------------------
\begin{frame}{Good books}
	\begin{columns}
		\begin{column}{0.7\textwidth}
			\begin{itemize}
				\item Introduction to Computational Chemistry (Jensen)
				\\
				\vspace{1cm}
				\item Essentials of Computational Chemistry (Cramer)
				\\
				\vspace{1cm}
				\item Modern Quantum Chemistry (Szabo \& Ostlund)
				\\
				\vspace{1cm}
				\item Molecular Electronic Structure Theory (Helgaker, Jorgensen \& Olsen)
				\\
				\vspace{1cm}
			\end{itemize}
		\end{column}
		\begin{column}{0.3\textwidth}
				\centering
				\includegraphics[height=0.3\textwidth]{fig/Jensen}
				\\
				\bigskip
				\includegraphics[height=0.3\textwidth]{fig/Cramer}
				\\
				\bigskip
				\includegraphics[height=0.3\textwidth]{fig/Szabo}
				\\
				\bigskip
				\includegraphics[height=0.3\textwidth]{fig/Helgaker}
		\end{column}
	\end{columns}
\end{frame}


\end{document}
