\chapter{Finite volume}
\label{chap:Finite_volume}

\section{Simple relative coordinates}

The coordinate system we choose for finite-volume calculations must satisfy several conditions:

\begin{enumerate}
    \item The Hamiltonian in terms of the new coordinates $(\vec{x}_i,\vec{p}_i)$ must be computationally efficient to apply.
    \item An $n$-body system results in $n - 1$ degrees of freedom when the center-of-mass is subtracted out. This center-of-mass of motion should be isolated as a separate coordinate which can then be dropped.
    \item Periodic boundary condition, which translates to the quantization condition for the original momenta $\vec{q}_i$ must follow from quantization condition for the new momenta $\vec{p}_i$.
\end{enumerate}

These conditions are satisfied by simple relative coordinates introduced in ~\cite{TBA}.
%
\begin{equation}
 \vec{x}_i = \begin{cases}
  \vec{r}_i - \vec{r}_n & \text{for}\ i<n \,, \\
  \frac{1}{n} \sum_{j=1}^n \vec{r}_j & \text{for}\  i=n \,.
 \end{cases}
\label{eq:simple_relative_coordinates}
\end{equation}
%
The last coordinate $\vec{x}_n$ corresponds to the center-of-mass and is therefore ultimately dropped. Nevertheless, we define it here for the sake of completeness, in the sense that, a transformation has to be invertible. To see that this transformation is canonical, we start with an ansatz for the generating function of \nth{2} type \citep{jose_classical_2006}.
%
\begin{equation}
    G_2(\vec{r}_i,\vec{p}_i) = \sum_{i=1}^{n-1} (\vec{r}_i - \vec{r}_n)\vec{p}_i + \frac{\vec{p}_n}{n} \sum_{i=1}^n \vec{r}_i
\end{equation}
%
Now, it can be seen that 
%
\begin{equation}
    \vec{x}_i=\frac{\partial G_2}{\partial \vec{p}_i}    
\end{equation}
%
recovers the definition given by Eq.~\ref{eq:simple_relative_coordinates}. Then we evaluate
%
\begin{spliteq}
    \vec{q}_i &= \frac{\partial G_2}{\partial \vec{r}_i} \\
    &= \frac{\vec{p}_n}{n} + \begin{cases}
          \vec{p}_i & \text{for}\ i<n \,, \\
          -\sum_{j=1}^{n-1} \vec{p}_j & \text{for}\  i=n \,.
        \end{cases}
\end{spliteq}
%
Setting to zero the center-of-mass momentum $\vec{p}_n=0$, we can see that quantization of $\vec{p}_j$ implies quantization of $\vec{q}_j$, as required for periodicity.

Finally, noting that $\frac{\partial G_2}{\partial t}=0$, we can calculate the free Hamiltonian, with the center-of-mass energy subtracted out.
%
\begin{spliteq}
    H_0 &= \sum_{i=1}^n \frac{\vec{q}_i^2}{2m} - \frac{1}{2nm} \parenth {\sum_{i=1}^n \vec{q}_i}^2 \\
    &= \frac{1}{2m} \sum_{i=1}^{n-1} \parenth{\frac{\vec{p}_n}{n} + \vec{p}_i}^2 + \frac{1}{2m} \parenth{\frac{\vec{p}_n}{n} - \sum_{i=1}^{n-1} \vec{p}_i}^2
    - \frac{1}{2nm} \parenth {\sum_{i=1}^n \vec{p}_i}^2 \\
    &= \frac{1}{m} \sum_{i=1}^{n-1} \sum_{j=1}^{i} \vec{p}_i \cdot \vec{p}_j
\label{eq:H0_in_SRC}
\end{spliteq}
%
Evidently, the Hamiltonian doesn't depend on $\vec{p}_n$, eliminating one degree-of-freedom, thereby reducing the basis size. However, this includes some cross terms, unlike, for example, Jacobi coordinates.

For instance, a 3-body system will have the simple form
%
\begin{equation}
    H_0 = \frac{1}{m} \parenth{\vec{p}_1^2 + \vec{p}_2^2 + \vec{p}_1 \cdot \vec{p}_2 } \, ,
\end{equation}
%
enabling computationally efficient strategies for multiplying with a vector without explicitly constructing the whole matrix.

\section{$n$-body Hamiltonian}

Using a uniformly discretized mesh containing $N$ lattice points in each direction,
\begin{equation}
    x = \frac{L}{N} k \quad \text{for} \quad k={-}\frac{N}{2}, \cdd \frac{N}{2}+1 \, ,
