A DerivativeStructure and UnivariateDifferentiableFunction are great
tools if one needs to investigate the whole function but are not
convenient if one just needs derivative in a given point.
In order to calculate a derivative of function in a given point one
needs something like that:
public static double calculateDerivative(UnivariateFunction
function, double point, double step) {
FiniteDifferencesDifferentiator diff = new
FiniteDifferencesDifferentiator(numPoints, step);
UnivariateDifferentiableFunction derivative =
diff.differentiate(function);
DerivativeStructure x = new DerivativeStructure(1, 1, 0, point);
DerivativeStructure y = derivative.value(x);
return y.getPartialDerivative(1);
}
which is not very convenient. Perhaps you could add some helper methods
to FiniteDifferencesDifferentiator or to utility class like
FunctionUtils. Also it would be good to have helper methods to get the
derivatives of UnivariateDifferentiableFunction or
MultivariateDifferentiableFunction as simple Univariate or Multivariate
functions (or vector-functions). In java 8 it could be simply done by
adding some default methods to corresponding interfaces. But since
commons-math does not support java 8 (as far as I can understand), it
should be some utility class.
With best regards, Alexander Nozik.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]