• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    Julia
  • License
    Other
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pure-Julia multidimensional h-adaptive integration

HCubature

The HCubature module is a pure-Julia implementation of multidimensional "h-adaptive" integration. That is, given an n-dimensional integral

n-dimensional integral

then hcubature(f, a, b) computes the integral, adaptively subdividing the integration volume into smaller and smaller pieces until convergence is achieved to the desired tolerance (specified by optional rtol and atol keyword arguments, described in more detail below.

Because hcubature is written purely in Julia, the integrand f(x) can return any vector-like object (technically, any type supporting +, -, * real, and norm: a Banach space). You can integrate real, complex, and matrix-valued integrands, for example.

Note that HCubature assumes that your function f(x) can be computed at arbitrary points in the integration domain. (This is the ideal way to do numerical integration.) If you instead have f(x) precomputed at a fixed set of points, such as a Cartesian grid, you will need to use some other method (e.g. Trapz.jl for a multidimensional trapezoidal rule).

Usage

Assuming you've installed the HCubature package (via Pkg.add) and loaded it with using HCubature, you can then use it by calling the hcubature function:

hcubature

hcubature(f, a, b; norm=norm, rtol=sqrt(eps), atol=0, maxevals=typemax(Int), initdiv=1)

This computes the n-dimensional integral of f(x), where n == length(a) == length(b), over the hypercube whose corners are given by the vectors (or tuples) a and b. That is, dimension x[i] is integrated from a[i] to b[i]. The return value of hcubature is a tuple (I, E) of the estimated integral I and an estimated error E.

f should be a function f(x) that takes an n-dimensional vector x and returns the integrand at x. The integrand can be any type that supports +, -, * real, and norm functions. For example, the integrand can be real or complex numbers, vectors, matrices, etcetera. (For performance, the StaticArrays package is recommended for use with vector/matrix-valued integrands.)

The integrand f(x) will be always be passed an SVector{n,T}, where SVector is an efficient vector type defined in the StaticArrays package and T is a floating-point type determined by promoting the endpoint a and b coordinates to a floating-point type. (Your integrand f should be type-stable: it should always return a value of the same type, given this type of x.)

The integrand will never be evaluated exactly at the boundaries of the integration volume. (So, for example, it is possible to have an integrand that blows up at the boundaries, as long as the integral is finite, though such singularities will slow convergence.)

The integration volume is adaptively subdivided, using a cubature rule due to Genz and Malik (1980), until the estimated error E satisfies E ā‰¤ max(rtol*norm(I), atol), i.e. rtol and atol are the relative and absolute tolerances requested, respectively. It also stops if the number of f evaluations exceeds maxevals. If neither atol nor rtol are specified, the default rtol is the square root of the precision eps(T) of the coordinate type T described above. Initially, the volume is divided into initdiv segments along each dimension.

The error is estimated by norm(I - Iā€²), where Iā€² is an alternative estimated integral (via an "embedded" lower-order cubature rule.) By default, the norm function used (for both this and the convergence test above) is norm, but you can pass an alternative norm by the norm keyword argument. (This is especially useful when f returns a vector of integrands with different scalings.)

hquadrature

hquadrature(f, a, b; norm=norm, rtol=sqrt(eps), atol=0, maxevals=typemax(Int), initdiv=1)

Compute the (1d) integral of f(x) from a to b. The return value of hcubature is a tuple (I, E) of the estimated integral I and an estimated error E.

The other parameters are the same as hcubature (above). hquadrature is just a convenience wrapper around hcubature so that you can work with scalar x, a, and b, rather than 1-component vectors.

Alternatively, for 1d integrals you can import the QuadGK module and call the quadgk function, which provides additional flexibility e.g. in choosing the order of the quadrature rule. (QuadGK is used internally anyway by HCubature to compute the quadrature rule.)

Algorithm

The algorithm of hcubature is based on the one described in:

Author and Copyright

HCubature was written by Steven G. Johnson (SGJ), and is free/open-source software under the MIT/expat license.

SGJ also wrote an earlier C implementation of a similar algorithm that is also callable from Julia via the Cubature.jl package. The HCubature package is a from-scratch re-implementation, not a translation, of this code, both to take advantage of unique features of Julia and to eliminate licensing restrictions arising from the use of C code taken from the HIntLib library. (In both cases, the original DCUHRE Fortran code of Genz was not examined, only the mathematical description in the papers.)

More Repositories

1

openlibm

High quality system independent, portable, open source libm implementation
C
512
star
2

Interpolations.jl

Fast, continuous interpolation of discrete datasets in Julia
Julia
475
star
3

MeasureTheory.jl

"Distributions" that might not add to one.
Julia
388
star
4

SpecialFunctions.jl

Special mathematical functions in Julia
Julia
317
star
5

Polynomials.jl

Polynomial manipulations in Julia
Julia
301
star
6

Roots.jl

Root finding functions for Julia
Julia
299
star
7

Calculus.jl

Calculus functions in Julia
Julia
278
star
8

FFTW.jl

Julia bindings to the FFTW library for fast Fourier transforms
Julia
267
star
9

QuadGK.jl

adaptive 1d numerical Gaussā€“Kronrod integration in Julia
Julia
267
star
10

Combinatorics.jl

A combinatorics library for Julia
Julia
205
star
11

NFFT.jl

Julia implementation of the Non-equidistant Fast Fourier Transform (NFFT)
Julia
152
star
12

DoubleFloats.jl

math with more good bits
Julia
130
star
13

Cubature.jl

One- and multi-dimensional adaptive integration routines for the Julia language
Julia
117
star
14

AbstractFFTs.jl

A Julia framework for implementing FFTs
Julia
116
star
15

GSL.jl

Julia interface to the GNU Scientific Library (GSL)
Julia
100
star
16

IntervalSets.jl

Interval Sets for Julia
Julia
93
star
17

Primes.jl

Prime numbers in Julia
Julia
87
star
18

FixedPointNumbers.jl

fixed point types for julia
Julia
80
star
19

Bessels.jl

Bessel functions for real arguments and orders
Julia
78
star
20

RandomMatrices.jl

Random matrices package for Julia
Julia
77
star
21

Sobol.jl

generation of Sobol low-discrepancy sequence (LDS) for the Julia language
Julia
74
star
22

IntelVectorMath.jl

Julia bindings for the Intel Vector Math Library
Julia
72
star
23

HypergeometricFunctions.jl

A Julia package for calculating hypergeometric functions
Julia
67
star
24

AccurateArithmetic.jl

Calculate with error-free, faithful, and compensated transforms and extended significands.
Julia
64
star
25

Richardson.jl

Richardson extrapolation in Julia
Julia
62
star
26

FastChebInterp.jl

fast multidimensional Chebyshev interpolation and regression in Julia
Julia
58
star
27

Decimals.jl

Pure Julia decimal arithmetic library.
Julia
57
star
28

DecFP.jl

Julia IEEE decimal floating-point via the Intel decimal-float library
Julia
55
star
29

Yeppp.jl

Yeppp! bindings
Julia
54
star
30

NaNMath.jl

Julia math built-ins which return NaN and accumulator functions which ignore NaN
Julia
53
star
31

BFloat16s.jl

Julia implementation for the BFloat16 number type
Julia
48
star
32

FastPow.jl

optimal addition-chain exponentiation for Julia
Julia
41
star
33

Tau.jl

A Julia module providing the definition of the circle constant Tau (2Ļ€)
Julia
36
star
34

Quadmath.jl

Float128 and libquadmath for the Julia language
Julia
35
star
35

Hadamard.jl

Fast Walsh-Hadamard transforms for the Julia language
Julia
35
star
36

openspecfun

A collection of special mathematical functions
Fortran
33
star
37

FixedPointDecimals.jl

Julia fixed-point decimals built from integers
Julia
33
star
38

ChangePrecision.jl

macro to change the default floating-point precision in Julia code
Julia
33
star
39

InverseLaplace.jl

Inverse Laplace transform
Julia
30
star
40

InverseFunctions.jl

Interface for function inversion in Julia
Julia
29
star
41

MeasureBase.jl

Julia
26
star
42

DoubleDouble.jl

Extended precision arithmetic for Julia (deprecated)
Julia
26
star
43

Libm.jl

A pure Julia math library
Julia
24
star
44

TensorCore.jl

Lightweight package for sharing tensor-algebra definitions
Julia
23
star
45

LambertW.jl

Lambert W mathematical function
Julia
21
star
46

KahanSummation.jl

Sum and cumulative sum using the Kahan-Babuska-Neumaier algorithm
Julia
19
star
47

Float8s.jl

A number format that you can count with your fingers.
Julia
17
star
48

Infinities.jl

A Julia package for representing infinity in all its forms
Julia
17
star
49

Xsum.jl

exactly rounded double-precision summation for Julia
Julia
16
star
50

IrrationalConstants.jl

defines additional irrationals
Julia
16
star
51

FunctionAccuracyTests.jl

ULP testing for Floating Point special functions.
Julia
13
star
52

DensityInterface.jl

Interface for mathematical/statistical densities in Julia
Julia
12
star
53

ChangesOfVariables.jl

Interface for transformation functions in Julia
Julia
11
star
54

CheckedArithmetic.jl

Utilities for handling arithmetic overflow
Julia
10
star
55

RoundingIntegers.jl

Integer types that automatically round assigned values
Julia
10
star
56

IntegerMathUtils.jl

Julia
6
star
57

MittagLeffler.jl

Mittag-Leffler function
Julia
6
star
58

ILog2.jl

integer valued base 2 logarithm
Julia
5
star
59

FunctionZeros.jl

Zeros of Bessel J and Y functions
Julia
4
star
60

RealDot.jl

Compute `real(dot(x, y))` efficiently.
Julia
4
star
61

FFTWBuilder

binary builder for FFTW.jl package
Julia
2
star
62

OpenlibmBuilder

Julia
2
star
63

Roadmap.jl

1
star
64

OpenspecfunBuilder

Julia
1
star
65

DSFMTBuilder

Julia
1
star
66

MPFRBuilder

Julia
1
star
67

GMPBuilder

Julia
1
star