Legend:
Library
Module
Module type
Parameter
Class
Class type
Numerical differentiation module This module provides APIs for performing numerical differentiation of any user defined functions. The module is part of Algodiff module, and only supports float numbers at the moment.
Numerical differentiation is subject to truncation error and round-off error. If you need more precise results, please consider to use Algodiff.AD module for algorithmic differentiation.
diff f x returns the numrical derivative of a function f : float -> float at point x. Simply calling diff f will return its derivative function g of the same type, i.e. g : float -> float.
Keep calling this function will give you higher-order derivatives of f, i.e. f |> diff |> diff |> diff |> .... However, the error grows quickly due to the numerical method of differentiation.
val diff2 : (float -> float)->float -> float
diff2 f x returns second-order derivative of f : float -> float at x.
grad f x returns the gradient of f at point x. Note the type of the function is f : mat -> float, i.e. f takes an one-row matrix as input and outputs a float scalar. An exception will be raised if the passed in paramter is not an one-row matrix.
jacobian f x returns the jacobian of f at point x. Again, the mat type here refers to one-row matrix. I am still thinking maybe it is necessary to introduce vector as a separate type in Owl? Currently, the returned result uses numerator-layout. I.e., if x is n-dimensional and f x is y-dimensional, then the returned jacobian is an m x n matrix.