Skip to main content
`Ctrl`+`K`

# TaoComputeHessian

Computes the Hessian matrix that has been set with `TaoSetHessian()`.

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoComputeHessian(Tao tao, Vec X, Mat H, Mat Hpre)

Collective

## Input Parameters

- tao - the Tao solver context

- X - input vector

## Output Parameters

- H - Hessian matrix

- Hpre - matrix used to construct the preconditioner, usually the same as `H`

## Options Database Keys

- -tao_test_hessian - compare the user provided Hessian with one compute via finite differences to check for errors

- -tao_test_hessian numerical value - display entries in the difference between the user provided Hessian and finite difference Hessian that are greater than a certain value to help users detect errors

- -tao_test_hessian_view - display the user provided Hessian, the finite difference Hessian and the difference between them to help users detect the location of errors in the user provided Hessian

## Notes

Most users should not need to explicitly call this routine, as it is used internally within the minimization solvers.

`TaoComputeHessian()` is typically used within optimization algorithms, so most users would not generally call this routine themselves.

## Developer Notes

The Hessian test mechanism follows `SNESTestJacobian()`.

If there is no separate preconditioning matrix, `TaoComputeHessian(tao, X, H, NULL)` and `TaoComputeHessian(tao, X, H, H)` are equivalent.

## See Also

TAO: Optimization Solvers, `Tao`, `TaoComputeObjective()`, `TaoComputeObjectiveAndGradient()`, `TaoSetHessian()`

## Level

developer

## Location

src/tao/interface/taosolver_hj.c

Index of all Tao routines
Table of Contents for all manual pages
Index of all manual pages