# High-Frequency moments of the Green’s function

The coefficients of the high-frequency expansion of a Green function (in short tail) play an essential role in acquiring accurate results for e.g. Fourier transforms and density calculations.

$G(i\omega) \approx \sum_{n = 0}^N \frac{a_n}{(i\omega)^n}$

The TRIQS library provides functionalities to determine these tail coefficiencts through a least-square fitting procedure.

## API

We provide a variety of free functions in order to determine the tail coefficients. Given a Matsubara or Real-frequency Green function $$G(i\omega)$$ with arbitrary G.target_shape() we have the following possibilities.

fit_tail(G) -> std::pair<array<dcomplex, Rank>, double>

• This function will consider twenty percent of the frequencies (the largest by absolute value) for the least square fit. The largest order $$N$$ for the fit is automatically determined based on the value of the largest frequency such that

$$\|\omega_{max}\|^{1-N} > 10^{-16}$$. The function will return a pair containing both the resulting high-frequency

moment array and an error corresponding to the mean deviation from the data.

fit_tail(G, known_moments)

• We can provide additional information to the fitting routine by passing an array with a set of known moments. The shape of this array should be of the form $$(N + 1, i, j, ...)$$ where the target_shape of G is given by $$(i, j, ...)$$.
fit_hermitian_tail(G_iw, [known_moments])

• Matsubara Green functions fulfill the general relation $$G_{ij}(i\omega) = G_{ji}^*(-i\omega)$$, which entails that the high-frequency coefficient matrices have to be hermitian. The fit_hermitian_tail function will enforce this property, but will otherwise take the same arguments as fit_tail.

Note

For convenience we prodive a free function make_zero_tail(G, max_order) that will, given the Green function G and the max_order, generate a tail-array of the proper shape initialized to 0.

### Example

#include <triqs/gfs.hpp>
#include <triqs/mesh.hpp>

using namespace triqs::gfs;
using namespace triqs;

int main() {

nda::clef::placeholder<0> iw_;

double beta  = 10;
auto iw_mesh = mesh::imfreq{beta, Fermion, 100};

auto G = gf<imfreq, scalar_valued>{iw_mesh, make_shape()};
G(iw_) << 1.0 / iw_ + 2.0 / iw_ / iw_ + 3.0 / iw_ / iw_ / iw_;

// We provide both the zeroth and first order coefficient to the fit
auto known_moments = array<dcomplex, 1>{0.0, 1.0};
auto [tail, err]   = fit_tail(G, known_moments);

std::cout << "tail: " << tail << "\nerror: " << err;
}


The experienced user can adjust the parameters of the fitting procedure directly:

G.mesh().set_tail_fit_parameters(tail_fraction, n_tail_max, expansion_order)


The fitting parameters are

• tail_fraction (double, default = 0.2) A value between 0 and 1.0 denoting the fraction of the frequency mesh (starting from the outer frequencies) to be considered for the fit.
• n_tail_max (integer, default = 30) The maximum number of frequency points to be considered for the fit on both the positive and negative side.
• expansion_order (integer, optional) This parameter will fix the largest order to be considered for the fit.

fit_tail_on_window(G_iw, n_min, n_max, known_moments, n_tail_max) -> std::pair<array<dcomplex, R>, double>

The parameters known_moments and n_tail_max behave as described above. Note that a variant of this function called fit_hermitian_tail_on_window enforces hermiticity of the coefficient matrices.