FDM.assert_approx_equalMethod
assert_approx_equal(x, y, ε_abs, ε_rel[, desc])

Assert that x is approximately equal to y.

Let eps_z = eps_abs / eps_rel. Call x and y small if abs(x) < eps_z and abs(y) < eps_z, and call x and y large otherwise. If this function returns True, then it is guaranteed that abs(x - y) < 2 eps_rel max(abs(x), abs(y)) if x and y are large, and abs(x - y) < 2 eps_abs if x and y are small.

Arguments

• x: First object to compare.
• y: Second object to compare.
• ε_abs: Absolute tolerance.
• ε_rel: Relative tolerance.
• desc: Description of the comparison. Omit or set to false to have no description.
FDM.backward_fdmFunction
FDM.Backward(p, q; kwargs...)
backward_fdm(p, q; kwargs...)

Construct a backward finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.central_fdmFunction
FDM.Central(p, q; kwargs...)
central_fdm(p, q; kwargs...)

Construct a central finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.fdmMethod
fdm(m::FDMethod, f, x[, Val(false)]; kwargs...) -> Real
fdm(m::FDMethod, f, x, Val(true); kwargs...) -> Tuple{FDMethod, Real}

Compute the derivative of f at x using the finite differencing method m. The optional Val argument dictates whether the method should be returned alongside the derivative value, which can be useful for examining the step size used and other such parameters.

The recognized keywords are:

• adapt: The number of adaptive steps to use improve the estimate of bound.
• bound: Bound on the value of the function and its derivatives at x.
• condition: The condition number. See DEFAULT_CONDITION.
• eps: The assumed roundoff error. Defaults to eps() plus TINY.
Warning

Bounds can't be adaptively computed over nonstandard grids; passing a value for adapt greater than 0 when m::Nonstandard results in an error.

Note

Calling FDMethod objects is equivalent to passing them to fdm.

Examples

julia> fdm(central_fdm(5, 1), sin, 1; adapt=2)
0.5403023058681039

julia> fdm(central_fdm(2, 1), exp, 0, Val(true))
(FDMethod:
order of method:       2
order of derivative:   1
grid:                  [-1, 1]
coefficients:          [-0.5, 0.5]
roundoff error:        1.42e-14
bounds on derivatives: 1.00e+02
step size:             1.69e-08
accuracy:              1.69e-06
, 1.0000000031817473)
FDM.forward_fdmFunction
FDM.Forward(p, q; kwargs...)
forward_fdm(p, q; kwargs...)

Construct a forward finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.TINYConstant
FDM.TINY

A tiny number added to some quantities to ensure that division by 0 does not occur.

FDM.BackwardType
FDM.Backward(p, q; kwargs...)
backward_fdm(p, q; kwargs...)

Construct a backward finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.CentralType
FDM.Central(p, q; kwargs...)
central_fdm(p, q; kwargs...)

Construct a central finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.FDMethodType
FDMethod

Abstract type for all finite differencing method types. Subtypes of FDMethod are callable with the signature

method(f, x; kwargs...)

where the keyword arguments can be any of

• adapt: The number of adaptive steps to use improve the estimate of bound.
• bound: Bound on the value of the function and its derivatives at x.
• condition: The condition number. See DEFAULT_CONDITION.
• eps: The assumed roundoff error. Defaults to eps() plus TINY.
FDM.ForwardType
FDM.Forward(p, q; kwargs...)
forward_fdm(p, q; kwargs...)

Construct a forward finite difference method of order p to compute the qth derivative. See FDMethod for more details.

FDM.HistoryType
History

A mutable type that tracks several values during adaptive bound computation.

FDM.NonstandardMethod
FDM.Nonstandard(grid, q; kwargs...)

An finite differencing method which is constructed based on a user-defined grid. It is nonstandard in the sense that it represents neither forward, backward, nor central differencing. See FDMethod for further details.

FDM._jvpMethod
_jvp(fdm, f, x::Vector{<:Real}, ẋ::AbstractVector{<:Real})

Convenience function to compute jacobian(f, x) * ẋ.

FDM._j′vpMethod
_j′vp(fdm, f, ȳ::AbstractVector{<:Real}, x::Vector{<:Real})

Convenience function to compute jacobian(f, x)' * ȳ.

FDM.gradMethod
grad(fdm, f, x::AbstractVector)

Approximate the gradient of f at x using fdm. Assumes that f(x) is scalar.

FDM.jacobianMethod
jacobian(fdm, f, x::AbstractVector{<:Real}, D::Int)
jacobian(fdm, f, x::AbstractVector{<:Real})

Approximate the Jacobian of f at x using fdm. f(x) must be a length D vector. If D is not provided, then f(x) is computed once to determine the output size.

FDM.jvpMethod
jvp(fdm, f, x, ẋ)

Compute a Jacobian-vector product with any types of arguments for which to_vec is defined.

FDM.j′vpMethod
j′vp(fdm, f, ȳ, x...)

Compute an adjoint with any types of arguments for which to_vec is defined.

FDM.to_vecMethod
to_vec(x)

Transform x into a Vector, and return a closure which inverts the transformation.