Skip to content

Adaptive quadrature

Nico Schlömer edited this page Sep 29, 2021 · 3 revisions

quadpy can do adaptive quadrature for certain domains. Again, everything is fully vectorized, so you can provide vector-valued functions and the domain can have any dimensionality.

Line segments

import quadpy
from numpy import pi, sin

val, error_estimate = quadpy.c1.integrate_adaptive(
    lambda x: x * sin(5 * x), [0.0, pi], 1.0e-10
)

Triangles

import quadpy
from numpy import sin

val, error_estimate = quadpy.t2.integrate_adaptive(
    lambda x: x[0] * sin(5 * x[1]), [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]], 1.0e-10
)