1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use Float;
use Fn;
/// Finite difference types for derivative approximation
///
/// Enum type that is used in the solvers to determine what type of finite difference to use.
/// Central difference
///
/// Given the closure `F(T) -> T` where `T` is a floating number, a value `x`, and the step length h, approximate the derivative of `F` at `x` using `(f(x+h) - f(x-h))/(2h)`. This has the Order of Accuracy 2.
/// Forward difference
///
/// Given the closure `F(T) -> T` where `T` is a floating number, a value `x`, and the step length h, approximate the derivative of `F` at `x` using `(f(x+h) - f(x))/h`. This has the Order of Accuracy 1.
/// Backward difference
///
/// Given the closure `F(T) -> T` where `T` is a floating number, a value `x`, and the step length h, approximate the derivative of `F` at `x` using `(f(x) - f(x-h))/h`. This has the Order of Accuracy 1.