vc_hessian: Approximate a scalar-field Hessian with direct differences

View source: R/derivative_matrices.R

vc_hessianR Documentation

Approximate a scalar-field Hessian with direct differences

Description

Approximate a scalar-field Hessian with direct differences

Usage

vc_hessian(f, point, 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.

h

Initial positive step(s) for second differences. NULL uses pmax(1,abs(point)) times machine epsilon to the power one quarter. One step or one per coordinate is allowed. Central interior stencils are always required; no automatic boundary fallback is applied.

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

Diagonal entries reuse the accepted direct .vc_second_difference engine used by vc_taylor. Mixed entries use four rectangle corners, never numerical differentiation of approximate gradients. Actual rectangle widths are used. Initial, half and quarter steps are retained; mixed roundoff indicators are 16*epsilon*max(abs(corners))/(width_i*width_j). These and diagonal indicators are heuristics, not certified error bounds. Near-zero curvature or large offsets may give conservative failed flags. Upper-triangle estimates are mirrored by construction. Symmetry is not a test of equality/existence of ordered mixed partials or of C2 regularity. All finite checks can miss nonsmoothness or sampling aliasing. No eigenvalue classification or extremum claim is made: a Hessian alone does not locate a critical point. The rectangle formula recovers the Hessian primitive embedded in original critical_points_nd/critical_points_2d, independently of their search/classification code.

Value

Plain list with type, point, value, estimate (symmetric matrix), reliable (logical matrix), all_reliable, table (upper-triangle entries, steps, estimate, stable, resolved, reliable), results (full direct stencil diagnostics), refinements (three matrices), evaluation_count and note.

Examples

f <- function(v)v[1]^2+v[1]*v[2]+2*v[2]^2
f |> vc_hessian(c(1,1),h=.01)

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