Package org.opensourcephysics.numerics
Class Derivative
java.lang.Object
org.opensourcephysics.numerics.Derivative
Derivative defines various derivative algorithms. This class cannot be
subclassed or instantiated because all methods are static.
- Author:
- Wolfgang Christian
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Calculates the first derivative of a function using the finite difference approximation toward decreasing x.static double
Calculates the first derivative of a function using the centered finite difference approximation.static double
Calculates the first derivative of a function at the given point.static double
firstPartial
(MultiVarFunction f, double[] x, int n, double h) Gets the partial derivate of a multivariable function using the centered finite difference approximation.static double
Calculates the first derivative of a function using the finite difference approximation toward increasing x.static Function
Gets a derivative function using the centered difference approximation.static Function
Gets a second derivative function using a second order finite difference approximation.static double
Calculates the derivative using the Romberg scheme for Richardson extrapolation.static double
Computes the second derivate using the centered finite difference approximation.
-
Method Details
-
getFirst
Gets a derivative function using the centered difference approximation.- Parameters:
f
- Function f(x)h
- double change in x- Returns:
- Function
-
getSecond
Gets a second derivative function using a second order finite difference approximation.- Parameters:
f
- Function f(x)h
- double change in x- Returns:
- Function second derivate
-
romberg
Calculates the derivative using the Romberg scheme for Richardson extrapolation. This method runs until all Romberg rows are filled or until the step size drops below defaultNumericalPrecision or if the desired tolerance is reached.- Parameters:
f
- the functionx0
- where derivative is to be calculatedh
- initial step sizetol
- desired accuracyd6
- scratch double[6]- Returns:
- first derivative
-
first
Calculates the first derivative of a function at the given point. The current implementation uses the centered finite difference method but this may change.- Parameters:
f
- the functionx
- the x valueh
-- Returns:
- first derivative
-
centered
Calculates the first derivative of a function using the centered finite difference approximation.- Parameters:
f
- the functionx
- the x valueh
-- Returns:
- first derivatve
-
backward
Calculates the first derivative of a function using the finite difference approximation toward decreasing x.- Parameters:
f
- the functionx
- the x valueh
-- Returns:
- first derivative
-
forward
Calculates the first derivative of a function using the finite difference approximation toward increasing x.- Parameters:
f
- the functionx
- the x valueh
-- Returns:
- first derivative
-
firstPartial
Gets the partial derivate of a multivariable function using the centered finite difference approximation.- Parameters:
f
- MultiVarFunctionx
- double[] variablesn
- int indexh
- double change in the varible with index i- Returns:
- double
-
second
Computes the second derivate using the centered finite difference approximation.- Parameters:
f
- Functionx
- doubleh
- double- Returns:
- double
-