[ 
https://issues.apache.org/jira/browse/MATH-1143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521431#comment-14521431
 ] 

Luc Maisonobe commented on MATH-1143:
-------------------------------------

{quote}
I am not sure I understand, how this constructor works. It seems that it 
defines derivatives in the fixed point.
{quote}

Yes. A DerivativeStructure instance is just one set of values, just like a 
double which would hold a value f(x). If you want to have f(x) for several x 
values, you create as many double as you want, this is the same for 
DerivativeStructure, you create one instance for each x value.

Your example to create a function is almost good. It just misses one point: you 
don't use the derivatives of ds itself, only its value. This may be fine if you 
are sure ds is already your canonical variable, but it would not work if your 
function is the last step of a composition. The DerivativeStructure class has 
been created to handle the second case, which explains why it seems overkill in 
simpler cases.

In fact, in your case you seem to already do separately the computation of the 
derivatives with separate code, using your someDerivativeCalculationHere 
function. This is the kind of things DerivativesStructure could do for you. In 
fact, as long as you have a way to implement "someOperationHere" using only 
Java (i.e. with primitive operations, Math/FastMath/StrictMath functions and 
even calls to intermediate functions, then you can reimplement it so it 
directly computes the derivatives at the same time and most importantly at any 
order, without requiring you to find the expression for the derivatives. This 
is the essence of automatic differentiation. There is even the Apache Commons 
Nable project (unfortunately not fully functional) that could do this for you, 
i.e. you give it a UnivariateFunction and it creates the corresponding 
UnivariateDifferentiableFunction automatically.

What you seem to ask here is for something different: you already have the 
function and derivatives available, but probably only at the order at which you 
did code them. Then if you want to put the result in a DerivativeStructure 
instance, the class simply acts as a container for the values, and serves no 
other purpose. Then of course it seems complicated for just doing this.

> Helper methods to FiniteDifferencesDifferentiator
> -------------------------------------------------
>
>                 Key: MATH-1143
>                 URL: https://issues.apache.org/jira/browse/MATH-1143
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Alexander Nozik
>            Priority: Trivial
>
> 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.
> 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).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to