\end{equation}
we can construct the $n$-body basis as follows. Let $k_{i,c}$ denote the ``lattice index'' corresponding to the $c$th spatial dimension of the $\vec{x}_i$ coordinate. For arbitrary number of particles $n$ and spatial dimensions $d$, basis states can be labelled as
%
\begin{spliteq}    
 \ket{s}
 &= \ket{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}} \\
 &= \bigotimes_{\substack{i=1,\cdot\cdot n-1 \\c=1,\cdot\cdot d}} \ket{k_{i,c}} \,.
\label{eq:s}
\end{spliteq}
%
Note that $\ket{s}$ can in addition include discrete quantum numbers such as spin and isospin but they are neglected here for simplicity. This decomposition implies that the momentum operators $p_{i,c}$ are diagonal in $i$ and $c$. Furthermore, the kinetic operators $K_c$ are diagonal in $c$, allowing the free Hamiltonian to be decomposable as,
%
\begin{equation}
 H_0 = K \oplus K \oplus \ldots \oplus K \quad \text{($d$ times)} \,,
\label{eq:H_0}
\end{equation}
%
where $\oplus$ denotes the Kronecker sum~\citep{KroneckerSumWolfram} and $K$ is the 1D kinetic energy operator. Note that $K_c$ in not necessarily diagonal in $i$ due to our choice of simple relative coordinates introducing the cross terms shown in Eq.~\eqref{eq:H0_in_SRC}. For example, for a three-body system in $d=3$ dimensions, this construction amounts to a sparse matrix with entries
%
\begin{spliteq}
 &\bra{k_{1,1}, k_{1,2}, k_{1,3}, k_{2,1}, k_{2,2}, k_{2,3}} H_0 \ket{l_{1,1}, l_{1,2}, l_{1,3}, l_{2,1}, l_{2,2}, l_{2,3}} \\
 &\hspace{2em}= \frac{1}{2\mu} \left\{ \left[(p^2)_{k_{1,1},l_{1,1}} + (p^2)_{k_{2,1},l_{2,1}} + p_{k_{1,1},l_{1,1}} p_{k_{2,1},l_{2,1}}\right]
 \delta_{k_{1,2},l_{1,2}} \delta_{k_{1,3},l_{1,3}} \delta_{k_{2,2},l_{2,2}} \delta_{k_{2,3},l_{2,3}} \right. \\
 &\hspace{4em}+ \left[(p^2)_{k_{1,2},l_{1,2}} + (p^2)_{k_{2,2},l_{2,2}} + p_{k_{1,2},l_{1,2}} p_{k_{2,2},l_{2,2}}\right]
 \delta_{k_{1,1},l_{1,1}} \delta_{k_{1,3},l_{1,3}} \delta_{k_{2,1},l_{2,1}} \delta_{k_{2,3},l_{2,3}} \\
 & \left. \hspace{4em}+ \left[(p^2)_{k_{1,3},l_{1,3}} + (p^2)_{k_{2,3},l_{2,3}} + p_{k_{1,3},l_{1,3}} p_{k_{2,3},l_{2,3}}\right]
 \delta_{k_{1,1},l_{1,1}} \delta_{k_{1,2},l_{1,2}} \delta_{k_{2,1},l_{2,1}} \delta_{k_{2,2},l_{2,2}} \right\} \, .
\label{eq:d3n3}
\end{spliteq}
%
The matrix representations of the momentum operator $p$ will be discussed later in Sec.~\ref{sec:DVR}. The potential energy matrix is diagonal in the configuration space (assuming local potentials) and therefore takes the form,
%
\begin{spliteq}
 &\bra{k_{1,1}, k_{1,2}, k_{1,3}, k_{2,1}, k_{2,2}, k_{2,3}} V \ket{l_{1,1}, l_{1,2}, l_{1,3}, l_{2,1}, l_{2,2}, l_{2,3}} \\
 &\hspace{2em}= V(x_{1,1}, x_{1,2}, x_{1,3}, x_{2,1}, x_{2,2}, x_{2,3}) \delta_{k_{1,1},l_{1,1}} \delta_{k_{1,2},l_{1,2}} \delta_{k_{1,3},l_{1,3}} \delta_{k_{2,1},l_{2,1}} \delta_{k_{2,2},l_{2,2}} \delta_{k_{2,3},l_{2,3}} \, .
