You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alexander Nozik <al...@gmail.com> on 2014/08/06 15:53:35 UTC
[math] FiniteDifferencesDifferentiator is not convenient for simple
differentiation task
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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [math] FiniteDifferencesDifferentiator is not convenient for
simple differentiation task
Posted by Luc Maisonobe <lu...@spaceroots.org>.
Hi Alexander
Le 06/08/2014 15:53, Alexander Nozik a écrit :
> 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.
You are right, helper methods would be good.
Could you open a Jira issue with this idea so we don't forget it?
best regards,
Luc
>
> With best regards, Alexander Nozik.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org