# NIntegration.jl

This is library intended to provided multidimensional numerical integration routines in pure Julia

## Status

For the time being this library can only perform integrals in three dimensions.

**TODO**

- Add rules for other dimensions
- Make sure it works properly with complex valued functions
- Parallelize
- Improve the error estimates (the Cuba library and consequently Cuba.jl seem to calculate tighter errors)

## Installation

`NIntegration.jl`

should work on Julia 1.0 and later versions and can be
installed from a Julia session by running

```
julia> using Pkg
julia> Pkg.add(PackageSpec(url = "https://github.com/pabloferz/NIntegration.jl.git"))
```

## Usage

Once installed, run

`using NIntegration`

To integrate a function `f(x, y, z)`

on the
hyperrectangle defined by
`xmin`

and `xmax`

, just call

```
nintegrate(
f::Function, xmin::NTuple{N}, xmax::NTuple{N};
reltol = 1e-6, abstol = eps(), maxevals = 1000000
)
```

The above returns a tuple `(I, E, n, R)`

of the calculated integral `I`

, the
estimated error `E`

, the number of integrand evaluations `n`

, and a list `R`

of
the subregions in which the integration domain was subdivided.

If you need to evaluate multiple functions `(f₁, f₂, ...)`

on the same
integration domain, you can evaluate the function `f`

with more "features" and
use its subregions list to estimate the integral for the rest of the functions
in the list, e.g.

```
(I, E, n, R) = nintegrate(f, xmin, xmin)
I₁ = nintegrate(f₁, R)
```

## Technical Algorithms and References

The integration algorithm is based on the one decribed in:

- J. Berntsen, T. O. Espelid, and A. Genz, "An Adaptive Algorithm for the
Approximate Calculation of Multiple Integrals,"
*ACM Trans. Math. Soft.*, 17 (4), 437-451 (1991).

## Author

## Acknowdlegments

The author expresses his gratitude to Professor Alan Genz for some useful pointers.

This work was financially supported by CONACYT through grant 354884.