\end{spliteq}
%
This resulting sparsity of the matrix should be exploited for numerical implementations, as the matrix is simply too large be be stored in computer memory for most practical applications. Alternatively, the matrix elements can be calculated on-demand when the multiplying with a vector. This is made possible due to most eigenvalue algorithms such as the implicitly restarted Arnoldi method (IRAM) only requiring the results of matrix-vector multiplications for a set of given vectors~\citep{lehoucq1998arpack}.

Alternatively, the tensor decomposition of the basis states can be exploited with the fact that modern computers (especially GPUs) are getting more and more efficient at large-scale tensor contractions, due to the rising popularity of machine learning. To this end, let us express the wave function as a rank-$\left[(n-1)\times d\right]$ tensor.
\begin{equation}
    \braket{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}|\psi}=\psi_{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}}
\end{equation}
Similarly, the Hamiltonian can be written as,
\begin{equation}
    \braket{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}|H|l_{{1,1}},\cdd l_{{1,d}},\cdd l_{{n-1,1}},\cdd l_{{n-1,d}}}=H^{l_{{1,1}},\cdd l_{{1,d}},\cdd l_{{n-1,1}},\cdd l_{{n-1,d}}}_{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}} \, .
\end{equation}
Now the free Hamiltonian derived in Eq.~\eqref{eq:H0_in_SRC} can be applied via,
\begin{equation}
    (H_0 \psi)_{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}} = 
    \frac{1}{2\mu} \sum_{c=1}^d \sum_{i=1}^{n-1} \left( p^{l_{i,c}}_{k_{i,c}} \sum_{j=1}^i p^{l_{j,c}}_{k_{j,c}} \psi_{l_{{1,1}},\cdd l_{{1,d}},\cdd l_{{n-1,1}},\cdd l_{{n-1,d}}} \right) \, ,
\end{equation}
where Einstein summation is implied. The potential energy can be trivially implemented as point-wise multiplication with the diagonal elements of the potential energy tensor $V_{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}}^{k_{{1,1}},\cdd k_{{1,d}},\cdd k_{{n-1,1}},\cdd k_{{n-1,d}}}$.
\ny{Illustrate as a tensor network.}

\section{Discrete variable representation}
\label{sec:DVR}

Now we are left with the task of implementing the 1D momentum operator $p={-}\ii\partial$ in discretized configuration space. The simplest approach would be to adopt a finite-difference scheme for approximating the derivative, one of the most basic of which being,
\begin{equation}
    \partial^l_k = \frac{n}{L} (\delta^{l+1}_k - \delta^l_k) \, ,
\end{equation}
where we have used the tensor notation again for convenience. However, this leads to significant numerical errors, even for a wave function as basic as a plane-wave $\psi(x)=\exp(\ii k x)$, as discussed in \cite{Konig:2020lzo}.

As pointed out in \cite{Bulgac:2013mz}, calculating the derivative in the \emph{discrete} Fourier basis, leads to much more accurate results. One could employ a fast Fourier transform (FFT) algorithm to efficiently go between representations and apply the kinetic energy operator efficiently in its diagonal basis. Since such an operation is still a linear map in the configuration space, alternatively, we can derive the ``derivative operator'' $\partial$ as a matrix or a rank-2 tensor, which when multiplied gives the same result numerically~\citep{Klos:2018sen}.
%
\begin{equation}
  \partial^l_k =  \frac{\pi (-1)^{k-l}}{L}
  \begin{cases}
    {-}\ii & \text{if } k=l \\
    \frac{\exp \left[ {-}\ii\frac{\pi (k-l)}{N} \right]} {\sin{\frac{\pi (k-l)}{N}}} & \text{otherwise} \\
  \end{cases}
\label{eq:daba_matrix}
\end{equation}
%
The second derivative equivalent of above can also be useful for optimizing the implementation.
%
\begin{equation}
  (\partial^2)^l_k = {-} \frac{\pi^2 (-1)^{k-l}}{L^2}
  \begin{cases}
    \frac{N^2 + 2}{3} & \text{if } k=l \\
    \frac{2} {\sin^2{\frac{\pi (k-l)}{N}}} & \text{otherwise} \\
  \end{cases}
\label{eq:daba2_matrix}
\end{equation}
%

\section{Resonances as avoided crossings}

[\ldots]

\section{Bound-to-resonance extrapolation in finite-volume}
\label{sec:B2R_FV}

As proven in~~\ref{TBA}, it is possible to employ EC to extrapolate from bound states to resonances. But for situations where complex-scaling is not possible, it is worth studying the same approach in finite volume where resonances can be indirectly identified from avoided crossings. That is, we attempt to train with finite volume bound states, which does not contain any avoided crossings, and then extrapolate to the resonant regime to see if resonances manifest as avoided crossings.

