24 #include "../Atomicrex.h" 38 double compute(
double x,
double& error,
double epsilon = 1e-5) {
42 error = round + trunc;
43 if(round < trunc && (round > 0 && trunc > 0)) {
47 double h_opt = epsilon * pow(round / (2.0 * trunc), 1.0 / 3.0);
48 double round_opt, trunc_opt;
50 double error_opt = round_opt + trunc_opt;
54 if(error_opt < error && fabs(r_opt - r_0) < 4.0 * error) {
67 virtual double evaluate(
double x) = 0;
82 double r3 = 0.5 * (fp1 - fm1);
83 double r5 = (4.0 / 3.0) * (fph - fmh) - (1.0 / 3.0) * r3;
85 const double CENTRAL_DBL_EPSILON = 2.2204460492503131e-16;
86 double e3 = (fabs(fp1) + fabs(fm1)) * CENTRAL_DBL_EPSILON;
87 double e5 = 2.0 * (fabs(fph) + fabs(fmh)) * CENTRAL_DBL_EPSILON + e3;
94 double result = r5 / h;
95 abserr_trunc = fabs((r5 - r3) / h);
96 abserr_round = fabs(e5 / h);
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
double centralDerivative(double x, double h, double &abserr_trunc, double &abserr_round)
Definition: NumericalDerivative.h:71
Definition: NumericalDerivative.h:32
double compute(double x, double &error, double epsilon=1e-5)
Definition: NumericalDerivative.h:38
virtual double evaluate(double x)=0