# HYPERBALL_VOLUME_MONTE_CARLO Monte Carlo Estimate of Hyperball Volume

HYPERBALL_VOLUME_MONTE_CARLO is a FORTRAN90 program which investigates the behavior of a Monte Carlo procedure when it is applied to compute the integral of a discontinuous function. In particular, our integration region is the M-dimensional unit hypercube and our function f(x) is 1 if the point x is inside the unit hyperball of radius 1, and 0 otherwise.

The program uses the Monte Carlo method to estimate the volume. Estimates are made starting with 2^0 (=1) points and doubling repeatedly up to 2^25 points.

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.)

### Usage:

hyperball_volume_monte_carlo dim_num seed
where
• dim_num is the spatial dimension.
• seed is an optional seed for the random number generator. If it is not specified on the command line, a default value is used.

### Languages:

HYPERBALL_VOLUME_MONTE_CARLO is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

BALL_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate integrals of a function over the interior of the unit ball in 3D;

CIRCLE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function on the circumference of the unit circle in 2D;

CUBE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of the unit cube in 3D;

DISK01_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of the unit disk in 2D.

DISK01_QUARTER_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of the unit quarter disk in 2D;

ELLIPSE_MONTE_CARLO a FORTRAN90 library which uses the Monte Carlo method to estimate the value of integrals over the interior of an ellipse in 2D.

ELLIPSOID_MONTE_CARLO a FORTRAN90 library which uses the Monte Carlo method to estimate the value of integrals over the interior of an ellipsoid in M dimensions.

HYPERBALL_INTEGRALS, a FORTRAN90 library which returns the exact value of the integral of any monomial over the interior of the unit hyperball in M dimensions.

HYPERBALL_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of the unit hyperball in M dimensions;

HYPERBALL_VOLUME_QUAD, a FORTRAN90 program which applies a quadrature rule to estimate the volume of the unit hyperball in M dimensions.

HYPERCUBE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of the unit hypercube in M dimensions;

HYPERSPHERE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function on the surface of the unit sphere in M dimensions;

LINE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the length of the unit line in 1D;

POLYGON_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of a polygon in 2D.

PYRAMID_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate integrals of a function over the interior of the unit pyramid in 3D;

SIMPLEX_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of the unit simplex in M dimensions.

SPHERE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the surface of the unit sphere in 3D;

SPHERE_TRIANGLE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over a spherical triangle on the surface of the unit sphere in 3D;

SQUARE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the interior of the unit square in 2D;

TETRAHEDRON_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of the unit tetrahedron in 3D.

TRIANGLE_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of a general triangle in 2D.

TRIANGLE01_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of the unit triangle in 2D.

WEDGE_MONTE_CARLO, a FORTRAN90 library which uses the Monte Carlo method to estimate integrals over the interior of the unit wedge in 3D.

### Reference:

1. Philip Davis, Philip Rabinowitz,
Methods of Numerical Integration,
Second Edition,
Dover, 2007,
ISBN: 0486453391,
LC: QA299.3.D28.
2. Gerald Folland,
How to Integrate a Polynomial Over a Sphere,
American Mathematical Monthly,
Volume 108, Number 5, May 2001, pages 446-448.

### List of Routines:

• MAIN is the main program for HYPERBALL_VOLUME_MONTE_CARLO.
• HYPERBALL01_INDICATOR evaluates the unit hyperball indicator function.
• HYPERBALL01_VOLUME computes the volume of the unit hyperball.
• R8MAT_UNIFORM_01 returns a unit pseudorandom R8MAT.
• S_TO_I4 reads an I4 from a string.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the FORTRAN90 source codes.

Last revised on 03 January 2014.