cauchy_principal_value, a Python code which uses Gauss-Legendre quadrature to estimate the Cauchy Principal Value of certain singular integrals.

The singular integrals to be considered will have the form:

        Integral ( a <= t <= b ) f(t) / ( t - x ) dt
The Cauchy Principal Value is defined as
        CPV = limit ( s --> x ) Integral ( a <= t <= s ) f(t) / ( t - x ) dt
            + limit ( x <-- s ) Integral ( s <= t <= b ) f(t) / ( t - x ) dt

We suppose that our singular integral is posed on an interval that is symmetric with respect to the location of the singularity:

        Integral ( x-d <= t <= x+d ) f(t) / ( t - x ) dt
and we propose to estimate the integral using a Gauss-Legendre rule of even order N:
        CPV approx sum ( 1 <= i <= N ) w(i) * f(xi(i)*d+x) / xi(i)
where xi(i) and w(i) are the points and weights, respectively, of the Gauss-Legendre rule.


The computer code and data files made available on this web page are distributed under the MIT license


cauchy_principal_value is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

quadrule, a Python code which defines quadrature rules for approximating an integral over a 1D domain.


  1. Julian Noble,
    Gauss-Legendre Principal Value Integration,
    Computing in Science and Engineering,
    Volume 2, Number 1, January-February 2000, pages 92-95.

Source Code:

Last modified on 21 January 2020.