cubs - Integrate functions numerically on the sphere (S2)

cubs is a utility package wrapping several commonly-used spherical cubature rules in a convenient interface:

cubs

Installation

You can install from GitHub with:

# install.package('remotes')
# remotes::install_github('nano-optics/cubs')
install.packages("cubs", repos = c('https://nano-optics.r-universe.dev', 'https://cloud.r-project.org'))

Simple example

Let’s request a Lebedev cubature with approximately 10 points,

cubs(N = 10, 'lebedev')
phi theta weight
1 0.0000000 1.5707963 0.0666667
2 3.1415927 1.5707963 0.0666667
3 1.5707963 1.5707963 0.0666667
4 -1.5707963 1.5707963 0.0666667
5 1.5707963 0.0000000 0.0666667
6 1.5707963 3.1415927 0.0666667
7 0.7853982 0.9553166 0.0750000
8 0.7853982 2.1862760 0.0750000
9 -0.7853982 0.9553166 0.0750000
10 -0.7853982 2.1862760 0.0750000
11 2.3561945 0.9553166 0.0750000
12 2.3561945 2.1862760 0.0750000
13 -2.3561945 0.9553166 0.0750000
14 -2.3561945 2.1862760 0.0750000

Lebedev, 10 points requested

Let’s try a known integrand,

f1(x, y, z) = 1 + x + y2 + x2y + x4 + y5 + x2y2z2

with the usual spherical coordinates.

We want to estimate the integral

I=14π∫0π∫02πf(φ,θ)sinθdφdθ numerically, i.e. with a spherical cubature I≈∑φi,θii=1…Nf(φi,θi)wi

We compare the exact value, 216π/35, to the Lebedev cubature for increasing number of points.

source value
lebedev N=14 19.5476876223365
lebedev N=26 19.3881146621542
exact 19.3881146621542

Acknowledgements

This package merely wraps existing rules in a convenient interface; the original cubature points were obtained from:

Fibonacci, grid, and random are implemented directly in the package.