# TSGetCostGradients
Returns the gradients from the `TSAdjointSolve()` 
## Synopsis
```
#include "petscts.h"  
PetscErrorCode TSGetCostGradients(TS ts, PetscInt *numcost, Vec **lambda, Vec **mu)
```
Not Collective, but the vectors returned are parallel if `TS` is parallel


## Input Parameter

- ***ts -*** the `TS` context obtained from `TSCreate()`



## Output Parameters

- ***numcost -*** size of returned arrays
- ***lambda -*** vectors containing the gradients of the cost functions with respect to the ODE/DAE solution variables
- ***mu -*** vectors containing the gradients of the cost functions with respect to the problem parameters





## See Also
 [](chapter_ts), `TS`, `TSAdjointSolve()`, `TSSetCostGradients()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/interface/sensitivity/tssen.c.html#TSGetCostGradients">src/ts/interface/sensitivity/tssen.c</A>


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


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