:orphan:
# SNESSetComputeInitialGuess
Sets a routine used to compute an initial guess for the nonlinear problem 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetComputeInitialGuess(SNES snes, PetscErrorCode (*func)(SNES, Vec, void *), void *ctx)
```
Logically Collective


## Input Parameters

- ***snes -*** the `SNES` context
- ***func -*** function evaluation routine
- ***ctx -*** [optional] user-defined context for private data for the
function evaluation routine (may be `NULL`)



## Calling sequence of `func`
```none
PetscErrorCode func(SNES snes, Vec x, void *ctx);
```

- ***snes -*** the `SNES` solver
- ***x -*** vector to put initial guess
- ***ctx -*** optional user-defined function context





## See Also
 [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetFunction()`, `SNESComputeFunction()`, `SNESSetJacobian()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snes.c.html#SNESSetComputeInitialGuess">src/snes/interface/snes.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex18.c.html">src/snes/tutorials/ex18.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex48.c.html">src/snes/tutorials/ex48.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex58.c.html">src/snes/tutorials/ex58.c</A><BR>


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


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