16 #ifndef ROOT_Math_Error 24 fFunctionCopied(false),
63 if (&rhs ==
this)
return *
this;
87 xx = x+
h;
double f1 = (
function)(xx);
89 xx = x-
h;
double f2 = (
function)(xx);
91 xx = x+h/2;
double g1 = (
function)(xx);
92 xx = x-h/2;
double g2 = (
function)(xx);
98 double deriv = h2*(8*d2 - d0)/3.;
104 double e0 = (std::abs( f1) + std::abs(f2)) * keps;
105 double e2 = 2* (std::abs( g1) + std::abs(g2)) * keps + e0;
106 double delta = std::max( std::abs( h2*d0), std::abs( deriv) ) * std::abs( x)/h * keps;
109 double err_trunc = std::abs( deriv - h2*d0 );
111 double err_round = std::abs( e2/h) + delta;
123 xx = x+h/4.0;
double f1 = (
function)(xx);
124 xx = x+h/2.0;
double f2 = (
function)(xx);
126 xx = x+(3.0/4.0)*
h;
double f3 = (
function)(xx);
127 xx = x+
h;
double f4 = (
function)(xx);
131 double r2 = 2.0*(f4 -
f2);
132 double r4 = (22.0 / 3.0) * (f4 - f3) - (62.0 / 3.0) * (f3 -
f2) +
133 (52.0 / 3.0) * (f2 -
f1);
137 double e4 = 2 * 20.67 * (
fabs (f4) +
fabs (f3) +
fabs (f2) +
fabs (f1)) * keps;
141 double dy = std::max (
fabs (r2 / h),
fabs (r4 / h)) *
fabs (x / h) * keps;
149 double abserr_trunc =
fabs ((r4 - r2) / h);
150 double abserr_round =
fabs (e4 / h) + dy;
163 xx = x+
h;
double f1 = (
function)(xx);
164 xx =
x;
double f2 = (
function)(xx);
165 xx = x-
h;
double f3 = (
function)(xx);
167 xx = x+h/2;
double g1 = (
function)(xx);
168 xx = x-h/2;
double g3 = (
function)(xx);
172 double d0 = f3 - 2*f2 +
f1;
173 double d2 = 4*g3 - 8*f2 +4*g1;
175 double deriv = hh*(4*d2 - d0)/3.;
184 xx = x+2*
h;
double f1 = (
function)(xx);
185 xx = x+
h;
double f2 = (
function)(xx);
186 xx = x-
h;
double f3 = (
function)(xx);
187 xx = x-2*
h;
double f4 = (
function)(xx);
188 xx =
x;
double fx = (
function)(xx);
189 xx = x+h/2;
double g2 = (
function)(xx);
190 xx = x-h/2;
double g3 = (
function)(xx);
193 double hhh = 1/(h*h*
h);
194 double d0 = 0.5*f1 - f2 +f3 - 0.5*f4;
195 double d2 = 4*f2 - 8*g2 +8*g3 - 4*f3;
197 double deriv = hhh*(4*d2 - d0)/3.;
double Derivative3(double x)
Returns the third derivative of the function at point x, computed by Richardson's extrapolation metho...
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
double DerivativeForward(double x)
Computation of the first derivative using a forward formula.
double Derivative2(double x)
Returns the second derivative of the function at point x, computed by Richardson's extrapolation meth...
void SetFunction(const IGenFunction &f)
Set function for derivative calculation (copy the function if option has been enabled in the construc...
double Derivative1(double x)
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
const IGenFunction * fFunction
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
~RichardsonDerivator()
Destructor: Removes function if needed.
RichardsonDerivator(double h=0.001)
Default Constructor.
Namespace for new Math classes and functions.
RichardsonDerivator & operator=(const RichardsonDerivator &rhs)
Assignment operator.
double f2(const double *x)
virtual IBaseFunctionOneDim * Clone() const =0
Clone a function.
User class for calculating the derivatives of a function.
unsigned int r2[N_CITIES]