---
name: "quadrule"
section: "3"
platform: "linux"
package: "libquadrule-dev"
version: "0~20121001-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/quadrule"
---

# quadrule(3)

C library of quadrature rules

## NAME

quadrule ‐ C library of quadrature rules

## SYNOPSIS

**#include \<quadrule.h\>**

## DESCRIPTION

**APPROXIMATING INTEGRALS**

The following functions apply an existing set of abscissas and weights to compute an approximation to an integral.

**double summer ( double** *func* **( double x ), int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Carries out a quadrature rule over a single interval.

**double sum\_sub ( double** *func* **( double x ), double** *a***, double** *b***, int** *nsub***, int** *order***, double** *xlo***, double** *xhi***, double** *xtab***\[\], double** *weight***\[\] )**

Carries out a composite quadrature rule.

*xlo* and *xhi* are the left and right endpoints of the interval over which the quadrature rule was defined.

*a* and *b* are the lower and upper limits of integration.

*nsub* is the number of equal subintervals into which the finite interval (*a*,*b*) is to be subdivided for higher accuracy.  *nsub* must be at least 1.

**double bdf\_sum ( double** *func* **( double x ), int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Carries out explicit backward difference quadrature on \[0,1\].  Requires *xtab* and *weight* to be pre‐computed from **bdfc\_set** or **bdfp\_set**.

**double laguerre\_sum ( double** *func* **( double x ), double** *a***, int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Carries out Laguerre quadrature over \[ A, +oo ).  Requires *xtab* and *weight* to be pre‐computed from **laguerre\_compute**, **gen\_laguerre\_compute**, or **laguerre\_set**.

**void summer\_gk ( double** *func* **( double x ), int** *orderg***, double** *weightg***\[\], double \****resultg***, int** *orderk* **, double** *xtabk***\[\], double** *weightk***\[\], double \****resultk* **)**

Carries out Gauss‐Kronrod quadrature over a single interval.  Before calling this function, *weightg* should be pre‐computed from **legendre\_compute\_dr** or **legendre\_set**.  Also, *xtabk* and *weightk* should be pre‐computed from **kronrod\_set**.  The orders should follow the relation *orderk* = 2 \* *orderg* + 1.  *resultk* will contain the result of the Gauss‐Kronrod sum.  *resultg* contains an intermediate sum, using only the Gauss quadrature.

**void sum\_sub\_gk ( double** *func* **( double x ), double** *a***, double** *b***, int** *nsub***, int** *orderg***, double** *weightg***\[\], double \****resultg***, int** *orderk***, double** *xtabk***\[\], double** *weightk***\[\], double \****resultk***, double \****error* **)**

Carries out a composite Gauss‐Kronrod rule.  Approximates the integral of *func* from *a* to *b*, by dividing the domain into *nsub* subdomains, and applying a Gauss‐Kronrod rule on each subdomain.

The following are utility function(s), to modify existing weights / abscissas before computing an integral.

**void rule\_adjust ( double** *a***, double** *b***, double** *c***, double** *d***, int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Maps a quadrature rule from \[A,B\] to \[C,D\]. *xtab* and *weight* are overwritten.

**COMPUTING QUADRATURE ABSCISSAS / WEIGHTS**

The following functions compute arrays of abscissas and weights (*xtab*, *weight*) for a particular quadrature rule, for any given *order*.  The range of the abscissas is ( -1 \<= x \< 1 ) unless otherwise given.

NOTE: *xtab* and *weight* must be allocated before calling these functions.

**void chebyshev1\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Chebyshev type 1 quadrature rule.

**void chebyshev2\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Chebyshev type 2 quadrature rule.

**void chebyshev3\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Chebyshev type 3 quadrature rule.

**void clenshaw\_curtis\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Clenshaw Curtis quadrature rule.

**void fejer1\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Fejer type 1 quadrature rule.

**void fejer2\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Fejer type 2 quadrature rule.

**void gegenbauer\_compute ( int** *order***, double** *alpha***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Gegenbauer quadrature rule.

**void gen\_hermite\_compute ( int** *order***, double** *alpha***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a generalized Gauss‐Hermite rule for the interval ( -infinity \< x \< +infinity )

**void gen\_laguerre\_compute ( int** *order***, double** *alpha***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a generalized Gauss‐Laguerre quadrature rule for the interval ( alpha \<= x \< infinity )

**void hermite\_ek\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Hermite quadrature rule, using an algorithm by Elhay and Kautsky.  Interval is ( -infinity \< x \< infinity )

**void hermite\_ss\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Hermite quadrature rule, using an algorithm by Arthur Stroud and Don Secrest. Interval is ( -infinity \< x \< infinity )

**void jacobi\_compute ( int** *order***, double** *alpha***, double** *beta***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Jacobi quadrature rule.

**void laguerre\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Gauss‐Laguerre quadrature rule for the inverval ( 0 \<= x \< infinity )

**void legendre\_compute\_dr ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Gauss‐Legendre quadrature by Davis‐Rabinowitz method.

**void lobatto\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Lobatto quadrature rule.

**void nc\_compute ( int** *order***, double** *x\_min***, double** *x\_max***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Newton‐Cotes quadrature rule.

( x\_min \<= x \<= x\_max )

**void ncc\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Newton‐Cotes Closed quadrature rule.

**void nco\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Newton‐Cotes Open quadrature rule.

**void ncoh\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Newton‐Cotes "open half" quadrature rule.

( x\_min \<= x \<= x\_max )

**void radau\_compute ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Computes a Radau quadrature rule.

**PRE‐COMPUTED QUADRATURES**

The following functions return abscissas/weights for various quadrature rules, but only for particular orders.

NOTE: Check the valid range of *order* parameters for the particular function before using it.  Using an unsupported *order* will cause an abort.

**void bashforth\_set ( int** *order***, double** *xtab***\[\], double** *weight* **\[\] )**

Sets an Adams‐Bashforth quadrature for *order* = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, or 20.

**void bdfc\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets weights for backward differentiation corrector quadrature, for 1 \<= *order* \<= 19.

**void bdfp\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets weights for backward differentiation predictor quadrature, for 1 \<= *order* \<= 19.

**void cheb\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Chebyshev quadrature, for *order* = 1, 2, 3, 4, 5, 6, 7, or 9.

**void clenshaw\_curtis\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Clenshaw‐Curtis quadrature rule, for *order* = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 33, 65, or 129.

**void fejer1\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Fejer type 1 quadrature, for *order* = 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10.

**void fejer2\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Fejer type 2 quadrature, for *order* = 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10.

**void hermite\_genz\_keister\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Hermite Genz‐Keister rule, for *order* = 1, 3, 7, 9, 17, 19, 31, 33, or 35.

**void hermite\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Hermite quadrature.  The *order* must be between 1 and 20, or 31/32/33, 63/64/65, 127/128/129.

**void kronrod\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Gauss‐Kronrod quadrature.  The *order* may be 15, 21, 31 or 41, corresponding to Gauss‐Legendre rules of order 7, 10, 15 or 20.

**void laguerre\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Laguerre quadrature.  The *order* must be between 1 and 20, or 31/32/33, 63/64/65, 127/128/129.

**void legendre\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Gauss‐Legendre quadrature.  The *order* must be between 1 and 33 or 63/64/65, 127/128/129, 255/256/257.

**void legendre\_set\_cos ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets Gauss‐Legendre rules for COS(X)\*F(X) on \[-PI/2,PI/2\].  The *order* must be 1, 2, 4, 8 or 16.

**void legendre\_set\_cos2 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets Gauss‐Legendre rules for COS(X)\*F(X) on \[0,PI/2\].  The *order* must be  2, 4, 8 or 16.

**void legendre\_set\_log ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Gauss‐Legendre rule for - LOG(X) \* F(X) on \[0,1\].  The *order* must be between 1 through 8, or 16.

**void legendre\_set\_sqrtx\_01 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets Gauss‐Legendre rules for SQRT(X)\*F(X) on \[0,1\].  The *order* must be between 1 and 16 or 63/64, 127/128.

**void legendre\_set\_sqrtx2\_01 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets Gauss‐Legendre rules for F(X)/SQRT(X) on \[0,1\].  The *order* must be be tween 1 and 16 or 63/64, 127/128.

**void legendre\_set\_x0\_01 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Gauss‐Legendre rule for F(X) on \[0,1\].  The *order* must be between 1 and 8.

**void legendre\_set\_x1 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Gauss‐Legendre rule for ( 1 + X ) \* F(X) on \[-1,1\].  The *order* must be between 1 and 9.

**void legendre\_set\_x1\_01 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Gauss‐Legendre rule for X \* F(X) on \[0,1\].  The *order* must be between 1 and 8.

**void legendre\_set\_x2 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets Gauss‐Legendre rules for ( 1 + X )^2\*F(X) on \[-1,1\].  The *order* must be between 1 and 9.

**void legendre\_set\_x2\_01 ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets a Gauss‐Legendre rule for X\*X \* F(X) on \[0,1\].  The *order* must be between 1 and 8.

**void lobatto\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Lobatto quadrature.  The *order* must be between 2 and 20.

**void moulton\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets weights for Adams‐Moulton quadrature.  The *order* must be between 1 and 10 or 12, 14, 16, 18 or 20.

**void ncc\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for closed Newton‐Cotes quadrature.  The *order* must be between 1 and 21.

**void nco\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for open Newton‐Cotes quadrature.  The *order* must be between 1 and 7, or 9.

**void ncoh\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Newton‐Cotes "open half" rules.  The *order* must be between 1 and 17.

**void patterson\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Gauss‐Patterson quadrature.  The *order* must be 1, 3, 7, 15, 31, 63, 127 or 255.

**void radau\_set ( int** *order***, double** *xtab***\[\], double** *weight***\[\] )**

Sets abscissas and weights for Radau quadrature.  The *order* must be between 1 and 15.

## AUTHOR

John Burkardt

## SEE ALSO

```
The official quadrule web page
http://people.sc.fsu.edu/~jburkardt/c_src/quadrule/quadrule.html
```
