vc_secant_convergence: Tabulate secants at decreasing steps

View source: R/secant_convergence.R

vc_secant_convergenceR Documentation

Tabulate secants at decreasing steps

Description

Tabulate secants at decreasing steps

Usage

vc_secant_convergence(
  f,
  x0,
  steps = 2^(-(1:8)),
  method = c("forward", "backward", "central"),
  h = NULL,
  atol = 1e-08,
  rtol = 1e-04
)

Arguments

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.

Details

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.

Value

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.

Examples

(function(x)x^2) |> vc_secant_convergence(x0=1)
abs |> vc_secant_convergence(x0=0,method="central")

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