# TaoSetHessian
Sets the function to compute the Hessian as well as the location to store the matrix. 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoSetHessian(Tao tao, Mat H, Mat Hpre, PetscErrorCode (*func)(Tao, Vec, Mat, Mat, void *), void *ctx)
```
Logically collective


## Input Parameters

- ***tao  -*** the Tao context
- ***H    -*** Matrix used for the hessian
- ***Hpre -*** Matrix that will be used operated on by preconditioner, can be same as H
- ***func -*** Hessian evaluation routine
- ***ctx  -*** [optional] user-defined context for private data for the
Hessian evaluation routine (may be NULL)



## Calling sequence of func
```none
func(Tao tao,Vec x,Mat H,Mat Hpre,void *ctx);
```


- ***tao  -*** the Tao  context
- ***x    -*** input vector
- ***H    -*** Hessian matrix
- ***Hpre -*** preconditioner matrix, usually the same as H
- ***ctx  -*** [optional] user-defined Hessian context





## See Also
 `Tao`, `TaoTypes`, `TaoSetObjective()`, `TaoSetGradient()`, `TaoSetObjectiveAndGradient()`, `TaoGetHessian()`

## Level
beginner

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex20opt_ic.c.html">src/ts/tutorials/ex20opt_ic.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex20opt_p.c.html">src/ts/tutorials/ex20opt_p.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion1.c.html">src/tao/unconstrained/tutorials/eptorsion1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2.c.html">src/tao/unconstrained/tutorials/eptorsion2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2f.F90.html">src/tao/unconstrained/tutorials/eptorsion2f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion3.c.html">src/tao/unconstrained/tutorials/eptorsion3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf1.c.html">src/tao/unconstrained/tutorials/minsurf1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf2.c.html">src/tao/unconstrained/tutorials/minsurf2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock1.c.html">src/tao/unconstrained/tutorials/rosenbrock1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock1f.F90.html">src/tao/unconstrained/tutorials/rosenbrock1f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock2.c.html">src/tao/unconstrained/tutorials/rosenbrock2.c.html</A><BR>


---
[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)  
