DOWNLOAD: QuadTools
Developed at The Computational Hydrodynamics and Informatics Laboratory (The CHIL) at The Ohio State University, QuadTools provides a collection of functions useful for obtaining, applying, and visualizing numerical quadrature rules for computing definite integrals over one- and two-dimensional domains (including a large collection of so-called nonproduct quadrature rules for the triangle and the square). With its extensive documentation, which includes a number of worked examples, it is also meant to serve as an educational resource for students and researchers.
Functions
The quadrature functions currently available in QuadTools include:
Detailed descriptions of each quad function, with examples, are available in the links above.
General Description
A quadrature “rule” consists of a set of quadrature weights and points that are used to form a weighted sum of function evaluations to compute the definite integral of a given function , i.e.,
In the case when is a polynomial, the above equation can be made exact with a sufficient number of weights and points A quadrature rule is said to be of degree d if it integrates all polynomial up to degree d exactly.
Quadrature rules are returned as structures Q with the following fields:
- Q.Points = the set of n quadrature points stored in an array of size , where is the dimension of the rule ( or 2).
- Q.Weights = the set of corresponding weights stored as a column vector of length
- Q.Properties = contains fields describing the .Degree, the .Type and the .Domain of integration of the quadrature rule.
An important difference to note between the primary inputs of the one- and two-dimensional cases is that the number of points n is specified in the one-dimensional cases (quadGaussJacobi, quadGaussLegendre, and quadGaussLobatto), while the degree d of the quadrature rule is specified in the two-dimensional cases (quadsquare and quadtriangle).
Given the weights and points of a quadrature rule, along with, for example, an anonymous-function representation (e.g., f = @(x)x.^3 + …), of the function to be integrated, the quadrature rule can be applied by simply taking a dot product, i.e.,
I = dot(Q.Weights,f(Q.Points));
or alternatively by multiplying a row vector of the weights (by taking the transpose) and a column vector of the function evaluations, i.e.,
I = Q.Weights’*f(Q.Points);