vc_gradient: Approximate the gradient of a scalar field

View source: R/multivariable.R

vc_gradientR Documentation

Approximate the gradient of a scalar field

Description

Approximate the gradient of a scalar field

Usage

vc_gradient(
  f,
  point,
  method = "central",
  h = NULL,
  atol = 1e-08,
  rtol = 1e-04,
  warn = TRUE
)

Arguments

f

Deterministic scalar field accepting ONE numeric vector and returning one finite real scalar. For f(x,y), supply an explicit wrapper function(v)f(v[1],v[2]); no automatic signature guessing is performed.

point

Nonempty finite real coordinate vector. Optional names must be unique and nonempty and are passed to f.

method

One difference method, or one per coordinate. Explicit one-sided methods can be used at known coordinate-domain boundaries.

h

NULL for per-coordinate vc_derivative heuristics, one positive finite step for all coordinates, or a positive finite vector of that dimension. No recycling of shorter vectors is allowed.

atol

Nonnegative finite absolute tolerance for sensitivity comparisons.

rtol

Nonnegative finite relative tolerance for sensitivity comparisons.

warn

Logical scalar; warn when sensitivity diagnostics fail.

Details

Reuses vc_partial(), which reuses the accepted one-variable engine. A reliable flag means only that its finite coordinate checks passed. Even all existing coordinate partials do not imply total differentiability or justify computing every directional derivative by a dot product. The engine's conservative side checks may fail at smooth stationary points.

Value

Plain list with type, point, value, estimate (named vector), results (full partial results), table (coordinate, label, method, h, estimate, reliable), reliable (all coordinate checks), and note.

Examples

(function(v)v[1]^2+2*v[2]^2) |> vc_gradient(c(x=1,y=2))

vectorialcalculus documentation built on Nov. 17, 2026, 1:09 a.m.