TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
Utilities (experimental)

Detailed Description

Adaptive 1D integration, a generic CLEF integrator wrapper and root-finding routines.

These utilities provide the numerical building blocks used by the experimental Lattice tools (experimental) tools: an adaptive 13-point Kronrod 1D integrator, a generic wrapper that integrates CLEF expressions over a placeholder, and dichotomy/bisection root finding.

Classes

class  triqs::experimental::utility::integrate_1d_adapt< T >
 Adaptive one-dimensional integrator based on a 13-point Gauss-Kronrod-Lobatto rule. More...

Functions

std::pair< double, double > triqs::experimental::utility::bisection (std::function< double(double)> f, double x_low, double x_high, double y_target, double precision, long max_loops, std::string x_name, std::string y_name, bool verbosity)
 Solve \( f(x) = y \) on a bracketing interval using the bisection method.
std::pair< double, double > triqs::experimental::utility::dichotomy (std::function< double(double)> f, double x_low, double x_high, double y_target, double precision, long max_loops, std::string x_name, std::string y_name, bool verbosity)
 Solve \( f(x) = y \) on a bracketing interval using the false-position (dichotomy) method.
std::pair< double, double > triqs::experimental::utility::find_bounds (std::function< double(double)> f, double x_init, double y_value, double delta_x, double precision, long max_loops=1000)
 Find a lower and an upper bound that bracket the solution of \( f(x) = y \).
template<typename D, int I>
auto triqs::experimental::utility::integrate (auto const &integrator1d, auto expr_to_integrate, nda::clef::pair< I, D > const &p)
 Integrate a CLEF expression over one of its placeholders using an arbitrary one-dimensional integrator.
std::pair< double, double > triqs::experimental::utility::root_finder (std::string method, std::function< double(double)> f, double x_init, double y_value, double precision, double delta_x, long max_loops=1000, std::string x_name="", std::string y_name="", bool verbosity=false)
 Find the value \( x \) that solves \( f(x) = y \) using the requested root-finding method.

Function Documentation

◆ bisection()

std::pair< double, double > triqs::experimental::utility::bisection ( std::function< double(double)> f,
double x_low,
double x_high,
double y_target,
double precision,
long max_loops,
std::string x_name,
std::string y_name,
bool verbosity )
inline

#include <triqs/experimental/utility/root_finder.hpp>

Solve \( f(x) = y \) on a bracketing interval using the bisection method.

Given an interval \( [x_\mathrm{low}, x_\mathrm{high}] \) that brackets the target value, this method repeatedly halves the interval, keeping the half in which the target value remains bracketed, until the residual drops below the requested precision.

It raises an error if convergence is not reached within max_loops iterations.

Parameters
fFunction \( f(x) : \mathbb{R} \to \mathbb{R} \) whose root is sought.
x_lowLower bound of the bracketing interval.
x_highUpper bound of the bracketing interval.
y_targetTarget value \( y \) for \( f(x) \).
precisionAbsolute precision \( |f(x) - y| \) at which the iteration stops.
max_loopsMaximum number of iterations.
x_nameName of the \( x \) variable, used in the progress log.
y_nameName of the \( y \) variable, used in the progress log.
verbosityWhether to print the convergence progress.
Returns
Pair \( (x, f(x)) \) with \( f(x) = y \) within the requested precision.

Definition at line 153 of file root_finder.hpp.

◆ dichotomy()

std::pair< double, double > triqs::experimental::utility::dichotomy ( std::function< double(double)> f,
double x_low,
double x_high,
double y_target,
double precision,
long max_loops,
std::string x_name,
std::string y_name,
bool verbosity )
inline

#include <triqs/experimental/utility/root_finder.hpp>

Solve \( f(x) = y \) on a bracketing interval using the false-position (dichotomy) method.

Given an interval \( [x_\mathrm{low}, x_\mathrm{high}] \) that brackets the target value, this method iteratively replaces one of the bounds with the linear (secant) estimate of the root until the residual drops below the requested precision.

It raises an error if convergence is not reached within max_loops iterations.

