Differentiation
Introduction
This module provides functions for numerical differentiation of univariate and multivariate functions, $R^n \to R$.
API
NumericalMethods.Deriv.differentiate — Methoddifferentiate(f::Function, x::Real; δ::Real=1.0e-6, two_side::Bool=true)Compute the derivative of f at x using a one or two-sided difference quotient.
Arguments
f::Function: The function to differentiate.x::Real: The point at which to differentiatef.δ::Real=1.0e-6: The step size to use in the difference quotient.two_side::Bool=true: Whether to use a two-sided difference quotient.
Returns
deriv: The derivative offatx.
NumericalMethods.Deriv.gradient — Methodgradient(f::Function, x::AbstractVector; δ::Real=1.0e-6)Compute the gradient of f at x using a two-sided difference quotient.
Arguments
f::Function: The function to differentiate.x::AbstractVector: The point at which to differentiatef.δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
grad::Vector: The gradient offatx.
NumericalMethods.Deriv.hessian — Methodhessian(f::Function, x::AbstractVector; δ::Real=1.0e-6)Compute the Hessian of f at x using a two-sided difference quotient.
Arguments
f::Function: The function to differentiate.x::AbstractVector: The point at which to differentiatef.δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
hess::Matrix: The Hessian offatx.
NumericalMethods.Deriv.partial — Methodpartial(f::Function, x::AbstractVector, i::Integer; δ::Real=1.0e-6)Compute the partial derivative of f at x with respect to the ith component of x using a two-sided difference quotient.
Arguments
f::Function: The function to differentiate.x::AbstractVector: The point at which to differentiatef.i::Integer: The index of the component ofxwith respect to which to differentiatef.δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
deriv: The partial derivative offatxwith respect to theith component ofx.
NumericalMethods.Deriv.twice_differentiate — Methodtwice_differentiate(f::Function, x::Real; δ::Real=1.0e-6)Compute the second derivative of f at x using a two-sided difference quotient.
Arguments
f::Function: The function to differentiate.x::Real: The point at which to differentiatef.δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
deriv: The second derivative offatx.