View source: R/secant_convergence.R
| vc_secant_convergence | R Documentation |
Tabulate secants at decreasing steps
vc_secant_convergence(
f,
x0,
steps = 2^(-(1:8)),
method = c("forward", "backward", "central"),
h = NULL,
atol = 1e-08,
rtol = 1e-04
)
f |
Deterministic function accepting a real scalar and returning one finite real scalar. Vectorization is not required. |
x0 |
Finite real scalar evaluation point of the local model. |
steps |
Nonempty strictly decreasing positive finite real step vector. A single step is allowed. Steps are not silently sorted or deduplicated. |
method |
One of "central", "forward", or "backward". |
h |
Positive finite real initial derivative step, or NULL for the heuristic used by vc_derivative(), evaluated with x = x0. |
atol |
Nonnegative finite absolute tolerance for sensitivity comparisons. |
rtol |
Nonnegative finite relative tolerance for sensitivity comparisons. |
Recovers the decreasing-step procedure of legacy secant_tangent. Forward/backward secants join x0 to x0 plus/minus each step. Central secants join x0-step and x0+step: their lines pass through both endpoints, not generally through (x0,f(x0)). Reuses vc_secant and vc_tangent without changing their algorithms. Collapsed/nonfinite endpoints are errors. Numerical sequences and apparent agreement do not prove differentiability or convergence. Failed tangent diagnostics are retained without warnings.
Plain list with type, x0, y0, method, steps, results (vc_secant objects), tangent (vc_tangent with full derivative diagnostics), table (step, left, right, slope, slope_difference), and note. slope_difference compares with a numerical tangent slope, not an exact derivative error.
(function(x)x^2) |> vc_secant_convergence(x0=1)
abs |> vc_secant_convergence(x0=0,method="central")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.