Skip to main content
`Ctrl`+`K`

# SNESComputeFunction

Calls the function that has been set with `SNESSetFunction()`.

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESComputeFunction(SNES snes, Vec x, Vec f)

Collective

## Input Parameters

- snes - the `SNES` context

- x - input vector

## Output Parameter

- f - function vector, as set by `SNESSetFunction()`

## Notes

`SNESComputeFunction()` is typically used within nonlinear solvers implementations, so users would not generally call this routine themselves.

When solving for \(F(x) = b\), this routine computes \(f = F(x) - b\).

This function usually appears in the pattern.

      SNESComputeFunction(snes, x, f);
      VecNorm(f, &fnorm);
      SNESCheckFunctionDomainError(snes, fnorm); or SNESLineSearchCheckFunctionDomainError(ls, fnorm);

to collectively handle the use of `SNESSetFunctionDomainError()` in the provided callback function.

## See Also

SNES: Nonlinear Solvers, `SNES`, `SNESSetFunction()`, `SNESGetFunction()`, `SNESComputeMFFunction()`, `SNESSetFunctionDomainError()`

## Level

developer

## Location

src/snes/interface/snes.c

## Examples

src/snes/tutorials/ex1f.F90
src/snes/tutorials/ex12.c
src/snes/tutorials/ex77.c
src/snes/tutorials/ex73f90t.F90

Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages