# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Find the error in the Newton–Cotes quadrature formula

Contributed by:
Jan Mangaldan

ResourceFunction["NewtonCotesError"][ gives the error in the elementary |

The error is given as a function of *n*, *a* and *b* multiplied by an *m*^{th} derivative of the function *f*. The size of the error is bounded by the maximum of this expression over the interval from *a* to *b*.

The abscissas may or may not include the endpoints *a* and *b* of the interval. The option "QuadratureType" is used to control whether endpoints are included as abscissas.

With the default setting "QuadratureType"→Closed, the endpoints are included as abscissas.

With the setting "QuadratureType"→Open, the endpoints are not included as abscissas. In this case, the initial abscissa is chosen to be a half step above the lower endpoint.

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]= |

- Tutorial: Numerical Differential Equation Analysis Package
- Guide: Numerical Differential Equation Analysis Package
- Newton–Cotes Formulas–Wolfram MathWorld

- 1.1.0 – 04 January 2021
- 1.0.0 – 15 November 2019

This work is licensed under a Creative Commons Attribution 4.0 International License