# 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 on tao


## Input Parameters

- ***tao -*** the Tao solver context
- ***X   -*** input vector



## Output Parameters

- ***H    -*** Hessian matrix
- ***Hpre -*** Preconditioning matrix



## 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 Note
The Hessian test mechanism follows `SNESTestJacobian()`.




## See Also
 `Tao`, `TaoComputeObjective()`, `TaoComputeObjectiveAndGradient()`, `TaoSetHessian()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/interface/taosolver_hj.c.html#TaoComputeHessian">src/tao/interface/taosolver_hj.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/tao/interface/taosolver_hj.c)


[Index of all Tao routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
