vc_plot_secant_convergence: Animate stored secants approaching a numerical tangent

View source: R/secant_convergence.R

vc_plot_secant_convergenceR Documentation

Animate stored secants approaching a numerical tangent

Description

Animate stored secants approaching a numerical tangent

Usage

vc_plot_secant_convergence(
  result,
  f,
  xlim = NULL,
  n = 401L,
  colors = c(curve = "#24476b", line = "#c44736", point = "#222222", differential =
    "#188367", change = "#8250a3"),
  title = NULL,
  xlab = "x",
  ylab = "y",
  animate = TRUE,
  frame_ms = 400,
  line_width = 3
)

Arguments

result

Result from vc_secant_convergence().

f

The same deterministic scalar function used for the calculation. Function values at the stored anchor points must match the result.

xlim

Optional increasing pair of finite real plot limits, containing the anchor points. NULL derives limits around the anchors.

n

Integer number of curve samples, at least 2. The curve is a sampled visualization, not an exact representation or a continuity test.

colors

Named character vector with entries curve, line, point, differential, and change; values are Plotly/CSS colors.

title

Optional scalar plot title. NULL uses a descriptive default.

xlab, ylab

Scalar axis labels.

animate

Logical; multiple stored steps get playback/slider. FALSE displays the last step; one step is always static.

frame_ms

Positive finite frame duration in milliseconds. Transition is zero to avoid interpolating artificial intermediate secants.

line_width

Positive finite animated secant width.

Details

No secants or derivatives are recomputed. Stored endpoints are checked against f. In central mode the secant is the chord of both endpoints, correcting the legacy line-through-x0 display. The tangent remains an approximation, including at cusps or domain boundaries.

Value

Plotly widget with sampled function, numerical tangent and its diagnostic label, actual secant lines and actual endpoint pairs.

Examples

if(requireNamespace("plotly",quietly=TRUE)) {
  f <- function(x)x^2
  f |> vc_secant_convergence(1) |> vc_plot_secant_convergence(f=f)
}

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