vc_secant: Compute the secant through two points of a real function

View source: R/local_models.R

vc_secantR Documentation

Compute the secant through two points of a real function

Description

Compute the finite slope (f(x1)-f(x0))/(x1-x0). This is a secant slope, not a derivative or evidence of differentiability.

Usage

vc_secant(f, x0, x1)

Arguments

f

Deterministic function accepting a real scalar and returning one finite real scalar. Vectorization is not required.

x0

Finite real scalar giving the first abscissa.

x1

Finite real scalar giving a distinct second abscissa.

Details

Both function values, the displacement, the ordinate difference, and the quotient must be finite. Reversing the endpoints preserves the slope. No smoothness assumption is needed. Floating-point cancellation can affect the result; this operation does not estimate numerical error.

Value

Plain list with type ("secant"), x0, y0, x1, y1, dx, dy, slope, and note. The line is y0 + slope * (x - x0). No intercept is computed, avoiding unnecessary cancellation in an intercept representation.

Examples

vc_secant(function(x) x^2, 1, 2)
sin |> vc_secant(x0 = 0, x1 = 0.1)

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