#include <triqs/gfs.hpp>


  1. template<int N, typename G, typename A = typenameG::const_view_type::>
    std::pair<typename A::regular_type, double> fit_tail (G const & g, A const & known_moments = {})
  2. template<int N, typename BG, typename BA = std::vector<typenameBG::g_t::data_t::regular_type>
    std::pair<std::vector<typename BG::g_t::data_t::regular_type>, double> fit_tail (BG const & bg,
    BA const & known_moments = {})


1) Fit the tail of a Green function using a least-squares fitting procedure

2) Fit the tail of a Block Green function using a least-squares fitting procedure

Template parameters

  • N The position of the frequency mesh in case of a product mesh [default: 0]
  • G The type of the Green function (gf, gf_view, gf_const_view)
  • A The type of the high-frequency moment array (array, array_view, array_const_view)
  • BG The type of the Block Green function (block_gf, block_gf_view, block_gf_const_view)
  • AG The type of the high-frequecy moments for Block Green functions (e.g. std::vector<array>)


  • g The Green function object to fit the tail for
  • known_moments The object containing the known high-frequency moments
  • bg The Block Green function object to fit the tail for


A pair of the tail object and the fitting error


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

using namespace triqs::gfs;
using namespace triqs::mesh;
nda::clef::placeholder<0> iw_;

int main() {
  double beta = 1.0;
  int n_iw    = 100;
  auto g      = gf<imfreq>{{beta, Fermion, n_iw}, {1, 1}};
  g[iw_] << 1.0 / iw_;
  auto [tail, err] = fit_tail(g);
  std::cout << std::setprecision(2) << "Error: " << err << "\nTail:  " << tail;


Error: 5.4e-19
Tail:  [(2.7e-16,-4.2e-17),(1,-1.4e-14),(2.6e-10,-6e-11),(2.1e-09,-8.8e-09),(8.1e-05,-3.2e-05),(-0.00058,-0.0014),(8.4,-2.3)]