View source: R/derivative_matrices.R
| vc_hessian | R Documentation |
Approximate a scalar-field Hessian with direct differences
vc_hessian(f, point, h = NULL, atol = 1e-08, rtol = 1e-04, warn = TRUE)
f |
Deterministic scalar field accepting ONE numeric vector and returning
one finite real scalar. For f(x,y), supply an explicit wrapper
|
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
|
atol |
Nonnegative finite absolute tolerance for sensitivity comparisons. |
rtol |
Nonnegative finite relative tolerance for sensitivity comparisons. |
warn |
Logical scalar; warn when sensitivity diagnostics fail. |
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.
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.
f <- function(v)v[1]^2+v[1]*v[2]+2*v[2]^2
f |> vc_hessian(c(1,1),h=.01)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.