Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ finite_diff_grad_hessian()

template<typename F >
void stan::math::finite_diff_grad_hessian ( const F &  f,
const Eigen::VectorXd &  x,
double &  fx,
Eigen::MatrixXd &  hess,
std::vector< Eigen::MatrixXd > &  grad_hess_fx,
double  epsilon = 1e-04 
)

Calculate the value and the gradient of the hessian of the specified function at the specified argument using second-order autodiff and first-order finite difference.

The functor must implement

double operator()(const Eigen::Matrix<double, Eigen::Dynamic, 1>&)

Reference:

De Levie: An improved numerical approximation for the first derivative, page 3

4 calls to the function, f.

Template Parameters
FType of function
Parameters
[in]fFunction
[in]xArgument to function
[out]fxFunction applied to argument
[out]hessHessian matrix
[out]grad_hess_fxgradient of Hessian of function at argument
[in]epsilonperturbation size

Definition at line 41 of file finite_diff_grad_hessian.hpp.