# TaoComputeObjectiveAndGradient
Computes the objective function value at a given point 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoComputeObjectiveAndGradient(Tao tao, Vec X, PetscReal *f, Vec G)
```
Collective


## Input Parameters

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



## Output Parameters

- ***f -*** Objective value at X
- ***g -*** Gradient vector at X



## Note
`TaoComputeObjectiveAndGradient()` is typically used within the implementation of the optimization algorithm,
so most users would not generally call this routine themselves.




## See Also
 `TaoComputeGradient()`, `TaoComputeObjectiveAndGradient()`, `TaoSetObjective()`

## Level
developer

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


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/tao/interface/taosolver_fg.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)  
