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

Total polynomial degree up to which the quadrature is exact.

__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.

Jacobi-Gauss quadrature in one dimension

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

Total polynomial degree up to which the quadrature is exact.

class modepy.JacobiGaussQuadrature(alpha, beta, N, backend=None)

An Gauss quadrature of order N associated with the Jacobi weight \((1 - x)^\alpha (1 + x)^\beta\), where \(\alpha, \beta > -1\).

Parameters

backend – Either "builtin" or "scipy".

When the "builtin" back-end is in use, there is an additional requirement that \((\alpha, \beta) \not \in \{(-1/2, -1/2)\}\). The "scipy" backend has no such restriction.

The sample points are the roots of the (N+1)-th degree Jacobi polynomial. Nodes and weights can be obtained from one of the supported backends (builtin, scipy).

Integrates on the interval \((-1, 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.

class modepy.LegendreGaussQuadrature(N, backend=None)

An Gauss quadrature associated with weight 1.

Integrates on the interval \((-1, 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.

(NOTE: Gauss–Legendre quadrature is a special case of Gauss–Jacobi quadrature with α = β = 0.)

class modepy.ChebyshevGaussQuadrature(N, kind=1, backend=None)

Chebyshev-Gauss quadrature of the first/second kind are special cases of Gauss–Jacobi quadrature with α = β = -0.5/0.5.

New in version 2019.1.

class modepy.GaussGegenbauerQuadrature(alpha, N, backend=None)

Gauss-Gegenbauer quadrature is a special case of Gauss–Jacobi quadrature with α = β.

New in version 2019.1.

modepy.quadrature.jacobi_gauss.jacobi_gauss_lobatto_nodes(alpha, beta, N, backend=None)

Compute the Gauss-Lobatto 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)

Compute the Legendre-Gauss-Lobatto quadrature nodes.

Exact to degree \(2N - 1\).

Clenshaw-Curtis and Fejér quadrature in one dimension

class modepy.ClenshawCurtisQuadrature(N)

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\).

class modepy.FejerQuadrature(N, kind=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)\).

Quadratures on the simplex

exception modepy.QuadratureRuleUnavailable

New in version 2013.3.

class modepy.GrundmannMoellerSimplexQuadrature(order, dimension)

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

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 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

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 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.

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.