petsc-3.7.1 2016-05-15
Report Typos and Errors

# SNESComputeJacobianDefault

Computes the Jacobian using finite differences.

### Synopsis

    #include "petscsnes.h"
    PetscErrorCode  SNESComputeJacobianDefault(SNES snes,Vec x1,Mat J,Mat B,void *ctx)

Collective on SNES Many br

### Input Parameters

| x1 | - compute Jacobian at this point Many br
| ctx | - application's function context, as set with SNESSetFunction() Many br

### Output Parameters

| J | - Jacobian matrix (not altered in this routine) Many br
| B | - newly computed Jacobian matrix to use with preconditioner (generally the same as J) Many br

### Options Database Key

| -snes_fd | - Activates SNESComputeJacobianDefault() Many br
| -snes_test_err | - Square root of function error tolerance, default square root of machine Many brepsilon (1.e-8 in double, 3.e-4 in single) Many br
| -mat_fd_type | - Either wp or ds (see MATMFFD_WP or MATMFFD_DS) Many br

### Notes

This routine is slow and expensive, and is not currently optimized Many brto take advantage of sparsity in the problem. Although Many brSNESComputeJacobianDefault() is not recommended for general use Many brin large-scale applications, It can be useful in checking the Many brcorrectness of a user-provided Jacobian. Many br

An alternative routine that uses coloring to exploit matrix sparsity is Many brSNESComputeJacobianDefaultColor(). Many br

Many br

### Keywords

SNES, finite differences, Jacobian

### See Also

SNESSetJacobian(), SNESComputeJacobianDefaultColor(), MatCreateSNESMF()

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

### Examples

src/ts/examples/tutorials/ex4.c.html
src/ts/examples/tutorials/ex10.c.html
src/ts/examples/tutorials/ex15.c.html
src/ts/examples/tutorials/ex17.c.html