test_int_2d


test_int_2d, a Python code which evaluates test integrands and their exact integrals over a 2D rectangular region.

The test integrands would normally be used to testing 2D quadrature software. It is possible to invoke a particular function by number, or to try out all available functions, as demonstrated in the sample calling program.

The current set of problems is:

  1. integral on [0,1]x[0,1] of f(x,y) = 1 / ( 1 - x * y ); singular at [1,1].
  2. integral on [-1,1]x[-1,1] of f(x,y) = 1 / sqrt ( 1 - x * x * y * y ); singular at [1,1], [1,-1], [-1,1], [-1,-1];
  3. integral on [-1,1]x[-1,1] of f(x,y) = 1 / sqrt ( 2 - x - y ); singular at [1,1];
  4. integral on [-1,1]x[-1,1] of f(x,y) = 1 / sqrt ( 3 - x - 2 * y ); singular along the line y = ( 3 - x ) / 2.
  5. integral on [0,1]x[0,1] of f(x,y) = sqrt ( x * y ); singular along the lines y = 0 and x = 0.
  6. integral on [-1,1]x[-1,1] of f(x,y) = abs ( x * x + y * y - 1/4 ); nondifferentiable along x*x+y*y=1/4.
  7. integral on [0,1]x[0,1] of f(x,y) = sqrt ( abs ( x - y ) ); nondifferentiable along y = x.
  8. integral on [0,5]x[0,5] of f(x,y) = exp ( - ( (x-4)^2 + (y-1)^2 ) ), highly localized near (4,1).

The library includes not just the integrand, but also the interval of integration, and the exact value of the integral. Thus, for each integrand function, three routines are supplied. For instance, for function #5, we have the routines:

So once you have the calling sequences for these routines, you can easily evaluate the function, or integrate it between the appropriate limits, or compare your estimate of the integral to the exact value.

Moreover, since the same interface is used for each function, if you wish to work with problem 2 instead, you simply change the "05" to "02" in your routine calls.

If you wish to call all of the functions, then you simply use the generic interface, which again has three subroutines, but which requires you to specify the problem number as an extra input argument:

Licensing:

The information on this web page is distributed under the MIT license.

Languages:

test_int_2d is available in a C version and a C++ version and a Fortran77 version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

python_integrals, a Python code which returns the exact value of the integral of any monomial over the surface or interior of some geometric object, including a line, quadrilateral, box, circle, disk, sphere, ball and others.

Reference:

  1. Gwynne Evans,
    Practical Numerical Integration,
    Wiley, 1993,
    ISBN: 047193898X,
    LC: QA299.3E93.

Source Code:


Last revised on 27 June 2025.