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 off
atx
.
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 off
atx
.
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 off
atx
.
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 i
th 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 ofx
with respect to which to differentiatef
.δ::Real=1.0e-6
: The step size to use in the difference quotient.
Returns
deriv
: The partial derivative off
atx
with respect to thei
th 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 off
atx
.