| vc_plot_newton | R Documentation |
Plot Newton iterations, tangents and numerical residuals
vc_plot_newton(
result,
f,
xlim = NULL,
n = 401L,
animate = TRUE,
frame_ms = 500,
colors = c(curve = "#24476b", line = "#c44736", point = "#188367", diagnostic =
"#8250a3"),
title = NULL,
xlab = "x",
ylab = "f(x)"
)
result |
Result from vc_critical_points(), vc_concavity() or vc_newton(), matching the selected plot function. |
f |
The same deterministic scalar function used for the calculation. Function values at the stored anchor points must match the result. |
xlim |
Finite increasing plot bounds. NULL uses the stored search interval, or the accepted Newton iterates with padding. |
n |
Integer number of curve samples, at least 2. The curve is a sampled visualization, not an exact representation or a continuity test. |
animate |
Logical; animate computed tangent updates when at least two computed outgoing steps exist. Initial-root, single-step and failed-before-step results remain static; no next iterate is fabricated. |
frame_ms |
Positive finite frame duration in milliseconds. |
colors |
Named vector with curve, line, point and diagnostic colors. |
title |
Optional scalar plot title. NULL uses a descriptive default. |
xlab, ylab |
Scalar axis labels. |
Tangent segments join the current function point to its actual computed Newton x-intercept. Final points without a computed outgoing step have no tangent-update frame. Hover and title include residual/status; numerical convergence does not guarantee a mathematical root.
Interactive plotly widget with iteration geometry and residual history. Play/pause and a frame slider are available for multiple steps.
if (requireNamespace("plotly",quietly=TRUE)) {
f <- function(x) x^2-2
f |> vc_newton(1) |> vc_plot_newton(f=f)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.