Consider 2 particles in a 3-D periodic box interacting with a potential,
\begin{equation}
    V(c,r)=-(0.5-c)\exp \left( \frac{-r^2}{30} \right) +(0.5+c)\exp \left(\frac{-(r-7)^2}{9} \right) \, ,
    \label{eq:Yapa_potential}
\end{equation}
where $c$ is a parameter to be varied. This potential is engineered to have a barrier at large $c$ values that can support a resonance, and a trough at small $c$ values that can support a bound state. The shape of the potential for 3 values of $c$ are shown in Fig.~\ref{fig:potential}.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=\textwidth]{Chapter-5/potential.pdf}
    \caption{The shape of the potential given by Eq.~\eqref{eq:Yapa_potential} for 3 values of $p$. As shown, the last curve contains a pronounced barrier, suggesting the possibility to support a resonance.}
    \label{fig:potential}
\end{figure}

The EC procedure is carried out by training at two points, $c=-0.45$ and $c=-0.40$, and then extrapolating at $c=0.10$, for each $L$ value. The resulting spectra are shown in Fig.~\ref{fig:spectra}. The extrapolated spectrum seems to show an avoided crossing. A zoomed in version of this spectrum is shown in Fig.~\ref{fig:last_spectrum} along with an exact calculation for comparison. As it can be seen, the exact and the extrapolated spectrum seems to agree closely, displaying a clear avoided crossing at the same energy level. This rather remarkable result shows that EC can predict an avoided crossing corresponding to a resonance, even when trained with bound spectra that does not contain at least a hint of such a feature.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=\textwidth]{Chapter-5/spectra.pdf}
    \caption{The finite volume spectra for the two $c$ values, $c=-0.45$ and $c=-0.40$, shown on the left and the middle respectively, that are used for training the EC basis. On the right, the extrapolated spectrum is shown which shows a clear avoided crossing, thereby implying the existence of a resonance.}
    \label{fig:spectra}
\end{figure}

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.7\textwidth]{Chapter-5/last_spectrum.pdf}
    \caption{The finite volume spectra for $c=0.10$ in Fig.~\ref{fig:spectra} zoomed in, along with an exact calculation of the spectrum as a comparison. Both spectra seems to agree well, as far as the energy level of the avoided crossing due to the resonance is concerned.}
    \label{fig:last_spectrum}
\end{figure}

\section{Volume extrapolation}

In previous calculations, we still had to deal with repeatedly solving the exact spectrum for a range of $L$ values. It turns out that we can employ EC again to tackle this problem. In this section, we will empirically show how that it is possible to obtain a highly accurate finite-volume spectrum only with few $L$ values, as opposed to mesh of $L$ values dense enough to identify important features such as avoided crossings.

We lay out the formalism for ``finite-volume eigenvector continuation (FVEC)'', where we extrapolate from periodic boxes with sizes $L_i$, $i=1,\cdd N$ to a target volume $L_*$. This should be distinguished from performing at a fixed single volume $L$ to extrapolate a parametric dependence of the Hamiltonian as we did in Sec.~\ref{sec:B2R_FV}. Specifically, we want to consider states $\ket{\psi_{L_i}}$ at volume $L_i$ (or sets of states $\{\ket{\psi_{L_i}^{(j)}},\,j=1,\cdd N_i\}$) and perform EC using Hamiltonian and norm matrices
%
\begin{subalign}[eq:H-N-naive]
 H_{ij} &= \braket{\psi_{L_i} | H_{L_*} | \psi_{L_j}} \,, \\
 N_{ij} &= \braket{\psi_{L_i} | \psi_{L_j}} \,.
\end{subalign}
%
However, at face value the above definitions appear problematic because the dependence on $L$ does not simply stem from the Hamiltonian; it is inherent in the definition of the Hilbert space. Two states $\ket{\psi_{L_i}}$ and $\ket{\psi_{L_j}}$ are actually vectors in different Hilbert spaces for $i\neq j$, and it is not immediately clear how the matrix elements written down naively in Eqs.~\eqref{eq:H-N-naive} can be well-defined quantities. To resolve this issue, we develop the notion of a vector space that accommodates states with arbitrary periodicities and show how it relates to FVEC calculations.

\ny{Incomplete}

\section{Direct resonances in finite volume}

[\ldots]

\section{Finite-volume correction}

