Numerical integration schemes for triangles.
To numerically integrate any function over any given triangle, do
import numpy
import quadrature
def f(x): return numpy.sin(x[0]) * numpy.sin(x[1])
triangle = numpy.array([[0.0, 0.0], [1.0, 0.0], [0.7, 0.5]])
val = quadrature.triangle.integrate(f, triangle, quadrature.triangle.Strang9())
print(val)
This uses Strang's rule of degree 6 (see picture above); many more are implemented.
quadrature is available from the Python Package Index, so with
pip install -U quadrature
you can install/upgrade.
Download quadrature from
the Python Package Index.
Place the quadrature script in a directory where Python can find it (e.g.,
$PYTHONPATH
). You can install it system-wide with
python setup.py install
To run the tests, just check out this repository and type
nosetests
To create a new release
-
bump the
__version__
number, -
publish to PyPi and GitHub:
$ make publish
quadrature is published under the MIT license.