Skip to main content
`Ctrl`+`K`

# SNESTestJacobian

Computes the difference between the computed and finite-difference Jacobians

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESTestJacobian(SNES snes, PetscReal *Jnorm, PetscReal *diffNorm)

Collective

## Input Parameter

- snes - the `SNES` context

## Output Parameters

- Jnorm - the Frobenius norm of the computed Jacobian, or `NULL`

- diffNorm - the Frobenius norm of the difference of the computed and finite-difference Jacobians, or `NULL`

## Options Database Keys

- -snes_test_jacobian [threshold] - compare the user provided Jacobian with one compute via finite differences to check for errors. If a threshold is given, display only those entries whose difference is greater than the threshold.

- -snes_test_jacobian_view - display the user provided Jacobian, the finite difference Jacobian and the difference

## Note

Directions and norms are printed to stdout if `diffNorm` is `NULL`.

## See Also

SNES: Nonlinear Solvers, `SNESTestFunction()`, `SNESSetJacobian()`, `SNESComputeJacobian()`

## Level

developer

## Location

src/snes/interface/snes.c

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