# TaoAppDefaultComputeHessian

Computes the Hessian using finite differences.

## Synopsis

    #include "tao.h"
    int TaoAppDefaultComputeHessian(TAO_APPLICATION taoapp,Vec V,Mat *H,Mat *B,
                               MatStructure *flag,void *ctx)

Collective on TAO_APPLICATION

## Input Parameters

| taoapp | - the TAO_APPLICATION context
| V | - compute Hessian at this point
| ctx | - the TAO_APPLICATION structure, cast to (void*)

## Output Parameters

| H | - Hessian matrix (not altered in this routine)
| B | - newly computed Hessian matrix to use with preconditioner (generally the same as H)
| flag | - flag indicating whether the matrix sparsity structure has changed

## Options Database Key

| -tao_fd | - Activates TaoAppDefaultComputeHessian()
| -tao_view_hessian | - view the hessian after each evaluation using PETSC_VIEWER_STDOUT_WORLD

## Notes

This routine is slow and expensive, and is not currently optimized to take advantage of sparsity in the problem. Although TaoAppDefaultComputeHessian() is not recommended for general use in large-scale applications, It can be useful in checking the correctness of a user-provided Hessian.

## Note

The gradient evaluation must be set using the routine TaoAppSetGradientRoutine().

## Keywords

TAO_APPLICATION, finite differences, Hessian

## See Also

TaoAppSetHessianRoutine(), TaoAppDefaultComputeHessianColor(), SNESDefaultComputeJacobian(),
TaoAppSetGradientRoutine()

Level:intermediate
Location:src/petsctao/application/petscapp/fdiff.c
TAO Solver Index
Table of Contents

### Examples

src/unconstrained/examples/tutorials/minsurf2.c.html