/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
ex.prependContext("Error generating cubic spline table for function '" + thisFuncInput.desc + "'");
throw;
}
- // Calculate the required table spacing h. The error we make with linear interpolation
- // of the derivative will be described by the third-derivative correction term.
- // This means we can compute the required spacing as h = sqrt(12*tolerance*min(f'/f''')),
- // where f'/f''' is the first and third derivative of the function, respectively.
+ // Calculate the required table spacing h. The error we make with a third order polynomial
+ // (second order for derivative) will be described by the fourth-derivative correction term.
+ //
+ // This means we can compute the required spacing as h = 0.5*cbrt(72*sqrt(3)*tolerance**min(f'/f'''')),
+ // where f'/f'''' is the first and fourth derivative of the function, respectively.
+ // Since we already have an analytical form of the derivative, we reduce the numerical
+ // errors by calculating the quotient of the function and third derivative of the
+ // input-derivative-analytical function instead.
double thisMinQuotient = internal::findSmallestQuotientOfFunctionAndThirdDerivative(thisFuncInput.derivative, range_);