commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Nozik <>
Subject [math] FiniteDifferencesDifferentiator is not convenient for simple differentiation task
Date Wed, 06 Aug 2014 13:53:35 GMT
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 = 
         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:
For additional commands, e-mail:

View raw message