disk01_rule, a Fortran77 code which computes a quadrature rule over the interior of the unit disk in 2D.
The user specifies values NT and NR, where NT is the number of equally spaced angles, and NR controls the number of radial points. The program returns vectors T(1:NT), R(1:NR) and W(1:NR), which define the rule Q(f).
To use a rule that is equally powerful in R and T, typically, set NT = 2 * NR.
Given NT and NR, and the vectors T, R and W, the integral I(f) of a function f(x,y) is estimated by Q(f) as follows:
s = 0.0 for j = 1, nr for i = 1, nt x = r(j) * cos ( t(i) ) y = r(j) * sin ( t(i) ) s = s + w(j) * f ( x, y ) end end area = pi; q = area * s;
To approximate an integral over a circle with center (XC,YC) and radius RC:
s = 0.0 for j = 1, nr for i = 1, nt x = xc + rc * r(j) * cos ( t(i) ) y = yc + rc * r(j) * sin ( t(i) ) s = s + w(j) * f ( x, y ) end end area = rc * rc * pi; q = area * s;
The information on this web page is distributed under the MIT license.
disk01_rule is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.
f77_rule, a Fortran77 code which computes a quadrature rule which estimates the integral of a function f(x), which might be defined over a one dimensional region (a line) or more complex shapes such as a circle, a triangle, a quadrilateral, a polygon, or a higher dimensional region, and which might include an associated weight function w(x).