org.apache.commons.nabla.numerical
Class FiniteDifferencesDifferentiator

java.lang.Object
  extended by org.apache.commons.nabla.numerical.FiniteDifferencesDifferentiator
All Implemented Interfaces:
Serializable, UnivariateDifferentiator
Direct Known Subclasses:
EightPointsScheme, FourPointsScheme, SixPointsScheme, TwoPointsScheme

public abstract class FiniteDifferencesDifferentiator
extends Object
implements UnivariateDifferentiator, Serializable

This class represents a differentiation scheme based on finite differences.

The differences are based on regularly distributed points around the central test point according to a given h step. For example a four points scheme would use a linear combination of points f(x-2h), f(x-h), f(x+h) and f(x+2h) to compute the first derivative f'(x) (note that f(x) by itself is not used for the evaluation of f'(x), but is used to compute the value of the function f(x)

The computed differential is only an approximation. The error depends on the value of the high order derivatives of the function which were not canceled by the linear combination, the number of points and the step size. For example the four points scheme cancels the f(2), f(3) and f(4) high order derivatives but not the f(5) and higher order terms. The theoretical error model for this scheme is -2h4/5 f(5)(x) + O(h6). This model doesn't take into account numerical cancellation which occur when the steps are too small.

The general expression of the theoretical error model is A f(k) + O(hk+1) where A is the value returned by getSignedErrorScaleFactor() and k is the value returned by getOrderFirstNonCanceled().

See Also:
Serialized Form

Constructor Summary
protected FiniteDifferencesDifferentiator(double stepSize, double factor, int order)
          Simple constructor.
 
Method Summary
 int getOrderFirstNonCanceled()
          Get the order of the first non-canceled derivative.
 double getSignedErrorScaleFactor()
          Get the signed error scale factor for the finite differences scheme.
protected  double getStepSize()
          Get the step size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.nabla.core.UnivariateDifferentiator
differentiate
 

Constructor Detail

FiniteDifferencesDifferentiator

protected FiniteDifferencesDifferentiator(double stepSize,
                                          double factor,
                                          int order)
Simple constructor.

Parameters:
stepSize - step stepSize
factor - error scale factor
order - order of the first non-canceled derivative
Method Detail

getSignedErrorScaleFactor

public double getSignedErrorScaleFactor()
Get the signed error scale factor for the finite differences scheme.

The error scale factor is the value of the h-dependent factor of the first non-canceled high order differential of the function. For example since the error model for the four points scheme is -2h4/5 f(5)(x) + O(h6), the signed error scale factor is -2h4/5.

Returns:
error signed scale factor
See Also:
getOrderFirstNonCanceled()

getOrderFirstNonCanceled

public int getOrderFirstNonCanceled()
Get the order of the first non-canceled derivative.

The error model of the scheme depends on the first non-canceled high order differential of the function. For example since the error model for the four points scheme is -2h4/5 f(5)(x) + O(h6), the order of the first non-canceled derivative is 5.

Returns:
order of the first non-canceled derivative
See Also:
getSignedErrorScaleFactor()

getStepSize

protected double getStepSize()
Get the step size.

Returns:
step size


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.