Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
clad::custom_derivatives::ROOT::Math Namespace Reference

Functions

template<unsigned N>
double horner (const double(&c)[N], double x)
 Evaluate the polynomial c[0] + c[1]*x + c[2]*x^2 + ... in Horner form, matching the evaluation order of the CERNLIB Landau routines below.
 
template<unsigned N>
double horner_deriv (const double(&c)[N], double x)
 Derivative of horner(c, x) with respect to x.
 
void inc_gamma_c_pullback (double a, double x, double _d_y, double *_d_a, double *_d_x)
 
clad::ValueAndPushforward< double, doubleinc_gamma_c_pushforward (double a, double x, double d_a, double d_x)
 Pushforward of ROOT::Math::inc_gamma_c, which is 1 - inc_gamma.
 
double inc_gamma_da (double a, double x)
 Derivative of the normalized lower incomplete gamma function P(a, x) with respect to a.
 
void inc_gamma_da_pullback (double a, double x, double _d_y, double *_d_a, double *_d_x)
 Pullback of inc_gamma_da().
 
double inc_gamma_dx (double a, double x)
 Derivative of the normalized lower incomplete gamma function P(a, x) with respect to x.
 
void inc_gamma_dx_pullback (double a, double x, double _d_y, double *_d_a, double *_d_x)
 Pullback of inc_gamma_dx(), using the closed forms of the second derivatives of P(a, x):
 
void inc_gamma_pullback (double a, double x, double _d_y, double *_d_a, double *_d_x)
 
clad::ValueAndPushforward< double, doubleinc_gamma_pushforward (double a, double x, double d_a, double d_x)
 Pushforward of ROOT::Math::inc_gamma.
 
double landau_cdf_dv (double v)
 Derivative with respect to v of the CERNLIB DISLAN rational approximation of the standardized Landau cumulative distribution, obtained by differentiating each branch of landau_cdf() in ProbFuncMathCore.cxx, whose branch structure and coefficient tables this function mirrors.
 
