https://github.com/stla/adaptive-cubature
Adaptive integration of a multivariate function on a hypercube.
https://github.com/stla/adaptive-cubature
haskell integration multidimensional-integration
Last synced: about 1 month ago
JSON representation
Adaptive integration of a multivariate function on a hypercube.
- Host: GitHub
- URL: https://github.com/stla/adaptive-cubature
- Owner: stla
- License: gpl-3.0
- Created: 2023-09-14T10:53:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T20:07:36.000Z (over 2 years ago)
- Last Synced: 2025-10-25T16:34:01.061Z (7 months ago)
- Topics: haskell, integration, multidimensional-integration
- Language: C
- Homepage:
- Size: 14.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# adaptive-cubature
*Adaptive integration of a multivariate function on an axis-aligned hyperrectangle.*
___
This package is powered by the C library [cubature](https://github.com/stevengj/cubature).
Follow the link for details.
### Usage
```haskell
cubature :: Char -- ^ cubature version, 'h' or 'p'
-> ([Double] -> Double) -- ^ integrand
-> Int -- ^ dimension (number of variables)
-> [Double] -- ^ lower limits of integration
-> [Double] -- ^ upper limits of integration
-> Double -- ^ desired relative error
-> IO Result -- ^ output: integral value and error estimate
```
### Example
```haskell
fExample :: [Double] -> Double
fExample x = exp (-0.5 * (sum $ zipWith (*) x x))
example :: IO Result -- should give 2pi ≈ 6.283185307179586
example = cubature 'h' fExample 2 [-6, -6] [6, 6] 1e-10
-- Result {_integral = 6.283185282383672, _error = 6.280185128024888e-10}
```