commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Cliff <m...@mattcliff.com>
Subject [math] Numerical Derivative pattern q.
Date Tue, 11 Nov 2003 22:50:18 GMT
I have been scratching out an implementation of a numerical derivative to 
add to the commons-math and keep going back and forth between two 
approaches.
 
  (all this would be in the o.a.c.math.analysis package)
  (for brevity I have omitted the prefix UnivariateReal* )
--------------------------------------------------------------------
 (1) a couple classes like Differentiator (interface) and 
DifferentiatorFactory (class), where we have a method like
   "Differentiator DifferentiatorFactory.getDefaultDifferentiator( 
Function f )"

  and another method like "double Differentiator.derivate( double x)"
     or  "double Differentiator.value(double x)"

  
   this keeps the same type of pattern as that of the *Solver

OR

  (2) Add a class like DerivativeFactory which has a method like
        "Function DerivativeFactory.getDefaultDerivative( Function f )"

   and use the existing "double Function.value( double x)" to obtain the 
numerical estimate.


  I first implemented it using approach (1) but as the code and usage
turned out, it seems that (2) was easier to use (and numerically has the
same number or operations and function evaluations).




----------------------------------------------------------------------
using (2) the client code would look like

public myMethod() {
   UnivariateRealFunction f = new SomeUserDefinedFunction();
   
   UnivariateRealFunction fprime = 
         DerivativeFactory.newInstance().getDefaultDerivative( f );

   System.out.println( "f'(1.0) = "+ fprime.value(1.0) );
}


-------------------------------------------------------------------------

 of course the Factory could allow for multiple types of Derivatives,  the 
one I have currently implemented is a centered 5-point algorithm, which 
has an operational parameter of h (or a step-size), there may also be 
parameters to handle "infinite" derivative or jumps.



-- 
      Matt Cliff            
      Cliff Consulting

      The label said install Windows 98 or better so I installed Linux.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message