The L\"uscher formalism \citep{Luscher:1985dn,Luscher:1986pf,Luscher:1990ux} for bound-states lets us calculate the energy correction $\Delta E = E_L - E_\infty$ for a two-body system simulated in a periodic box of length $L$, compared to the same system in infinite volume. This lets one extrapolate the energy, from some finite $L$  larger than the range of the potential $R$, to infinite volume, $L \to \infty$, which is usually the quantity of interest. We start by constructing the finite-volume Hamiltonian $H_L = H_0 + V_L$ by replicating the interaction potential $V$ (assumed to be local for simplicity) at each cubic image,
\begin{equation}
    V_L(\vec r) = \sum_{\vec n \in \mathbb{Z}^3} V(\vec r + \vec n L) \, .
\end{equation}
Inspired by this, we construct and approximation for the finite-volume wave function $\psi_L(\vec r)$,
\begin{equation}
    \Tilde{\psi}_L(\vec r) = \sum_{\vec n \in \mathbb{Z}^3} \psi_\infty(\vec r + \vec n L) \, .
\end{equation}
To justify this approximation, let us see the effect of multiplying the above with $H_L$.
\begin{spliteq}
    H_L \Tilde\psi_L(\vec r)
    &= H_0 \sum_{\vec n'} \psi_\infty(\vec r + \vec n' L) + \sum_{\vec n'} \sum_{\vec n} V(\vec r + \vec n L) \psi_\infty(\vec r + \vec n' L) \\    
    &= \sum_{\vec n'} \left\{ \left[ H_0 + V(\vec r + \vec n' L) \right] \psi_\infty(\vec r + \vec n' L) + \sum_{\vec n \neq \vec n'} V(\vec r + \vec n L) \psi_\infty(\vec r + \vec n' L) \right\} \\
    &= E_\infty \sum_{\vec n'} \psi_\infty(\vec r + \vec n' L) + \sum_{\vec n'} \sum_{\vec n \neq \vec n'} V(\vec r + \vec n L) \psi_\infty(\vec r + \vec n' L) \\
    &= E_\infty \, \Tilde\psi_L(\vec r) + \eta(\vec r) \\
\end{spliteq}
where we have defined,
\begin{spliteq}
    \eta(\vec r) &= \sum_{\vec n'} \sum_{\vec n \neq \vec n'} V(\vec r + \vec n L) \psi_\infty(\vec r + \vec n' L) \\
    &= \sum_{\vec n} \sum_{\vec n' \neq 0} V(\vec r + \vec n L) \psi_\infty(\vec r + (\vec n + \vec n') L) \, . \\
\end{spliteq}
Now, based on the previous discussion in Sec.~\ref{TBA}, we consider the asymptotic form of the wave function for the region $|\vec r| > R$,
\begin{equation}
    \psi_\infty(\vec r) \to \ii^l \gamma \, Y^m_l(\vec {\hat r}) \frac{\hat h^+_l(\ii \kappa r)}{r} = \mathcal O (\ee^{{-}\kappa r}) \, .
\end{equation}
Now we can see that $\eta(\vec r)$ only has contributions from the asymptotic region of the wave function since $V(r) = 0$ for $r > L/2$. Moreover, these contributions are suppressed exponentially with respect to $\kappa|\vec n'|L$, with the leading contribution being of order $\mathcal O (\ee^{{-}\kappa L})$. Therefore we have proved that $\Tilde\psi_L(\vec r)$ is an \emph{approximate} eigenfunction of $H_L$ with an eigenvalue of $E_\infty$.

To estimate the finite-volume correction, we first consider the matrix element $\braket{\psi_L|H_L|\Tilde\psi_L}$. Acting $H_L$ towards the left gives,
\begin{equation}
    \braket{\psi_L|H_L|\Tilde\psi_L} = E_L \braket{\psi_L|\Tilde\psi_L} \, ,
\end{equation}
whereas acting towards the right gives,
\begin{equation}
    \braket{\psi_L|H_L|\Tilde\psi_L} = E_\infty \braket{\psi_L|\Tilde\psi_L} + \braket{\psi_L|\eta} \, ,
\end{equation}
so that we have,
\begin{equation}
    E_L - E_\infty = \frac{\braket{\psi_L|\eta}}{\braket{\psi_L|\Tilde\psi_L}}\, .
\end{equation}
It can be shown that this expression reduces to,
\begin{equation}
    \Delta E = E_L - E_\infty = \sum_{|\vec n| = 1} \int \dd^3 r \, \psi^*_\infty(\vec r) V(\vec r) \psi_\infty(\vec r + \vec n L) + \mathcal O (\ee^{{-}\sqrt{2}\kappa r}) \, .
\end{equation}

\ny{Incomplete}