Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the abscissa-weight pairs of the elementary Newton-Cotes formula
ResourceFunction["NewtonCotesWeights"][n,a,b] gives a list of the n pairs {xi,wi} of the elementary n-point Newton-Cotes formula for quadrature on the interval a to b, where wi is the weight of the abscissa xi. |
Find the Newton-Cotes value weight:
| In[1]:= |
| Out[1]= | ![]() |
Set "QuadratureType"→Open to exclude the endpoints:
| In[2]:= |
| Out[2]= | ![]() |
Define the function:
| In[3]:= |
Visualize the area between 0 and 5:
| In[4]:= |
| Out[4]= | ![]() |
Determine the Newton-Cotes weights:
| In[5]:= |
| Out[5]= |
Multiply the value at each x-value by its weight:
| In[6]:= |
| Out[6]= |
Compare to the solution of NIntegrate:
| In[7]:= |
| Out[7]= |
The resource function NewtonCotesError can be used to determine the error in the Newton–Cotes approximation:
| In[8]:= |
| Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License