Class deriv_multip_gsl (o2scl)¶
-
class deriv_multip_gsl¶
Evalulate a derivative to within a requested tolerance using multiprecision if necessary.
Experimental.
This class uses funct_multip to ensure the function evaluations are sufficiently accurate and then ensures that the derivative evaluation is below the requested relative tolerance. If the relative tolerance is not specified, then \( 10^{-d} \) is used where \( d \) is the value reported by
numeric_limits::digits10
for the input floating point type.Todo
In class deriv_multip_gsl:
More carefully optimize pow_tol_func and the stepsize guesses.
Allow the user to specify the value of ‘h’ for the individual derivative objects.
Allow the user to determine how many function evaluations or precision required for the last derivative.
Note
Derivatives near zero can be particularly troublesome, even for simple functions, since this class only uses relative tolerances.
Public Functions
-
inline deriv_multip_gsl()¶
Public Members
-
double h¶
Initial stepsize.
This should be specified before a call to deriv() or deriv_err(). If it is less than or equal to zero, then \( x 10^{-4} \) will used, or if
x
is zero, then \( 10^{-4} \) will be used.
-
double h_opt¶
The last value of the optimized stepsize.
This is initialized to zero in the constructor and set by deriv_err() to the most recent value of the optimized stepsize.
-
double tol_rel¶
Relative tolerance.
-
double pow_tol_func¶
Power for tolerance of function evaluations (default 1.33)
-
int verbose¶
Verbosity parameter.
Protected Functions
-
template<typename func_t, class fp_t>
inline int deriv_err_int(func_t &&f, fp_t x, fp_t &dfdx, fp_t &err, double tol)¶ Calculate the first derivative of
func
w.r.t. x and uncertainty.
-
template<typename func_t, class fp_t>
inline int central_deriv(func_t &&func, fp_t x, double hh, fp_t &result, fp_t &abserr_round, fp_t &abserr_trunc, double func_tol)¶ Compute derivative using 5-point rule.
Compute the derivative using the 5-point rule (x-h, x-h/2, x, x+h/2, x+h) and the error using the difference between the 5-point and the 3-point rule (x-h,x,x+h). Note that the central point is not used for either.
The value \c func_tol is the error tolerance for the function evaluations.