33.1. Finite Differences

Finite differences approximations can be used to compute the gradient and the Hessian of an objective function. These approximations will slow down the solve considerably and are only recommended for checking the accuracy of hand-coded gradients and Hessians. These routines are


  TaoAppDefaultComputeGradient(TAO_APPLICATION, Vec, Vec, void*); 
,


   TaoAppDefaultComputeHessian( TAO_APPLICATION, Vec, Mat*, Mat*,  
                                MatStructure*, void*); 
and
   TaoAppDefaultComputeHessianColor( TAO_APPLICATION, Vec, Mat*, Mat*,  
                                      MatStructure*, void* ); 
These routines can be set using TaoAppSetGradientRoutine() and TaoAppSetHessianRoutine() or through the options database. If finite differencing is used with coloring, the routine
   TaoAppSetColoring(TAO_APPLICATION, ISColoring); 
should be used to specify the coloring.

It is also possible to use finite difference approximations to directly check the correctness of an application's gradient and/or Hessian evaluation routines. This can be done using the special TAO solver tao_fd_test together with the options -tao_test_gradient or -tao_test_hessian.