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 differentiate- f.
- δ::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 of- fat- x.
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 differentiate- f.
- δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
- grad::Vector: The gradient of- fat- x.
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 differentiate- f.
- δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
- hess::Matrix: The Hessian of- fat- x.
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 differentiate- f.
- i::Integer: The index of the component of- xwith respect to which to differentiate- f.
- δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
- deriv: The partial derivative of- fat- xwith respect to the- ith component of- x.
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 differentiate- f.
- δ::Real=1.0e-6: The step size to use in the difference quotient.
Returns
- deriv: The second derivative of- fat- x.