integrateSpherePolynomial: Integration of polynomials over sphere or ball.

Description Usage Arguments Details Value References Examples

View source: R/SphericalCubature.R

Description

Exact integration of polynomial over sphere or ball in n-dimensions.

Usage

1
2

Arguments

p

a list specifying the coefficients and powers of the polynomial. See details below

valueOnly

boolean saying whether to return only the value of the integral, or return both the value and a intermediate terms. These intermediate terms are used by integrateBallPolynomial( ).

R

inner and outer radius of the annular region: R[1] <= radius <= R[2].

Details

Compute the exact integral over the sphere in n dimensions of a polynomial
p(x[1],...,x[n])=sum (coef[i] * x[1]^k[i,1] * ... * x[n]^k[i,n]),
where the sum is over i=1,...,m. The polynomial is specified as a list p with fields

m and n are given implicitly in the sizes of these arrays output is normally just a number, the value of the integral. If integrateSpherePolynomial is called with valueOnly=FALSE, a list with two fields:

Value

integrateSpherePolynomial() normally just returns a value of the integral, but if valueOnly=FALSE, it will return a list containing the value and intermediate terms. These intermediate terms correspond to the integral of each monomial term in the polynomial; they are used by integrateBallPolynomial().

integrateBallPolynomial( ) returns just the value of the integral.

References

Method is from How to Integrate a Polynomial over a Sphere, by G. Folland (2001), MAA Monthly 108, pg. 446-448.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
n <- 3
# specify the polynomial p(x) = 1.0 * x[1]^2 * x[2]^0 * x[3]^0 + 7.0 * x[1]^0 * x[2]^3 * x[3]
p <- list(coef=c(1.0,7.0),k=matrix( c(2L,0L,0L,0L,3L,0L), byrow=TRUE, nrow=2) )
integrateSpherePolynomial( p )
integrateBallPolynomial( p )

# compare to adaptive integration
f4 <- function( x ) { return( x[1]^2 + 7*x[2]^2*x[3] ) }
adaptIntegrateSpherePolar( f4, n )$integral
adaptIntegrateBallPolar( f4, n )$integral

Example output

Loading required package: cubature
Loading required package: SimplicialCubature
Loading required package: mvmesh
Loading required package: rcdd
If you want correct answers, use rational arithmetic.
See the Warnings sections added to help pages for
    functions that do computational geometry.

Loading required package: rgl
Loading required package: geometry
Loading required package: abind
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] 4.18879
[1] 0.837758
[1] 4.18879
[1] 0.8377581

SphericalCubature documentation built on Jan. 13, 2021, 1:04 p.m.