QuadratureÂ¶
Base classesÂ¶

class
modepy.
Quadrature
(nodes, weights)Â¶ The basic interface for a quadrature rule.

nodes
Â¶ An array of shape (d, nnodes), where d is the dimension of the qudrature rule. In 1D, the shape is just (nnodes,).

weights
Â¶ A vector of length nnodes.

exact_to
Â¶ Summed polynomial degree up to which the quadrature is exact. In higherdimensions, the quadrature is supposed to be exact on (at least) \(P^N\), where \(N\) =
exact_to
.

__call__
(f)Â¶ Evaluate the callable f at the quadrature nodes and return its integral.
f is assumed to accept arrays of shape (dims, npts), or of shape (npts,) for 1D quadrature.


modepy.
quadrature_for_space
(space, shape)Â¶ 
modepy.
quadrature_for_space
(space, shape) 
modepy.
quadrature_for_space
(space, shape)  Returns
a
Quadrature
that exactly integrates the functions in space over shape. Parameters
space (modepy.spaces.FunctionSpace) â€“
shape (modepy.shapes.Shape) â€“
 Return type
Redirections to Canonical NamesÂ¶

class
modepy.quadrature.
Quadrature
Â¶ See
modepy.Quadrature
.
JacobiGauss quadrature in one dimensionÂ¶

class
modepy.
JacobiGaussQuadrature
(alpha, beta, N, backend=None, force_dim_axis=False)Â¶ A Gauss quadrature of order N associated with the Jacobi polynomials.
The quadrature rule can be used for weighted integrals of the form
\[I[f] = \int_{1}^1 f(x) (1  x)^\alpha (1 + x)^\beta\, \mathrm{d}x,\]where \(\alpha, \beta > 1\). The quadrature rule is exact up to degree \(2N + 1\).
Inherits from
modepy.Quadrature
. See there for the interface to obtain nodes and weights.
__init__
(alpha, beta, N, backend=None, force_dim_axis=False)Â¶  Parameters
backend â€“ Either
"builtin"
or"scipy"
. When the"builtin"
backend is in use, there is an additional requirement that \(\alpha + \beta \ne 1\), with the exception of the Chebyshev quadrature \(\alpha = \beta = 1/2\). The"scipy"
backend has no such restriction.


class
modepy.
LegendreGaussQuadrature
(N, backend=None, force_dim_axis=False)Â¶ A Gauss quadrature rule with weight \(1\).
Corresponds to a GaussJacobi quadrature rule with \(\alpha = \beta = 0\).

class
modepy.
ChebyshevGaussQuadrature
(N, kind=1, backend=None, force_dim_axis=False)Â¶ A Gauss quadrature rule with weight \(\sqrt{1x^2}^{\mp 1}\).
The ChebyshevGauss quadrature rules of the first kind and second kind correspond to GaussJacobi quadrature rules with \(\alpha = \beta = 0.5\) and \(\alpha = \beta = 0.5\), respectively.
New in version 2019.1.

class
modepy.
GaussGegenbauerQuadrature
(alpha, N, backend=None, force_dim_axis=False)Â¶ GaussGegenbauer quadrature is a special case of GaussJacobi quadrature with \(\alpha = \beta\).
New in version 2019.1.

modepy.quadrature.jacobi_gauss.
jacobi_gauss_lobatto_nodes
(alpha, beta, N, backend=None, force_dim_axis=False)Â¶ Compute the GaussLobatto quadrature nodes corresponding to the
JacobiGaussQuadrature
with the same parameters.Exact to degree \(2N  3\).

modepy.quadrature.jacobi_gauss.
legendre_gauss_lobatto_nodes
(N, backend=None, force_dim_axis=False)Â¶ Compute the LegendreGaussLobatto quadrature nodes.
Exact to degree \(2N  1\).
ClenshawCurtis and FejĂ©r quadrature in one dimensionÂ¶

class
modepy.
ClenshawCurtisQuadrature
(N, force_dim_axis=False)Â¶ ClenshawCurtis quadrature of order N (having N + 1 points).
Inherits from
modepy.Quadrature
. See there for the interface to obtain nodes and weights.Integrates on the interval \((1, 1)\). The quadrature rule is exact up to degree \(N\); however, its performance for differentiable functions is comparable with the classic GaussLegendre quadrature which is exact for polynomials of degree up to \(2N + 1\).

class
modepy.
FejerQuadrature
(N, kind=1, force_dim_axis=False)Â¶ FejĂ©râ€™s quadrature rules of order N, categorized in two kinds. The FejĂ©râ€™s quadrature rule of first kind has N points; while the second kind has N  1 points.
The first kind uses Chebyshev nodes, i.e. roots of the Chebyshev polynomials. The second kind uses the interior extrema of the Chebyshev polynomials, i.e. the true stationary points.
The secondkind FejĂ©râ€™s quadrature rule is nearly identical to ClenshawCurtis. Both can also be nested.
Inherits from
modepy.Quadrature
. See there for the interface to obtain nodes and weights.Integrates on the interval \((1, 1)\).
Quadratures on the simplexÂ¶
New in version 2013.3.

