# SNESSetFunction

Sets the function evaluation routine and function vector for use by the SNES routines in solving systems of nonlinear equations.

### Synopsis

    #include "petscsnes.h"
    PetscErrorCode PETSCSNES_DLLEXPORT SNESSetFunction(SNES snes,Vec r,PetscErrorCode (*func)(SNES,Vec,Vec,void*),void *ctx)

Collective on SNES

### Input Parameters

| snes | - the SNES context
| r | - vector to store function value
| func | - function evaluation routine
| ctx | - [optional] user-defined context for private data for the function evaluation routine (may be PETSC_NULL)

### Calling sequence of func

       func (SNES snes,Vec x,Vec f,void *ctx);

f -function vector
ctx -optional user-defined function context

### Notes

The Newton-like methods typically solve linear systems of the form

         f'(x) x = -f(x),

where f'(x) denotes the Jacobian matrix and f(x) is the function.

### Keywords

SNES, nonlinear, set, function

### See Also

SNESGetFunction(), SNESComputeFunction(), SNESSetJacobian()

Level:beginner
Location:src/snes/interface/snes.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex1.c.html
src/snes/examples/tutorials/ex2.c.html
src/snes/examples/tutorials/ex3.c.html
src/snes/examples/tutorials/ex5.c.html
src/snes/examples/tutorials/ex5s.c.html
src/snes/examples/tutorials/ex6.c.html
src/snes/examples/tutorials/ex14.c.html
src/snes/examples/tutorials/ex21.c.html
src/snes/examples/tutorials/ex26.c.html
src/snes/examples/tutorials/ex1f.F.html
src/snes/examples/tutorials/ex5f.F.html