# TaoLineSearchGetSolution
Returns the solution to the line search 
## Synopsis
```
#include "petsctaolinesearch.h" 
PetscErrorCode TaoLineSearchGetSolution(TaoLineSearch ls, Vec x, PetscReal *f, Vec g, PetscReal *steplength, TaoLineSearchConvergedReason *reason)
```
Collective


## Input Parameter

- ***ls -*** the TaoLineSearch context



## Output Parameters

- ***x -*** the new solution
- ***f -*** the objective function value at x
- ***g -*** the gradient at x
- ***steplength -*** the multiple of the step direction taken by the line search
- ***reason -*** the reason why the line search terminated



## reason will be set to one of


- ***TAOLINESEARCH_FAILED_INFORNAN -*** function evaluation gives Inf or Nan value
- ***TAOLINESEARCH_FAILED_BADPARAMETER -*** negative value set as parameter
- ***TAOLINESEARCH_FAILED_ASCENT -*** initial line search step * g is not descent direction
- ***TAOLINESEARCH_HALTED_MAXFCN -*** maximum number of function evaluation reached
- ***TAOLINESEARCH_HALTED_UPPERBOUND -*** step is at upper bound
- ***TAOLINESEARCH_HALTED_LOWERBOUND -*** step is at lower bound
- ***TAOLINESEARCH_HALTED_RTOL -*** range of uncertainty is smaller than given tolerance

- ***TAOLINESEARCH_HALTED_USER -*** user can set this reason to stop line search
- ***TAOLINESEARCH_HALTED_OTHER -*** any other reason

- ***TAOLINESEARCH_SUCCESS -*** successful line search





## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/linesearch/interface/taolinesearch.c.html#TaoLineSearchGetSolution">src/tao/linesearch/interface/taolinesearch.c</A>


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


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