TaoTermComputeGradientFD — PETSc 3.25.2 documentation

Skip to main content
`Ctrl`+`K`

# TaoTermComputeGradientFD

Approximate the gradient of a `TaoTerm` using finite differences

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoTermComputeGradientFD(TaoTerm term, Vec x, Vec params, Vec g)

Collective

## Input Parameters

- term - a `TaoTerm`

- x - a solution vector

- params - parameters vector (may be `NULL`, see `TaoTermParametersMode`)

## Output Parameter

- g - the computed finite difference approximation to the gradient

## Options Database Keys

- -tao_term_fd_delta - change in `x` used to calculate finite differences

- -tao_term_gradient_use_fd - Use `TaoTermComputeGradientFD()` in `TaoTermComputeGradient()`

## Notes

This routine is slow and expensive, and is not optimized to take advantage of sparsity in the problem. Although not recommended for general use in large-scale applications, it can be useful in checking the correctness of a user-provided gradient. Call `TaoTermComputeGradientSetUseFD()` to start using this routine in `TaoTermComputeGradient()`.

## See Also

TaoTerm: composable objective function terms, `TaoTerm`, `TaoTermGetFDDelta()`, `TaoTermSetFDDelta()`, `TaoTermComputeGradientSetUseFD()`, `TaoTermComputeGradientGetUseFD()`, `TaoTermComputeHessianFD()`

## Level

advanced

## Location

src/tao/term/utils/taotermfdiff.c

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