Multidimensional volumes and monomial integrals.
ndim computes all kinds of volumes and integrals of monomials over such volumes in a fast, numerically stable way, using recurrence relations.
Install with
pip install ndim
and use like
import ndim
val = ndim.nball.volume(17)
print(val)
val = ndim.nball.integrate_monomial((4, 10, 6, 0, 2), lmbda=-0.5)
print(val)
# or nsphere, enr, enr2, ncube, nsimplex
0.14098110691713894
1.0339122278806983e-07
All functions have the symbolic
argument; if set to True
, computations are performed
symbolically.
import ndim
vol = ndim.nball.volume(17, symbolic=True)
print(vol)
512*pi**8/34459425
A PDF version of the text can be found here.
This note gives closed formulas and recurrence expressions for many
- Volume.
- Monomial integration.
- Volume.
- Monomial integration.
Note that both numerator and denominator in the closed expression will assume very large values even for polynomials of moderate degree. This can lead to difficulties when evaluating the expression on a computer; the registers will overflow. A common countermeasure is to use the log-gamma function,
but a simpler and arguably more elegant solution is to use the recurrence. This holds true for all such expressions in this note.
- Volume.
- Monomial integral.
-
Volume.
|S_n| = \frac{\sqrt{\pi}^n}{\Gamma(\frac{n}{2}+1)} = \begin{cases} 1&\text{if $n = 0$}\\ 2&\text{if $n = 1$}\\ |S_{n-2}| \times \frac{2\pi}{n}&\text{otherwise} \end{cases}
-
Monomial integral.
with
- Volume.
- Monomial integration.
Gegenbauer with
- Volume.
- Monomial integration.
Gegenbauer with
- Volume.
- Monomial integration.
- Volume
- Monomial integration.
with
- Volume.
- Monomial integration.
- Volume.
- Monomial integration.
To run the meshio unit tests, check out this repository and type
tox
This software is published under the GPLv3 license.