TaoTestGradient — PETSc 3.25.4 documentation

Skip to main content
`Ctrl`+`K`

# TaoTestGradient

Compare the user-supplied gradient with a finite-difference approximation, when requested via the options database, and print the difference.

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoTestGradient(Tao tao, Vec x, Vec g1)

Collective

## Input Parameters

- tao - the `Tao` context

- x - the point at which to evaluate the gradient

- g1 - the user-supplied gradient at `x`

## Options Database Keys

- -tao_test_gradient - enable the comparison

- -tao_test_gradient_view - display the user-supplied gradient, the finite-difference gradient, and their difference

## Note

If `-tao_test_gradient` is not set, this routine returns immediately without performing any work.

## See Also

TAO: Optimization Solvers, `Tao`, `TaoTestHessian()`, `TaoComputeGradient()`

## Level

intermediate

## Location

src/tao/interface/taosolver_fg.c

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