vc_spherical_integrate: Integrate a Cartesian field over a spherical-coordinate...

View source: R/spherical_integrate.R

vc_spherical_integrateR Documentation

Integrate a Cartesian field over a spherical-coordinate region

Description

Integrate a Cartesian field over a spherical-coordinate region

Usage

vc_spherical_integrate(
  f,
  interval,
  polar_lower,
  polar_upper,
  radial_lower,
  radial_upper,
  method = c("simpson", "trapezoid"),
  n_outer = 8L,
  n_middle = 16L,
  n_inner = 8L,
  abs_tol = 1e-08,
  rel_tol = 1e-08
)

Arguments

f

Scalar field accepting one vector in physical x,y,z order.

interval

Azimuth theta bounds in radians, reversed/equal allowed; absolute span at most 2*pi.

polar_lower, polar_upper

Functions of theta giving ordered polar angles phi in ⁠[0,pi]⁠, measured from the positive z axis.

radial_lower, radial_upper

Functions of one theta,phi vector giving nonnegative ordered radial bounds rho.

method

Simpson or trapezoid fixed quadrature.

n_outer, n_middle, n_inner

Initial cell counts, each refined internally.

abs_tol, rel_tol

Nonnegative diagnostic tolerances, one positive.

Details

Maps x=rho*sin(phi)*cos(theta), y=rho*sin(phi)*sin(theta), z=rho*cos(phi), using Jacobian rho^2*sin(phi). Exact endpoint poles use zero sine. Reuses vc_triple_integrate unchanged, preserving all diagnostics and heuristic error indicators. They are not certified bounds or evidence of change-of-variables hypotheses, integrability or ordering between nodes. All sampled fields must be finite, including origin and poles even where the Jacobian vanishes; supply justified continuous extensions explicitly. Azimuth reversal changes sign. Negative radii, sampled polar angles outside ⁠[0,pi]⁠ and spans above one azimuth turn are rejected. Equal widths skip deeper functions. No automatic singularity removal or adaptive nested rule.

Value

Full nested triple result of type spherical_integral. Stored engine coordinates are theta,phi,rho; f receives physical Cartesian x,y,z.

Examples

(function(v)1) |> vc_spherical_integrate(c(0,2*pi),function(t)0,function(t)pi,
  function(v)0,function(v)1,n_outer=2,n_middle=16,n_inner=2)

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