# MatMFFDSetFunctionError
Sets the error_rel for the approximation of matrix-vector products using finite differences with the `MATMFFD` matrix 
## Synopsis
```
#include "petscmat.h"   
PetscErrorCode MatMFFDSetFunctionError(Mat mat, PetscReal error)
```
Logically Collective


## Input Parameters

- ***mat -*** the `MATMFFD` matrix free matrix
- ***error_rel -*** relative error (should be set to the square root of the relative error in the function evaluations)



## Options Database Keys

- ***-mat_mffd_err <error_rel> -*** Sets error_rel





## Note
The default matrix-free matrix-vector product routine computes
```none
     F'(u)*a = [F(u+h*a) - F(u)]/h where
     h = error_rel*u'a/||a||^2                        if  |u'a| > umin*||a||_{1}
       = error_rel*umin*sign(u'a)*||a||_{1}/||a||^2   else
```



## See Also
 `MATMFFD`, `MatCreateSNESMF()`, `MatMFFDGetH()`, `MatCreateMFFD()`, `MATMFFD`
`MatMFFDSetHHistory()`, `MatMFFDResetHHistory()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/mffd/mffd.c.html#MatMFFDSetFunctionError">src/mat/impls/mffd/mffd.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/mffd/mffd.c.html#MatMFFDSetFunctionError_MFFD">MatMFFDSetFunctionError_MFFD in src/mat/impls/mffd/mffd.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/mffd/mffd.c)


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