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

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

If you have function f(x1, x2, x3) and know both the value and the derivatives, 
you can directly build the DerivativeStructure as follows:

{code}
  int nbParams = 3; // index 0 will be for x1, index 1 for x2, index 2 for x3
  int order         = 1; // we will use only value and first order derivative
  return new DerivativeStructure(nbParams, order, f, dfdx1, dfdx2, dfdx3);
{code}

As this constructor as a variable number of arguments, this example can be 
generalized
to other numbers of parameters.

The order in which the derivatives should be provided is difficult to set up in 
the general case
when both nbParams and order are greater than 1, but it is straightforward in 
the two limit
cases (nbParams = 1, order > 1) or (nbParams > 1, order = 1). In both cases, 
you just give
the derivatives in the "natural" order, which is in increasing order when you 
have one parameter
and high order derivatives, and in parameters order when you have only first 
order derivatives
for all parameters.

> 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