void landau_cdf_pullback (double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
 
clad::ValueAndPushforward< double, doublelandau_cdf_pushforward (double x, double xi, double x0, double d_x, double d_xi, double d_x0)
 Pushforward of ROOT::Math::landau_cdf, which is the cumulative distribution function of the standardized Landau density evaluated at (x - x0) / xi.
 
double landau_pdf_dv (double v)
 First derivative of the standardized Landau density p(v) = ROOT::Math::landau_pdf(v) with respect to v, obtained by differentiating each branch of the CERNLIB DENLAN rational approximation.
 
void landau_pdf_dv_pullback (double v, double _d_y, double *_d_v)
 Pullback of landau_pdf_dv().
 
void landau_pdf_pullback (double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
 
clad::ValueAndPushforward< double, doublelandau_pdf_pushforward (double x, double xi, double x0, double d_x, double d_xi, double d_x0)
 Pushforward of ROOT::Math::landau_pdf, which is p((x - x0) / xi) / xi in terms of the standardized Landau density p.
 
template<unsigned N, unsigned M>
double rational_deriv (const double(&p)[N], const double(&q)[M], double x)
 Derivative of the rational function horner(p, x) / horner(q, x) with respect to x.
 

Function Documentation

◆ horner()

template<unsigned N>
double clad::custom_derivatives::ROOT::Math::horner ( const double(&) c[N],
double x )

Evaluate the polynomial c[0] + c[1]*x + c[2]*x^2 + ... in Horner form, matching the evaluation order of the CERNLIB Landau routines below.

Definition at line 209 of file CladDerivator.h.

◆ horner_deriv()

template<unsigned N>
double clad::custom_derivatives::ROOT::Math::horner_deriv ( const double(&) c[N],
double x )

Derivative of horner(c, x) with respect to x.

Definition at line 219 of file CladDerivator.h.

◆ inc_gamma_c_pullback()

void clad::custom_derivatives::ROOT::Math::inc_gamma_c_pullback ( double a,
double x,
double _d_y,
double * _d_a,
double * _d_x )
inline

Definition at line 522 of file CladDerivator.h.

◆ inc_gamma_c_pushforward()

clad::ValueAndPushforward< double, double > clad::custom_derivatives::ROOT::Math::inc_gamma_c_pushforward ( double a,
double x,
double d_a,
double d_x )
inline

Pushforward of ROOT::Math::inc_gamma_c, which is 1 - inc_gamma.

See inc_gamma_pushforward().

Definition at line 900 of file CladDerivator.h.

◆ inc_gamma_da()

double clad::custom_derivatives::ROOT::Math::inc_gamma_da ( double a,
double x )
inline

Derivative of the normalized lower incomplete gamma function P(a, x) with respect to a.

It has no closed form, but inc_gamma_pullback() computes it exactly by differentiating through the algorithm that evaluates P(a, x).

Definition at line 859 of file CladDerivator.h.

◆ inc_gamma_da_pullback()

void clad::custom_derivatives::ROOT::Math::inc_gamma_da_pullback ( double a,
double x,
double _d_y,
double * _d_a,
double * _d_x )
inline

Pullback of inc_gamma_da().

The mixed second derivative is known in closed form (it is the same as the a-derivative of inc_gamma_dx(), see inc_gamma_dx_pullback()). For d2P/da2 there is no closed form, so it is approximated by a central difference of the exact first derivative.

For a <= h, the lower stencil point leaves the domain (inc_gamma_da() returns zero for non-positive a), so d2P/da2 is unreliable there. This is acceptable because RooFit never differentiates with respect to a, which is data there.

Definition at line 876 of file CladDerivator.h.

◆ inc_gamma_dx()

double clad::custom_derivatives::ROOT::Math::inc_gamma_dx ( double a,
double x )
inline

Derivative of the normalized lower incomplete gamma function P(a, x) with respect to x.

This is the integrand of P(a, x), i.e. the gamma distribution density: x^(a-1) * exp(-x) / Gamma(a).

Definition at line 835 of file CladDerivator.h.

◆ inc_gamma_dx_pullback()

void clad::custom_derivatives::ROOT::Math::inc_gamma_dx_pullback ( double a,
double x,
double _d_y,
double * _d_a,
double * _d_x )
inline

Pullback of inc_gamma_dx(), using the closed forms of the second derivatives of P(a, x):

d2P/dx2 = inc_gamma_dx(a, x) * ((a - 1) / x - 1) d2P/dxda = inc_gamma_dx(a, x) * (log(x) - digamma(a))

Definition at line 847 of file CladDerivator.h.

◆ inc_gamma_pullback()

void clad::custom_derivatives::ROOT::Math::inc_gamma_pullback ( double a,
double x,
double _d_y,
double * _d_a,
double * _d_x )
inline

Definition at line 406 of file CladDerivator.h.

◆ inc_gamma_pushforward()

clad::ValueAndPushforward< double, double > clad::custom_derivatives::ROOT::Math::inc_gamma_pushforward ( double a,
double x,
double d_a,
double d_x )
inline

Pushforward of ROOT::Math::inc_gamma.

Besides forward-mode differentiation, this enables second derivatives (e.g. clad::hessian): clad differentiates this function in reverse mode, and all derivatives it needs for that are provided by custom pullbacks.

Definition at line 893 of file CladDerivator.h.

◆ landau_cdf_dv()

double clad::custom_derivatives::ROOT::Math::landau_cdf_dv ( double v)
inline

Derivative with respect to v of the CERNLIB DISLAN rational approximation of the standardized Landau cumulative distribution, obtained by differentiating each branch of landau_cdf() in ProbFuncMathCore.cxx, whose branch structure and coefficient tables this function mirrors.

Since DISLAN is an approximation of its own, this is not identical to landau_pdf() (they are consistent to about 1e-7 relative).

Definition at line 330 of file CladDerivator.h.

◆ landau_cdf_pullback()

void clad::custom_derivatives::ROOT::Math::landau_cdf_pullback ( double x,
double xi,
double x0,
double d_out,
double * d_x,
double * d_xi,
double * d_x0 )
inline

Definition at line 394 of file CladDerivator.h.

◆ landau_cdf_pushforward()

clad::ValueAndPushforward< double, double > clad::custom_derivatives::ROOT::Math::landau_cdf_pushforward ( double x,
double xi,
double x0,
double d_x,
double d_xi,
double d_x0 )
inline

Pushforward of ROOT::Math::landau_cdf, which is the cumulative distribution function of the standardized Landau density evaluated at (x - x0) / xi.

Its derivative in x is landau_pdf, so unlike for the density itself, all second derivatives are known in closed form.

That identity is exact only for the mathematical Landau distribution: ROOT implements the cdf (CERNLIB DISLAN) and the density (CERNLIB DENLAN) as independent rational approximations that are consistent with each other to about 1e-7 relative. The derivatives returned here therefore differ at that level both from the exact derivative of the implemented cdf and from landau_cdf_pullback(), which differentiates the DISLAN algorithm itself.

Definition at line 966 of file CladDerivator.h.

◆ landau_pdf_dv()

double clad::custom_derivatives::ROOT::Math::landau_pdf_dv ( double v)
inline

First derivative of the standardized Landau density p(v) = ROOT::Math::landau_pdf(v) with respect to v, obtained by differentiating each branch of the CERNLIB DENLAN rational approximation.

The branch structure and the coefficient tables mirror landau_pdf() in PdfFuncMathCore.cxx. Used by landau_pdf_pullback() and by the second-derivative helpers further down.

Definition at line 242 of file CladDerivator.h.

◆ landau_pdf_dv_pullback()

void clad::custom_derivatives::ROOT::Math::landau_pdf_dv_pullback ( double v,
double _d_y,
double * _d_v )
inline

Pullback of landau_pdf_dv().

The second derivative of the standardized Landau density has no closed form, so it is approximated by a central difference of the exact first derivative (see also inc_gamma_da_pullback()).

The CERNLIB DENLAN approximation of the density is piecewise rational, and its first derivative has small jumps at the branch boundaries. Dividing such a jump by the step size would ruin the difference quotient (up to ~50 % error right at v = 1), so when the stencil would straddle a boundary it is shifted sideways to keep both points on the branch that contains v. The off-center evaluation costs one order in h, which is insignificant at this step size.

Definition at line 916 of file CladDerivator.h.

◆ landau_pdf_pullback()

void clad::custom_derivatives::ROOT::Math::landau_pdf_pullback ( double x,
double xi,
double x0,
double d_out,
double * d_x,
double * d_xi,
double * d_x0 )
inline

Definition at line 310 of file CladDerivator.h.

◆ landau_pdf_pushforward()

clad::ValueAndPushforward< double, double > clad::custom_derivatives::ROOT::Math::landau_pdf_pushforward ( double x,
double xi,
double x0,
double d_x,
double d_xi,
double d_x0 )
inline

Pushforward of ROOT::Math::landau_pdf, which is p((x - x0) / xi) / xi in terms of the standardized Landau density p.

Like for inc_gamma_pushforward(), all derivatives that clad needs to differentiate this function in reverse mode (e.g. for clad::hessian) are provided by custom pullbacks.

Definition at line 944 of file CladDerivator.h.

◆ rational_deriv()

template<unsigned N, unsigned M>
double clad::custom_derivatives::ROOT::Math::rational_deriv ( const double(&) p[N],
const double(&) q[M],
double x )

Derivative of the rational function horner(p, x) / horner(q, x) with respect to x.

Definition at line 230 of file CladDerivator.h.