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 Clenshaw-Curtis quadrature
| ResourceFunction["ClenshawCurtisQuadratureWeights"][n,{a,b}] gives a list of the n pairs {xi,wi} of the n-point Clenshaw-Curtis formula for quadrature on the interval a to b, where wi is the weight of the abscissa xi. | |
| ResourceFunction["ClenshawCurtisQuadratureWeights"][n,{a,b},prec] uses the working precision prec. | 
 .
.The abscissas and weights for a 10-point Clenshaw-Curtis quadrature on a given interval:
| In[1]:= | ![ResourceFunction["ClenshawCurtisQuadratureWeights"][10, {-2., 9.}]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/21a0d9d1a2c2e008.png) | 
| Out[1]= |  | 
Use the specified precision:
| In[2]:= | ![ResourceFunction["ClenshawCurtisQuadratureWeights"][3, {-1, 1}, 20]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/67d69c1e6cffd631.png) | 
| Out[2]= |  | 
Use Clenshaw-Curtis quadrature to approximate the area under a curve:
| In[3]:= | ![f = x |-> Cos[x] + 3 x^3 - x + 3](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/2e169b0e7c3ad083.png) | 
| Out[3]= |  | 
Plot the curve over a given interval:
| In[4]:= | ![Plot[f[x], {x, -0.5, 1.5}, Filling -> Axis, AxesOrigin -> {0, 0}]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/0e6474eee2eb5e1b.png) | 
| Out[4]= |  | 
Approximate the area under the curve using n-point Clenshaw-Curtis quadrature:
| In[5]:= | ![area[n_] := Module[{a, w}, {a, w} = Transpose@
    ResourceFunction["ClenshawCurtisQuadratureWeights"][
     n, {-0.5, 1.5}]; w . (f /@ a)]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/751ff8ebae3b9601.png) | 
| In[6]:= | ![area[5]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/3d2f6a1814119904.png) | 
| Out[6]= |  | 
Compare to the output of NIntegrate:
| In[7]:= | ![NIntegrate[f[x], {x, -0.5, 1.5}]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/41a7b1c9322ea293.png) | 
| Out[7]= |  | 
| In[8]:= | ![Abs[% - area[9]]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/463f828ea2b1697e.png) | 
| Out[8]= |  | 
The abscissas of n-point Clenshaw-Curtis quadrature are the extrema of the Chebyshev polynomial Tn-1(x), along with the interval extrema ±1:
| In[9]:= | ![ResourceFunction["ClenshawCurtisQuadratureWeights"][
  6, {-1, 1}][[All, 1]]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/00c293d319eb689e.png) | 
| Out[9]= |  | 
| In[10]:= | ![Join[{-1.}, x /. NSolve[D[ChebyshevT[5, x], x], x], {1.}]](https://www.wolframcloud.com/obj/resourcesystem/images/44d/44d5811d-5adb-4cd8-9a30-996c14b1362b/39234cc8c1789c16.png) | 
| Out[10]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License