Parameters
fFunction \( f(x) : \mathbb{R} \to \mathbb{R} \) whose root is sought.
x_lowLower bound of the bracketing interval.
x_highUpper bound of the bracketing interval.
y_targetTarget value \( y \) for \( f(x) \).
precisionAbsolute precision \( |f(x) - y| \) at which the iteration stops.
max_loopsMaximum number of iterations.
x_nameName of the \( x \) variable, used in the progress log.
y_nameName of the \( y \) variable, used in the progress log.
verbosityWhether to print the convergence progress.
Returns
Pair \( (x, f(x)) \) with \( f(x) = y \) within the requested precision.

Definition at line 92 of file root_finder.hpp.

◆ find_bounds()

std::pair< double, double > triqs::experimental::utility::find_bounds ( std::function< double(double)> f,
double x_init,
double y_value,
double delta_x,
double precision,
long max_loops = 1000 )
inline

#include <triqs/experimental/utility/root_finder.hpp>

Find a lower and an upper bound that bracket the solution of \( f(x) = y \).

Starting from an initial guess, this function steps along \( x \) in increments of delta_x until the target value \( y \) is bracketed by the function values at the two most recent points (or until the maximum number of steps is reached). The returned bounds are ordered such that the first is smaller than the second.

Parameters
fFunction \( f(x) : \mathbb{R} \to \mathbb{R} \) whose root is sought.
x_initInitial guess for \( x \).
y_valueTarget value \( y = f(x) \).
delta_xStep size by which \( x \) is incremented.
precisionAbsolute precision \( |f(x) - y| \) used to stop the search early.
max_loopsMaximum number of steps.
Returns
Pair \( (x_1, x_2) \) with \( x_1 \leq x_2 \) whose function values bracket \( y \).

Definition at line 45 of file root_finder.hpp.

◆ integrate()

template<typename D, int I>
auto triqs::experimental::utility::integrate ( auto const & integrator1d,
auto expr_to_integrate,
nda::clef::pair< I, D > const & p )

#include <triqs/experimental/utility/integrator.hpp>

Integrate a CLEF expression over one of its placeholders using an arbitrary one-dimensional integrator.

This function turns the given expression into a unary CLEF function of the placeholder with index \( I \) and hands it to the supplied one-dimensional integrator together with the integration domain. If the expression still depends on other placeholders, the result is again a lazy CLEF expression; otherwise it is the value of the integral.

Template Parameters
DType of the integration domain (e.g. a pair of bounds).
IIndex of the placeholder that is integrated over.
Parameters
integrator1dOne-dimensional integrator that integrates a callable \( f(x) \) over the domain.
expr_to_integrateCLEF expression to be integrated.
pPlaceholder-to-domain assignment, i.e. a placeholder = domain pair.
Returns
Lazy CLEF expression if other placeholders remain, otherwise the value of the integral.

Definition at line 29 of file integrator.hpp.

◆ root_finder()

std::pair< double, double > triqs::experimental::utility::root_finder ( std::string method,
std::function< double(double)> f,
double x_init,
double y_value,
double precision,
double delta_x,
long max_loops = 1000,
std::string x_name = "",
std::string y_name = "",
bool verbosity = false )
inline

#include <triqs/experimental/utility/root_finder.hpp>

Find the value \( x \) that solves \( f(x) = y \) using the requested root-finding method.

This is the main entry point of the root finder. It first brackets the solution and then refines it with either a dichotomy or a bisection step, depending on the chosen method.

It raises an error if the method name is not recognized.

Parameters
methodRoot-finding method, either "dichotomy" or "bisection".
fFunction \( f(x) : \mathbb{R} \to \mathbb{R} \) whose root is sought.
x_initInitial guess for \( x \).
y_valueTarget value \( y \) for \( f(x) \).
precisionAbsolute precision \( |f(x) - y| \) at which the iteration stops.
delta_xStep size used when bracketing the solution.
max_loopsMaximum number of iterations.
x_nameName of the \( x \) variable, used in the progress log.
y_nameName of the \( y = f(x) \) variable, used in the progress log.
verbosityWhether to print the convergence progress.
Returns
Pair \( (x, f(x)) \) with \( f(x) = y \) within the requested precision.

Definition at line 201 of file root_finder.hpp.