Function Repository Resource:

FejerQuadratureWeights

Source Notebook

Get a numerically sorted list of abscissa-weight pairs for Fejér quadrature

Contributed by: Jan Mangaldan

ResourceFunction["FejerQuadratureWeights"][m,n,{a,b}]

gives a list of the n pairs {xi,wi} of the n-point Fejér formula for quadrature of type m on the interval a to b, where wi is the weight of the abscissa xi.

ResourceFunction["FejerQuadratureWeights"][m,n,{a,b},prec]

uses the working precision prec.

Details and Options

Fejér quadrature approximates the value of an integral as a linear combination of values of the integrand evaluated at abscissas xi: .
Possible types m of Fejér quadrature are 1 and 2.
Type-1 Fejér quadrature uses the roots of the Chebyshev polynomial ChebyshevT as the abscissas.
Type-2 Fejér quadrature uses the extrema of the Chebyshev polynomial ChebyshevT as the abscissas.
You can use "I" or "II" for the types 1 and 2, respectively.
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 type-1 Fejér quadrature on a given interval:

In[1]:=
ResourceFunction["FejerQuadratureWeights"][1, 10, {-2., 9.}]
Out[1]=

The abscissas and weights for a 10-point type-2 Fejér quadrature on a given interval:

In[2]:=
ResourceFunction["FejerQuadratureWeights"][2, 10, {-2., 9.}]
Out[2]=

Use the specified precision:

In[3]:=
ResourceFunction["FejerQuadratureWeights"][1, 3, {-1, 1}, 20]
Out[3]=

Scope (1) 

Use "I" or "II" to specify the type of Fejér quadrature:

In[4]:=
ResourceFunction[
 "FejerQuadratureWeights"]["I", 4, {-1, 1}, $MachinePrecision]
Out[4]=
In[5]:=
ResourceFunction[
 "FejerQuadratureWeights"]["II", 4, {-1, 1}, $MachinePrecision]
Out[5]=

Applications (6) 

Use Fejér quadrature to approximate the area under a curve. First define a function:

In[6]:=
f = x |-> Cos[x] + 3 x^3 - x + 3
Out[6]=

Plot the curve over a given interval:

In[7]:=
Plot[f[x], {x, -0.5, 1.5}, Filling -> Axis, AxesOrigin -> {0, 0}]
Out[7]=

Approximate the area under the curve using n-point type-1 Fejér quadrature:

In[8]:=
fejerArea1[n_] := Module[{a, w}, {a, w} = Transpose@
    ResourceFunction["FejerQuadratureWeights"][1, n, {-0.5, 1.5}]; w.(f /@ a)]
In[9]:=
fejerArea1[5]
Out[9]=

Compare to the output of NIntegrate:

In[10]:=
NIntegrate[f[x], {x, -0.5, 1.5}]
Out[10]=
In[11]:=
Abs[% - fejerArea1[9]]
Out[11]=

Approximate the area under the curve using n-point type-2 Fejér quadrature:

In[12]:=
fejerArea2[n_] := Module[{a, w}, {a, w} = Transpose@
    ResourceFunction["FejerQuadratureWeights"][2, n, {-0.5, 1.5}]; w.(f /@ a)]
In[13]:=
fejerArea2[5]
Out[13]=

Compare to the output of NIntegrate:

In[14]:=
NIntegrate[f[x], {x, -0.5, 1.5}]
Out[14]=
In[15]:=
Abs[% - fejerArea2[9]]
Out[15]=

Properties and Relations (2) 

The abscissas of type-1 n-point Fejér quadrature are the roots of the Chebyshev polynomial Tn(x):

In[16]:=
ResourceFunction["FejerQuadratureWeights"][1, 6, {-1, 1}][[All, 1]]
Out[16]=
In[17]:=
x /. NSolve[ChebyshevT[6, x], x]
Out[17]=

The abscissas of type-2 n-point Fejér quadrature are the extrema of the Chebyshev polynomial Tn+1(x):

In[18]:=
ResourceFunction["FejerQuadratureWeights"][2, 6, {-1, 1}][[All, 1]]
Out[18]=
In[19]:=
x /. NSolve[D[ChebyshevT[7, x], x], x]
Out[19]=

Version History

  • 1.0.0 – 05 January 2021

Source Metadata

Related Resources

License Information