public class Ridders extends AbstractRealScalarFunction
FiniteDifference
.
Ridders' method tries a sequence of decreasing h's to compute the derivatives,
and then extrapolate to zero using Neville's algorithm.
The choice of the initial h is critical.
If h is too big, the value computed could be inaccurate.
If h is too small, due to rounding error, we might be computing the "same" value over and over again for different h's.Function.EvaluationException
Constructor and Description |
---|
Ridders(RealScalarFunction f,
int[] varidx)
Construct the derivative function of a vector-valued function using Ridder's method.
|
Ridders(RealScalarFunction f,
int[] varidx,
double rate,
int discretization)
Construct the derivative function of a vector-valued function using Ridder's method.
|
Ridders(UnivariateRealFunction f,
int order)
Construct the derivative function of a univariate function using Ridder's method.
|
Ridders(UnivariateRealFunction f,
int order,
double rate,
int discretization)
Construct the derivative function of a univariate function using Ridder's method.
|
Modifier and Type | Method and Description |
---|---|
double |
evaluate(double x)
Evaluate f'(x), where f is a
UnivariateRealFunction . |
Double |
evaluate(Vector x)
Evaluate the function f at x, where x is from the domain.
|
double |
evaluate(Vector x,
double h)
Evaluate numerically the derivative of f at point x, f'(x), with step size h.
|
dimensionOfDomain, dimensionOfRange
public Ridders(UnivariateRealFunction f, int order, double rate, int discretization)
f
- the UnivariateRealFunction
to take derivative oforder
- the order of differentiationrate
- the rate at which the increment h decreases; rate
should be a simple number such as 0.75, not like 0.66666666666...discretization
- the number of points for extrapolationpublic Ridders(UnivariateRealFunction f, int order)
f
- the UnivariateRealFunction
to take derivative oforder
- the order of the derivativepublic Ridders(RealScalarFunction f, int[] varidx, double rate, int discretization)
varidx = new int[]{1, 2}
means
\[
f_{x_1,x_2} = {\partial^2 f \over \partial x_1 \partial x_2} = {\partial \over \partial x_2}{\partial \over \partial x_1}
\]
The indices count from 1 up to the number of variables of f,
i.e., the domain dimension of f.f
- the multivariate function to take derivative ofvaridx
- specify the variable indices, numbering from 1 up to the domain dimension of frate
- rate
should be a simple number, not like 0.66666666666...discretization
- the number of points used for extrapolationpublic Ridders(RealScalarFunction f, int[] varidx)
varidx = new int[]{1, 2}
means
\[
f_{x_1,x_2} = {\partial^2 f \over \partial x_1 \partial x_2} = {\partial \over \partial x_2}{\partial \over \partial x_1}
\]
The indices count from 1 up to the number of variables of f,
i.e., the domain dimension of f.f
- the real multivariate function to take derivative ofvaridx
- specify the variable indices, numbering from 1 up to the domain dimension of fpublic Double evaluate(Vector x)
x
- the point to evaluate the derivative of f atpublic double evaluate(double x)
UnivariateRealFunction
.x
- the point to evaluate the derivative of f atpublic double evaluate(Vector x, double h)
x
- the point to evaluate f ath
- the step sizeCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.