Class deriv_cern (o2scl)¶

template<class func_t = funct>
class deriv_cern : public o2scl::deriv_base<funct>¶ Numerical differentiation routine (CERNLIB)
This uses Romberg extrapolation to compute the derivative with the finitedifferencing formula
\[ f^{\prime}(x) = [f(x+h)f(xh)]/(2h) \]If deriv_base::verbose is greater than zero, then each iteration prints out the extrapolation table, and if deriv_base::verbose is greater than 1, then a keypress is required at the end of each iteration.
For sufficiently difficult functions, the derivative computation can fail, and will call the error handler and return zero with zero error.
Based on the CERNLIB routine DERIV, which was based on [Rutishauser63] and is documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d401/top.html
An example demonstrating the usage of this class is given in the Differentiation example.
If deriv_base::verbose is greater than zero, at each iteration this class prints something similar to
If deriv_base::verbose is greater than 1, a keypress is required after each iteration.deriv_cern, iteration: 1 (hh, a[k], derivative) list: 4.193459e05 4.387643e14 8.775286e01 2.995402e05 4.387792e14 8.775585e01 1.048405e05 4.387845e14 8.775690e01 7.488654e06 4.387882e14 8.775765e01 2.621038e06 4.387895e14 8.775791e01 1.872173e06 4.387905e14 8.775810e01 6.552611e07 4.387908e14 8.775817e01 4.680438e07 4.387910e14 8.775821e01 1.638153e07 4.387911e14 8.775823e01
 Idea for Future:
All of the coefficients appear to be fractions which could be replaced with exact representation?
Record the number of function calls?
Note
Second and third derivatives are computed by naive nested applications of the formula for the first derivative. No uncertainty for these derivatives is provided.
Public Functions

inline deriv_cern()¶

inline virtual int deriv_err(double x, func_t &func, double &dfdx, double &err)¶
Calculate the first derivative of
func
w.r.t. x and the uncertainty.

inline virtual const char *type()¶
Return string denoting type (“deriv_cern”)
Public Members

double delta¶
A scaling factor (default 1.0)

double eps¶
Extrapolation tolerance (default is \( 5 \times 10^{14} \))