Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find the error in the Newton–Cotes quadrature formula
ResourceFunction["NewtonCotesError"][n,f,a,b] gives the error in the elementary n-point Newton–Cotes quadrature formula for the function f on an interval from a to b. |
Find the error in the five-point Newton–Cotes quadrature of a function:
In[1]:= | ![]() |
Out[1]= | ![]() |
Determine the error in the Newton–Cotes approximation with four steps between 2 and 7 for a pure function:
In[2]:= | ![]() |
Out[2]= | ![]() |
The error for a function defined using SetDelayed:
In[3]:= | ![]() |
Out[3]= | ![]() |
The Newton–Cotes error involves a derivative of f at an unknown point, so you do not really know what the error itself is:
In[4]:= | ![]() |
Out[4]= | ![]() |
However, the error decreases rapidly with the length of the interval:
In[5]:= | ![]() |
Out[5]= | ![]() |
For a polynomial of order n, the n-point Newton–Cotes formula gives zero error, expressed through a zero-valued function 0&:
In[6]:= | ![]() |
Out[6]= | ![]() |
The Newton–Cotes result is the same as the one returned by Integrate:
In[7]:= | ![]() |
Out[7]= | ![]() |
In[8]:= | ![]() |
Out[8]= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License