class
modepy.
GrundmannMoellerSimplexQuadrature
(order, dimension)Â¶ Cubature on an nsimplex.
This cubature rule has both negative and positive weights. It is exact for polynomials up to order \(2s + 1\), where \(s\) is given as order.
The integration domain is the unit simplex. (see Coordinates on the triangle and Coordinates on the tetrahedron)

exact_to
Â¶ The total degree up to which the quadrature is exact.
See
A. Grundmann and H.M. Moeller, Invariant integration formulas for the nsimplex by combinatorial methods, SIAM J. Numer. Anal. 15 (1978), 282â€“290. http://dx.doi.org/10.1137/0715019

__init__
(order, dimension)Â¶  Parameters
order â€“ A parameter correlated with the total degree of polynomials that are integrated exactly. (See also
exact_to
.)dimension â€“ The number of dimensions for the quadrature rule. Any positive integer.

__call__
(f)Â¶ Evaluate the callable f at the quadrature nodes and return its integral.
f is assumed to accept arrays of shape (dims, npts), or of shape (npts,) for 1D quadrature.


class
modepy.
XiaoGimbutasSimplexQuadrature
(order, dims)Â¶ A (nearly) Gaussian simplicial quadrature with very few quadrature nodes, available for lowtomoderate orders.
Raises
modepy.QuadratureRuleUnavailable
if no quadrature rule for the requested parameters is available.The integration domain is the unit simplex. (see Coordinates on the triangle and Coordinates on the tetrahedron)
Inherits from
modepy.Quadrature
. See there for the interface to obtain nodes and weights.
exact_to
Â¶ The total degree up to which the quadrature is exact.
See
H. Xiao and Z. Gimbutas, â€śA numerical algorithm for the construction of efficient quadrature rules in two and higher dimensions,â€ť Computers & Mathematics with Applications, vol. 59, no. 2, pp. 663676, 2010. http://dx.doi.org/10.1016/j.camwa.2009.10.027

__init__
(order, dims)Â¶  Parameters
order â€“ The total degree to which the quadrature rule is exact.
dims â€“ The number of dimensions for the quadrature rule. 2 for quadrature on triangles and 3 for tetrahedra.

__call__
(f)Â¶ Evaluate the callable f at the quadrature nodes and return its integral.
f is assumed to accept arrays of shape (dims, npts), or of shape (npts,) for 1D quadrature.


class
modepy.
VioreanuRokhlinSimplexQuadrature
(order, dims)Â¶ Simplicial quadratures with symmetric node sets and positive weights suitable for wellconditioned interpolation. The integration domain is the unit simplex. (see Coordinates on the triangle and Coordinates on the tetrahedron)
Raises
modepy.QuadratureRuleUnavailable
if no quadrature rule for the requested parameters is available.Inherits from
modepy.Quadrature
. See there for the interface to obtain nodes and weights.
exact_to
Â¶ The total degree up to which the quadrature is exact.
When using these nodes, please acknowledge Zydrunas Gimbutas, who generated them as follows:
The 2D nodes are based on the interpolation node set derived in the article
B. Vioreanu and V. Rokhlin, â€śSpectra of Multiplication Operators as a Numerical Tool,â€ť Yale CS Tech Report 1443
Note that in Vioreanuâ€™s tables, only orders 5,6,9, and 12 are rotationally symmetric, which gives one extra order for integration and better interpolation conditioning. Also note that since the tables have been regenerated independently, the nodes and weights may be different.
The 3D nodes were derived from the
modepy.warp_and_blend_nodes()
.A tightening algorithm was then applied, as described in
B. Vioreanu, â€śSpectra of Multiplication Operators as a Numerical Toolâ€ť, Yale University, 2012. Dissertation
New in version 2013.3.

__init__
(order, dims)Â¶  Parameters
order â€“ The total degree to which the quadrature rule is exact for interpolation.
dims â€“ The number of dimensions for the quadrature rule. 2 for quadrature on triangles and 3 for tetrahedra.

__call__
(f)Â¶ Evaluate the callable f at the quadrature nodes and return its integral.
f is assumed to accept arrays of shape (dims, npts), or of shape (npts,) for 1D quadrature.

Quadratures on the hypercubeÂ¶

class
modepy.
WitherdenVincentQuadrature
(order, dims)Â¶ Symmetric quadrature rules with positive weights for rectangles and hexahedra.
The integration domain is the unit hypercube \([1, 1]^d\), where \(d\) is the dimension. The quadrature rules are adapted from:
F. D. Witherden, P. E. Vincent, On the Identification of Symmetric Quadrature Rules for Finite Element Methods, Computers & Mathematics with Applications, Vol. 69, pp. 1232â€“1241, 2015, DOI.

__init__
(order, dims)Â¶ Initialize self. See help(type(self)) for accurate signature.

__call__
(f)Â¶ Evaluate the callable f at the quadrature nodes and return its integral.
f is assumed to accept arrays of shape (dims, npts), or of shape (npts,) for 1D quadrature.


class
modepy.
TensorProductQuadrature
(quads)Â¶ 
__init__
(quads)Â¶  Parameters
quad â€“ a
tuple
ofQuadrature
for onedimensional intervals, one for each dimension of the tensor product.


class
modepy.
LegendreGaussTensorProductQuadrature
(N, dims, backend=None)Â¶