Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get a numerically sorted list of abscissa-weight pairs for Fejér quadrature
| 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. | 
 .
.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.}]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/436a2e1f6456142e.png)  | 
| 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.}]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/7eecabec7426e84e.png)  | 
| Out[2]= |   | 
Use the specified precision:
| In[3]:= | ![ResourceFunction["FejerQuadratureWeights"][1, 3, {-1, 1}, 20]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/41f526ea3e90149e.png)  | 
| Out[3]= |   | 
Use "I" or "II" to specify the type of Fejér quadrature:
| In[4]:= | ![ResourceFunction[
 "FejerQuadratureWeights"]["I", 4, {-1, 1}, $MachinePrecision]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/7eb849a106484353.png)  | 
| Out[4]= |   | 
| In[5]:= | ![ResourceFunction[
 "FejerQuadratureWeights"]["II", 4, {-1, 1}, $MachinePrecision]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/38fa7e1e9ef88361.png)  | 
| Out[5]= |   | 
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](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/188557f31009a849.png)  | 
| Out[6]= |   | 
Plot the curve over a given interval:
| In[7]:= | ![Plot[f[x], {x, -0.5, 1.5}, Filling -> Axis, AxesOrigin -> {0, 0}]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/126ff4b065ce0fb5.png)  | 
| 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)]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/0cc687a36391f943.png)  | 
| In[9]:= | ![fejerArea1[5]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/4cb6f3aa2636d57b.png)  | 
| Out[9]= |   | 
Compare to the output of NIntegrate:
| In[10]:= | ![NIntegrate[f[x], {x, -0.5, 1.5}]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/7d22791c0e224c14.png)  | 
| Out[10]= |   | 
| In[11]:= | ![Abs[% - fejerArea1[9]]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/0c1ebc302559afc9.png)  | 
| 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)]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/3e055f684d2cfab5.png)  | 
| In[13]:= | ![fejerArea2[5]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/36745cbdbd0e2cc7.png)  | 
| Out[13]= |   | 
Compare to the output of NIntegrate:
| In[14]:= | ![NIntegrate[f[x], {x, -0.5, 1.5}]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/42c603c070e78c24.png)  | 
| Out[14]= |   | 
| In[15]:= | ![Abs[% - fejerArea2[9]]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/51f811bf93082a9f.png)  | 
| Out[15]= |   | 
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]]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/1ca8bc961587ad8a.png)  | 
| Out[16]= |   | 
| In[17]:= | ![x /. NSolve[ChebyshevT[6, x], x]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/07a75a75eabb941f.png)  | 
| 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]]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/3b997525c624c95e.png)  | 
| Out[18]= |   | 
| In[19]:= | ![x /. NSolve[D[ChebyshevT[7, x], x], x]](https://www.wolframcloud.com/obj/resourcesystem/images/efa/efa0c19d-dbf5-441d-a0aa-c743436ac8e4/3dbfa2b399d1937d.png)  | 
| Out[19]= |   | 
This work is licensed under a Creative Commons Attribution 4.0 International License