HYPERBALL_VOLUME_QUAD is a FORTRAN90 program which investigates the behavior of a quadrature rule when it is applied to the characteristic function of the unit M-dimensional hyperball, which is a discontinuous function.
The program integrates the function over the unit hypercube [-1,+1]^M, where the spatial dimension M is arbitrary. The value of M is inferred from the user input quadrature rule information.
The problem used as example input to the program works in M = 6 dimensions. In that case, the volume of the hypercube is 64; the volume of the hyperball is pi^3/6, or about 5.16771.
Because the integrand is discontinuous, any quadrature rule based on the idea of interpolation will probably be unable to do a good job. A family of quadrature rules, which rely on increasing the order of interpolation to improve accuracy, will probably get increasingly bad answers.
By contrast, a basic Monte Carlo rule, which assumes nothing about the function, integrates this function just as well as it integrates most any other square-integrable function. (That's both the strength and weakness of the blunt instrument we call Monte Carlo integration.)
The program assumes that the quadrature rule is defined by three text files.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
HYPERBALL_VOLUME_QUAD is available in a FORTRAN90 version.
HYPERBALL_INTEGRALS, a FORTRAN90 library which defines test functions for integration over the interior of the unit hyperball in M dimensions.
HYPERBALL_VOLUME_MONTE_CARLO, a FORTRAN90 program which applies a Monte Carlo method to estimate the volume of the unit hyperball in M dimensions;
NINTLIB, a FORTRAN90 library which numerically estimates integrals in multiple dimensions.
QUADRATURE_RULES, a dataset directory which contains sets of files that define quadrature rules over various 1D intervals or multidimensional hypercubes.
STROUD, a FORTRAN90 library which defines quadrature rules for a variety of unusual areas, surfaces and volumes in 2D, 3D and multiple dimensions.
TEST_NINT, a FORTRAN90 library which defines integrand functions for testing multidimensional quadrature routines.
TESTPACK, a FORTRAN90 library which defines a set of integrands used to test multidimensional quadrature.
You can go up one level to the FORTRAN90 source codes.