vc_plot_taylor: Compare a function and its numerical Taylor polynomial...

View source: R/plot_taylor.R

vc_plot_taylorR Documentation

Compare a function and its numerical Taylor polynomial interactively

Description

Show the sampled function and polynomial above a signed/absolute error panel. Hover reports distance from the expansion point; zoom, pan and the horizontal range slider explore behavior away from that point.

Usage

vc_plot_taylor(
  result,
  f,
  xlim = NULL,
  n = 401L,
  colors = c(curve = "#24476b", polynomial = "#c44736", error = "#188367", point =
    "#222222"),
  title = NULL,
  xlab = "x",
  ylab = "y"
)

Arguments

result

Plain result from vc_taylor().

f

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

xlim

Optional increasing finite pair containing the expansion point. NULL uses the range of result$comparison$x together with x0, padded by ten percent; without a nonzero comparison range it uses x0 +/- 1.

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 curve, polynomial, error and point entries specifying Plotly/CSS colors.

title

Optional scalar plot title. NULL uses a descriptive default.

xlab, ylab

Scalar axis labels.

Details

Error means the sampled difference f(x)-P(x), not a rigorous Taylor remainder bound. Undefined/erroring/nonfinite function samples create gaps and NA errors. Warnings during sampling are suppressed. Polynomial overflow also creates gaps; at least one polynomial sample must be finite. A grid can miss singularities or oscillations. The subtitle displays diagnostic status and the number of evaluable errors.

Value

A plotly htmlwidget with function, polynomial, expansion point, signed error and absolute error traces. Derivatives are not recalculated.

Examples

if (requireNamespace("plotly", quietly = TRUE)) {
  exp |> vc_taylor(x0 = 0, x = seq(-1,1,length.out=21)) |>
    vc_plot_taylor(f = exp)
}

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