HCubature

pure-Julia multidimensional h-adaptive integration

https://github.com/juliamath/hcubature.jl

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 20 committers (5.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.5%) to scientific vocabulary

Keywords

cubature integration julia math numerical-integration

Keywords from Contributors

matrix-exponential sciml graphics accuracy doubledouble extended-precision floating-point precision julialang julia-package
Last synced: 4 months ago · JSON representation ·

Repository

pure-Julia multidimensional h-adaptive integration

Basic Info
  • Host: GitHub
  • Owner: JuliaMath
  • License: other
  • Language: Julia
  • Default Branch: master
  • Size: 114 KB
Statistics
  • Stars: 162
  • Watchers: 9
  • Forks: 27
  • Open Issues: 13
  • Releases: 10
Topics
cubature integration julia math numerical-integration
Created over 8 years ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

HCubature

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

math \int_{a_1}^{b_1} \int_{a_2}^{b_2} \cdots \int_{a_n}^{b_n} f(\vec{x})\,\mathrm{d}^n\vec{x}

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

Owner

  • Name: Julia Math
  • Login: JuliaMath
  • Kind: organization

Mathematics made easy in Julia

Citation (CITATION.bib)

% the software:

@misc{HCubature,
  title = {The {HCubature.jl} package for multi-dimensional adaptive integration in {Julia}},
  author = {Steven G. Johnson},
  year = {2017},
  howpublished = {\url{https://github.com/JuliaMath/HCubature.jl}}
}

% mathematical algorithm:

@article{Genz1980,
  title = {Remarks on algorithm 006: An adaptive algorithm for numerical integration over an $N$-dimensional rectangular region},
  author = {A. C. Genz and A. A. Malik},
  doi = {10.1016/0771-050x(80)90039-x},
  year = {1980},
  volume = {6},
  pages = {295--302},
  journal = {Journal of Computational and Applied Mathematics}
}

GitHub Events

Total
  • Issues event: 2
  • Watch event: 9
  • Issue comment event: 9
  • Push event: 1
  • Pull request review event: 3
  • Pull request review comment event: 3
  • Pull request event: 5
  • Fork event: 4
  • Create event: 1
Last Year
  • Issues event: 2
  • Watch event: 9
  • Issue comment event: 9
  • Push event: 1
  • Pull request review event: 3
  • Pull request review comment event: 3
  • Pull request event: 5
  • Fork event: 4
  • Create event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 104
  • Total Committers: 20
  • Avg Commits per committer: 5.2
  • Development Distribution Score (DDS): 0.394
Past Year
  • Commits: 9
  • Committers: 5
  • Avg Commits per committer: 1.8
  • Development Distribution Score (DDS): 0.667
Top Committers
Name Email Commits
Steven G. Johnson s****j@m****u 63
Andreas Noack a****s@n****k 7
dependabot[bot] 4****] 7
James Cook c****s@g****m 3
Pablo Zubieta p****z@y****x 3
Chris Rackauckas a****s@c****m 3
Kevin k****s@g****m 2
Yakir Luc Gagnon 1****r@g****m 2
Lorenzo Van Munoz 6****m 2
github-actions[bot] 4****] 2
Hendrik Ranocha r****a 1
Julia TagBot 5****t 1
Luiz M. Faria m****a 1
Mateus Araújo m****n@g****m 1
Michael Ingold m****d@g****m 1
Mosè Giordano 7****o 1
Stefanos Carlström s****m@g****m 1
Tim Holy t****y@g****m 1
Wonseok Shin w****7@g****m 1
jneem j****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 36
  • Total pull requests: 40
  • Average time to close issues: 7 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 29
  • Total pull request authors: 22
  • Average comments per issue: 3.78
  • Average comments per pull request: 1.38
  • Merged pull requests: 33
  • Bot issues: 0
  • Bot pull requests: 10
Past Year
  • Issues: 1
  • Pull requests: 7
  • Average time to close issues: about 2 hours
  • Average time to close pull requests: 1 day
  • Issue authors: 1
  • Pull request authors: 5
  • Average comments per issue: 3.0
  • Average comments per pull request: 0.29
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • mzaffalon (3)
  • agerlach (3)
  • araujoms (2)
  • nhavt (2)
  • yakir12 (2)
  • hesampour (1)
  • dandanua (1)
  • JuliaTagBot (1)
  • rpetit (1)
  • NoelAraujo (1)
  • giordano (1)
  • terasakisatoshi (1)
  • xiaoweiz (1)
  • IljaK91 (1)
  • hammerfunctor (1)
Pull Request Authors
  • dependabot[bot] (15)
  • stevengj (12)
  • lxvm (3)
  • maltezfaria (3)
  • github-actions[bot] (2)
  • giordano (2)
  • mikeingold (2)
  • kishore-nori (2)
  • mzaffalon (2)
  • jwscook (2)
  • araujoms (2)
  • wsshin (2)
  • JuliaTagBot (1)
  • yakir12 (1)
  • ranocha (1)
Top Labels
Issue Labels
enhancement (4) bug (1)
Pull Request Labels
dependencies (15)

Packages

  • Total packages: 1
  • Total downloads:
    • julia 695 total
  • Total dependent packages: 36
  • Total dependent repositories: 24
  • Total versions: 11
juliahub.com: HCubature

pure-Julia multidimensional h-adaptive integration

  • Versions: 11
  • Dependent Packages: 36
  • Dependent Repositories: 24
  • Downloads: 695 Total
Rankings
Dependent repos count: 1.5%
Dependent packages count: 2.3%
Average: 3.8%
Stargazers count: 5.1%
Forks count: 6.2%
Last synced: 5 months ago

Dependencies

.github/workflows/CI.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • codecov/codecov-action v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/CompatHelper.yml actions
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite