[jira] [Comment Edited] (MATH-1143) Helper methods to FiniteDifferencesDifferentiator

2015-04-30 Thread Luc Maisonobe (JIRA)

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

Luc Maisonobe edited comment on MATH-1143 at 4/30/15 11:24 AM:
---

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 has 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.


was (Author: luc):
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)


[jira] [Comment Edited] (MATH-1143) Helper methods to FiniteDifferencesDifferentiator

2015-04-30 Thread Alexander Nozik (JIRA)

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

Alexander Nozik edited comment on MATH-1143 at 4/30/15 12:21 PM:
-

I am not sure I understand, how this constructor works. It seems that it 
defines derivatives in the fixed point. How can I define a function for which I 
know value and first derivative in any given point? Something like that?
{code}
  UnivariateDifferentiableFunction f = (DerivativeStructure ds) - {
double val = someOerationHere(ds.value);
double deriv = someDerivativeCalculationHere(ds.value)
return new DerivativeStructure(1, 1, val, deriv);
  };
{code}
Anyway, it seems a bit complicated construct. I think it would be better to 
create some kind of helper class (say DifferentiableFuncitonBuilder), in which 
on could set function and its derivatives separately. Later one can add some 
pretty fancy functionality like building function from String representation.


was (Author: darksnake):
I am not sure I understand, how this constructor works. It seems that it 
defines derivatives in the fixed point. How can I define a function for which I 
know value and first derivative in any given point? Something like that?
{code}
  UnivariateFunction f = (DerivativeStructure ds) - {
double val = someOerationHere(ds.value);
double deriv = someDerivativeCalculationHere(ds.value)
return new DerivativeStructure(1, 1, val, deriv);
  };
{code}
Anyway, it seems a bit complicated construct. I think it would be better to 
create some kind of helper class (say DifferentiableFuncitonBuilder), in which 
on could set function and its derivatives separately. Later one can add some 
pretty fancy functionality like building function from String representation.

 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)