Function Repository Resource:

Get a numerically sorted list of abscissa-weight pairs for Gaussian quadrature

Contributed by: Paul Abbott (additional contributions by Wolfram Research staff)
 ResourceFunction["GaussianQuadratureWeights"][n,{a,b}] gives a list of the n pairs {xi,wi} of the elementary n-point Gaussian formula for quadrature on the interval a to b, where wi is the weight of the abscissa xi. ResourceFunction["GaussianQuadratureWeights"][n,{a,b},prec] uses the working precision prec.

## Details and Options

Gaussian quadrature approximates the value of an integral as a linear combination of values of the integrand evaluated at optimal abscissas xi: .
The abscissas are optimal in the sense that the quadrature formula is exact for all polynomials up to degree 2n-1.
The precision argument acts similarly to the WorkingPrecision option used in many Wolfram Language numeric functions; it is not at all like the PrecisionGoal option. If the n argument is too small to allow for a high-precision result, extra precision in a result will not be meaningful.

## Examples

### Basic Examples (3)

The abscissas and weights for a 10-point quadrature on a given interval:

 In[1]:=
 Out[1]=

The exact abscissas and weights:

 In[2]:=
 Out[2]=

Use the specified precision:

 In[3]:=
 Out[3]=

### Applications (3)

Use the Gaussian quadrature to approximate the area under a curve:

 In[4]:=
 Out[4]=

Plot the curve over a given interval:

 In[5]:=
 Out[5]=

Approximate the area under the curve for a specific n:

 In[6]:=
 In[7]:=
 Out[7]=

Compare to the output of NIntegrate:

 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=

The difference in Gaussian quadratures of two different orders:

 In[10]:=
 Out[10]=

The abscissas and weights for an n-point quadrature on {-1,1} for n=2 5:

 In[11]:=
 Out[11]=

The triangle of polynomials whose roots determine the weights for n up to 8:

 In[12]:=
 Out[12]=

### Properties and Relations (3)

For the interval {-1,1}, abscissas for the n-point Gaussian quadrature are the roots of the Legendre polynomial Pn(x):

 In[13]:=
 In[14]:=
 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=

The weights at abscissas xi are 2(1-xi2)/((n+1)2Pn+1(xi))2):

 In[17]:=
 Out[17]=
 In[18]:=
 Out[18]=

The sum of the weights is exactly 2:

 In[19]:=
 Out[19]=

Resource function GaussianQuadratureError gives an upper bound of the error in the weights used for the approximation:

 In[20]:=
 Out[20]=

The abscissas and weights for the elementary n-point Gaussian quadrature are related to the eigensystem of the nn symmetric tridiagonal Gaussian quadrature matrix:

 In[21]:=
 In[22]:=
 In[23]:=
 Out[23]=

Eigenvalues of the matrix determine the abscissas:

 In[24]:=
 Out[24]=
 In[25]:=
 Out[25]=

Eigenvectors of the matrix determine the weights:

 In[26]:=
 In[27]:=
 Out[27]=

## Version History

• 2.0.0 – 06 November 2020
• 1.0.0 – 20 November 2019