## Base classes#

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 higher-dimensions, the quadrature is supposed to be exact on (at least) $$P^N$$, where $$N$$ = exact_to. If the quadrature accuracy is not known, attr:exact_to will not be set, and an AttributeError will be raised when attempting to access this information.

__init__(nodes, weights, exact_to=None)[source]#
Parameters:
• nodes – an array of shape (d, nnodes), where d is the dimension of the qudrature rule.

• weights – an array of length nnodes.

• exact_to – an optional argument denoting the symmed polynomial degree to which the quadrature is exact. By default, exact_to is None and will not be set as an attribute.

__call__(f)[source]#

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.

A quadrature rule that should be used for 0d domains (i.e. points).

Inherits from Quadrature.

Returns:

a Quadrature that exactly integrates the functions in space over shape.

## Jacobi-Gauss quadrature in one dimension#

class modepy.JacobiGaussQuadrature(alpha, beta, N, backend=None, force_dim_axis=False)[source]#

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)[source]#
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.

A Gauss quadrature rule with weight $$1$$.

Corresponds to a Gauss-Jacobi quadrature rule with $$\alpha = \beta = 0$$.

A Gauss quadrature rule with weight $$\sqrt{1-x^2}^{\mp 1}$$.

The Chebyshev-Gauss quadrature rules of the first kind and second kind correspond to Gauss-Jacobi quadrature rules with $$\alpha = \beta = -0.5$$ and $$\alpha = \beta = 0.5$$, respectively.

New in version 2019.1.

Gauss-Gegenbauer quadrature is a special case of Gauss-Jacobi quadrature with $$\alpha = \beta$$.

New in version 2019.1.

Compute the Gauss-Lobatto quadrature nodes corresponding to the JacobiGaussQuadrature with the same parameters.

Exact to degree $$2N - 3$$.

Exact to degree $$2N - 1$$.

## Clenshaw-Curtis and Fejér quadrature in one dimension#

Clenshaw-Curtis 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 Gauss-Legendre quadrature which is exact for polynomials of degree up to $$2N + 1$$.

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 second-kind Fejér’s quadrature rule is nearly identical to Clenshaw-Curtis. 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)$$.

New in version 2013.3.

Cubature on an n-simplex.

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 n-simplex by combinatorial methods, SIAM J. Numer. Anal. 15 (1978), 282–290. http://dx.doi.org/10.1137/0715019

__init__(order, dimension)[source]#
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)[source]#

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.

A (nearly) Gaussian simplicial quadrature with very few quadrature nodes, available for low-to-moderate 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. 663-676, 2010. http://dx.doi.org/10.1016/j.camwa.2009.10.027

__init__(order, dims)[source]#
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)[source]#

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.

Simplicial quadratures with symmetric node sets and positive weights suitable for well-conditioned 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 re-generated 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)[source]#
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)[source]#

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.

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)[source]#
Parameters:
• nodes – an array of shape (d, nnodes), where d is the dimension of the qudrature rule.

• weights – an array of length nnodes.

• exact_to – an optional argument denoting the symmed polynomial degree to which the quadrature is exact. By default, exact_to is None and will not be set as an attribute.

__call__(f)[source]#

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.

quad – a tuple of Quadrature for one-dimensional intervals, one for each dimension of the tensor product.