vc_area: Compute geometric area between two graphs

View source: R/applications.R

vc_areaR Documentation

Compute geometric area between two graphs

Description

Compute geometric area between two graphs

Usage

vc_area(
  f,
  interval,
  g = NULL,
  breaks = NULL,
  method = c("adaptive", "trapezoid", "simpson"),
  n = 32L,
  abs_tol = 1e-08,
  rel_tol = 1e-08,
  subdivisions = 100L
)

Arguments

f

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

interval

Two finite real bounds, allowing reversed or equal bounds.

g

Second scalar boundary function; NULL means zero.

breaks

Optional finite strictly increasing interior integration split points, for example known intersections. These are not found automatically.

method

Quadrature rule: trapezoid, Simpson, or adaptive QUADPACK through stats::integrate(). Improper infinite bounds are not supported.

n

Initial number of equal cells for fixed rules; positive integer, even and at least two for Simpson. Ignored by the adaptive rule.

abs_tol, rel_tol

Nonnegative finite absolute and relative diagnostic tolerances; at least one must be positive. Adaptive integration also applies the tolerance restrictions of stats::integrate().

subdivisions

Positive integer maximum adaptive subinterval count; ignored by fixed rules.

Details

Integrates abs(f-g), not abs(integral(f-g)). Curve ordering may change. Bounds are sorted because area is unoriented; equal bounds give zero. Sampled values and totals must be finite. Known crossings can be supplied as breaks to help resolve the nonsmooth absolute difference. Finite sampling does not prove all crossings or features were resolved.

Value

Plain list with type, sorted interval, breaks, method, estimate (geometric area), signed_estimate (integral of f-g on increasing bounds), area and signed (complete segmented quadrature diagnostics), and note.

Examples

identity |> vc_area(c(-1,1),breaks=0)

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