vc_plot_newton_system: Animate two-dimensional Newton system iterates and zero...

View source: R/plot_newton_system.R

vc_plot_newton_systemR Documentation

Animate two-dimensional Newton system iterates and zero contours

Description

Animate two-dimensional Newton system iterates and zero contours

Usage

vc_plot_newton_system(
  result,
  f,
  xlim = NULL,
  ylim = NULL,
  n = 81L,
  colors = c(first = "#188367", second = "#8250a3", path = "#24476b", current =
    "#c44736", rejected = "#dd8800"),
  line_width = 2,
  marker_size = 9,
  alpha = 0.45,
  show_rejected = FALSE,
  animate = TRUE,
  frame_ms = 600,
  title = NULL,
  xlab = "x",
  ylab = "y"
)

Arguments

result

Two-dimensional vc_newton_system result, including failed runs.

f

The same vector-valued function used in the calculation.

xlim, ylim

Optional finite increasing display bounds. NULL covers accepted iterates plus a margin; rejected trials do not expand the view.

n

Integer samples per coordinate axis, at least two. Zero contours are sampled independently; missed/tangential roots are possible.

colors

Named first, second, path, current and rejected colors.

line_width

Positive finite curve/path width.

marker_size

Positive finite iterate marker size.

alpha

Opacity of optional rejected-trial markers, between zero and one.

show_rejected

Logical; display finite rejected trial coordinates, labeled as rejected and not connected to the accepted iterate path.

animate

Logical; TRUE plays stored accepted iterates, FALSE shows the complete path. A run with zero updates has a static initial marker.

frame_ms

Positive animation frame duration in milliseconds.

title

Optional scalar title; default reports stored termination status.

xlab, ylab

Scalar coordinate-axis labels.

Details

Invalid samples are gaps. f is checked against stored system values at every accepted point. Contour intersections illustrate possible roots, not proofs of existence or uniqueness. Rejected-trial markers, when requested, are a static overlay of all rejections and do not imply they occurred at each playback time. Only 2D systems are drawn; the engine supports higher dimensions, whose Jacobians can use vc_plot_matrix.

Value

Plotly widget with two zero level sets and accepted Newton path. Each frame includes the current iterate, residual and accepted damping. Contour matrices have y rows and x columns. The terminal frame is included even after failure; no updates or Jacobians are recomputed for plotting.

Examples

if(requireNamespace("plotly",quietly=TRUE)) {
  f <- function(v)c(v[1]^2+v[2]^2-1,v[1]-v[2])
  f |> vc_newton_system(c(.8,.2)) |> vc_plot_newton_system(f=f)
}

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