checkintrfr: Check the Integral of r f_r(r)

checkintrfrR Documentation

Check the Integral of r f_r(r)

Description

This function is auxiliary to polyCub.iso for the cubature of a radially symmetric function f(x,y) = f_r(||(x,y)-\boldsymbol{\mu}||), with \mu being the center of isotropy, over a polygonal domain. The (analytical) integral of r f_r(r) from 0 to R, intrfr, is checked against an integrate-based approximation for various values (rs) of the upper bound R. A warning is issued if inconsistencies are found.

Usage

checkintrfr(intrfr, f, ..., center, control = list(), rs = numeric(0L),
  tolerance = control$rel.tol)

Arguments

intrfr

a function(R, ...), which implements the (analytical) antiderivative of r f_r(r) from 0 to R. The first argument must be vectorized but not necessarily named R.
If intrfr is missing, it will be approximated numerically via

  integrate(function(r, ...) r * f(cbind(x0 + r, y0), ...),
            0, R, ..., control = control)

where c(x0, y0) is the center of isotropy. Note that f will not be checked for isotropy.

f

a two-dimensional real-valued function. As its first argument it must take a coordinate matrix, i.e., a numeric matrix with two columns, and it must return a numeric vector of length the number of coordinates.

...

further arguments for f or intrfr.

center

numeric vector of length 2, the center of isotropy.

control

list of arguments passed to integrate, the quadrature rule used for the line integral along the polygon boundary.

rs

numeric vector of upper bounds for which to check the validity of intrfr. If it has length 0 (default), no checks are performed.

tolerance

of all.equal.numeric when comparing intrfr results with numerical integration. Defaults to the relative tolerance used for integrate.

Value

The intrfr function, invisibly. If only f was given, an integrate-based approximation of intrfr is returned.

Examples

f_const <- function (coords) rep(1, nrow(coords))
intrfr_const <- function (R) R^2/2  # = \int_0^R r f_r(r) dr
checkintrfr(intrfr_const,  f = f_const, center = c(0,0), rs = 1:10) # OK
checkintrfr(function(R) R, f = f_const, center = c(0,0), rs = 1:10) # warns

polyCub documentation built on April 24, 2026, 5:07 p.m.