invenia/FDM.jl

Estimate derivatives with finite differences
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
 Failed to load latest commit information. docs Oct 23, 2018 src Aug 8, 2018 test Aug 8, 2018 .codecov.yml Jan 17, 2018 .gitignore Jan 18, 2018 .travis.yml Oct 23, 2018 LICENSE Jan 17, 2018 Project.toml Oct 23, 2018 README.md Jun 20, 2018 REQUIRE Oct 23, 2018 appveyor.yml Oct 23, 2018

FDM.jl: Finite Difference Methods

FDM.jl estimates derivatives with finite differences.

Examples

Compute the first derivative of `sin` with a 5th order central method:

```julia> central_fdm(5, 1)(sin, 1) - cos(1)
-1.247890679678676e-13```

Compute the second derivative of `sin` with a 5th order central method:

```julia> central_fdm(5, 2)(sin, 1) + sin(1)
9.747314066999024e-12```

Construct a FDM on a custom grid:

```julia> method, report = fdm([-2, 0, 5], 1, report=true)
(FDM.method, FDMReport:
order of method:       3
order of derivative:   1
grid:                  [-2, 0, 5]
coefficients:          [-0.357143, 0.3, 0.0571429]
roundoff error:        2.22e-16
bounds on derivatives: 1.00e+00
step size:             3.62e-06
accuracy:              6.57e-11
)

julia> method(sin, 1) - cos(1)
-2.05648831297367e-11```

Compute a directional derivative:

```julia> f(x) = sum(x)
f (generic function with 1 method)

julia> central_fdm(5, 1)(ε -> f([1, 1, 1] + ε * [1, 2, 3]), 0) - 6
-2.922107000813412e-13```