total_differential_nd: Total differential of a scalar field in R^n
Description
Computes the gradient of a scalar field f(x) at a point x0
using central finite differences. It also returns the total differential,
understood as the linear map v -> grad f(x0) %*% v.
Usage
total_differential_nd(f, x0, h = NULL)
Value
A list with components:
point: the numeric vector x0,
value: the numeric value f(x0),
gradient: numeric vector with the gradient at x0,
differential: a function d(v) that returns
sum(gradient * v).
Arguments
f
Function of one argument x (numeric vector) returning a
numeric scalar.
x0
Numeric vector giving the evaluation point.
h
Step size for finite differences. Can be NULL (automatic),
a scalar, or a vector of the same length as x0.
Details
The function f must take a single numeric vector x and
return a single numeric value.