# LEGENDRE_RULE_FAST Order N Computation of Legendre Quadrature Rule

LEGENDRE_RULE_FAST is a C program which implements a fast algorithm for the computation of the points and weights of the Gauss-Legendre quadrature rule.

The standard algorithm for computing the N points and weights of such a rule is by Golub and Welsch. It sets up and solves an eigenvalue problem, whose solution requires work of order N*N.

By contrast, the fast algorithm, by Glaser, Liu and Rokhlin, can compute the same information expending work of order N. For quadrature problems requiring high accuracy, where N might be 100 or more, the fast algorithm provides a significant improvement in speed.

The Gauss-Legendre quadrature rule is designed for the interval [-1,+1].

The Gauss-Legendre quadrature assumes that the integrand has the form:

```        Integral ( -1 <= x <= +1 ) f(x) dx
```

The standard Gauss-Legendre quadrature rule is used as follows:

```        Integral ( -1 <= x <= +1 ) f(x) dx
```
is to be approximated by
```        Sum ( 1 <= i <= order ) w(i) * f(x(i))
```

This program allows the user to request that the rule be transformed from the standard interval [-1,+1] to the interval [a,b].

### Usage:

legendre_rule_fast n a b
where
• n is the order (number of points);
• a is the left endpoint (often -1.0 or 0.0);
• b is the right endpoint (usually 1.0).

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

LEGENDRE_RULE_FAST is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

CLENSHAW_CURTIS_RULE, a C program which defines a Clenshaw Curtis quadrature rule.

HERMITE_RULE, a C program which can compute and print a Gauss-Hermite quadrature rule.

LAGUERRE_RULE, a C program which can compute and print a Gauss-Laguerre quadrature rule.

LEGENDRE_EXACTNESS, a C program which tests the monomial exactness of quadrature rules for the Legendre problem of integrating a function with density 1 over the interval [-1,+1].

LEGENDRE_RULE, a C program which computes a 1D Gauss-Legendre quadrature rule.

PATTERSON_RULE, a C program which computes a Gauss-Patterson quadrature rule.

QUADRULE, a C library which defines quadrature rules for 1D domains.

### Reference:

1. Andreas Glaser, Xiangtao Liu, Vladimir Rokhlin,
A fast algorithm for the calculation of the roots of special functions,
SIAM Journal on Scientific Computing,
Volume 29, Number 4, pages 1420-1438, 2007.

### Examples and Tests:

The following files were created by the command legendre_rule_fast 15 0.0 2.0:

### List of Routines:

• MAIN is the main program for LEGENDRE_RULE_FAST.
• LEGENDRE_COMPUTE_GLR: Legendre quadrature by the Glaser-Liu-Rokhlin method.
• LEGENDRE_COMPUTE_GLR0 gets a starting value for the fast algorithm.
• LEGENDRE_COMPUTE_GLR1 gets the complete set of Legendre points and weights.
• LEGENDRE_COMPUTE_GLR2 finds the first real root.
• LEGENDRE_HANDLE computes the requested Gauss-Legendre rule and outputs it.
• R8MAT_WRITE writes an R8MAT file.
• RESCALE rescales a Legendre quadrature rule from [-1,+1] to [A,B].
• RK2_LEG advances the value of X(T) using a Runge-Kutta method.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• TS_MULT evaluates a polynomial.
• WTIME estimates the elapsed wall clock time.

You can go up one level to the C source codes.

Last revised on 22 October 2009.