Numerical integration

To calculate definite integral by the rectangle method, trapezoid method, Simpson method or other Newton-Cotes quadrature methods.

Creative Commons Attribution/Share-Alike License 3.0 (Unported)

This content is licensed under Creative Commons Attribution/Share-Alike License 3.0 (Unported). That means you may freely redistribute or modify this content under the same license conditions and must attribute the original author by placing a hyperlink from your site to this work https://planetcalc.com/5494/. Also, please do not modify any references to the original work (if any) contained in this content.

Numerical methods can be used for definite integral value approximation. Numerical integration is used in case of impossibility to evaluate antiderivative analytically and then calculate definite integral using Newton–Leibniz axiom.

Numerical integration of a single argument function can be represented as the area (or quadrature) calculation of a curvilinear trapezoid bounded by the graph of a given function, the x-axis and vertical lines bounding given limits.
The integrand function is replaced by simpler one (which has antiderivative) approximating the integrand with a given accuracy. Replacing the integrand with Lagrange polynomials evaluated at equally spaced points in given limits yields the Newton-Cotes integration formulas, such as:

  1. Rectangle rule
  2. Trapezoidal rule
  3. Simpson rules

PLANETCALC, Numerical integration using Newton-Cotes formulas

Numerical integration using Newton-Cotes formulas

Digits after the decimal point: 6
Definite integral value
Quadrature function
Method error
Integral geometric view
Formula source

Numerical integration using Newton-Cotes formulas

Using Newton-Cotes formulas, the integration interval is divided by points x1,x2,x3..xn into equal line segments.
Integrand function is replaced by the Lagrange polynomials of different degree, integration of which yields the numerical integration formulas with different degree of accuracy.

Finally the definite integral approximation is evaluated as the weighted sum of integrand values evaluated for the integration points:
I\approx \sum _{{i=1}}^{{n}}{W_i}f(x_{i})+R_n

  • Wi - weights, determined by integration methods
  • Rn - remainder or error.
  • n - number of integration points.
  • The formula sum is a quadrature rule.

Handbook Newton-Cotes quadrature functions, contains a few commonly mentioned Newton-Cotes quadrature rules for integration on equally spaced intervals. Any registered user can add a new quadrature rule in this handbook.

Integration segment limits

Depending on the end points using by an integration method, open or closed rules are distinguished.

Open rules do not use end points. The open integration methods can be used in cases where integrand function is undefined in some points.
E.g. using rectangle method we can approximate ln(x) definite integral value on (0,1) line segment, in spite of ln(0) is undefined.

In opposite, Closed rules, use end points as well as midpoints to evaluate integrand function values.

Half-opened rules (e.g. left rectangle rule or right rectangle rule) can also be used to approximate integral on the line segment opened from the only one side.

Newton-Cotes rule approximation error

Commonly by the increasing number of integration points (with increasing polynomial degree), the accuracy is raised as well. But for some functions it is not true.

Karl Runge, german mathematician, analyzed this oddity first.
He noticed, the interpolaton polynomial with equally spaced interval for \frac{1}{1+25x^2} function ceases to converge in the range 0.726.. ≤ |x| <1 with raising polynomial degree.
It can be explained by looking on the error equation. The formula includes interval h and factorial n!, both of them increase accuracy if n tends to infinity, but n-degree derivative part value, which decrease accuracy in the error equation, raises faster for particular functions.

In addition, with raising interpolation polynomial degree, we get negative weights, which can increase computational error. The calculator displays intermediate quadrature function results in graphical form. For the methods having only positive Wi weights it looks like Riemann sum representation. If negative Wi weights exists, the graph has both positive and negative halves which are wider than integration interval. This effect can be seen here: Closed Newton-Cotes rule with 11-nodes

Taking in account this arguments it is not recommended to use rules with polynomial degree >10.

To increase accuracy, the integration interval can be divided in a few parts, for each of which definite integral can be calculated separately with any integration rule. Final integral value is the sum of integral for each partial intervals.

To evaluate a new integration methods based on eqally spaced intervals you may use the following calculator having an input box for entering weights:

PLANETCALC, Numerical integration with explicit Newton-Cotes formula coefficients

Numerical integration with explicit Newton-Cotes formula coefficients

All weights must be separated by comma. A weight is a simple fraction in form of n/d, where n - numerator, d - denominator or real number. The first weight is a common multiplier, set 1 if there is no common multiplier.
Digits after the decimal point: 6
Definite integral value
Quadrature function
Integral geometric view

The weights are comma separated real numbers or common fractions. First coefficient in the weight list is a common multiplier, enter 1 there if there is no common multiplier.

E.g. 3/8,1,3,3,1 weights can be used for Simpson 3/8 rule

Definite integral approximation with Newton-Cotes integration rules is far from ideal. For real applications you should use better methods, e,g. Gauss-Kronrod rule. Hopefully we'll illustrate it by the new calculators and articles in nearest future.


  1. N.S. Bakhvalov Numerical methods, 2012
  2. U.G.Pirumov Numerical methods, 2006
  3. D. Kahaner, C.Moler, S.Nash Numerical methods and software, 1989
  4. R.V. Hamming Numerical methods for scientists and engineers, 1972
  5. M. Abramovitz и I. Stegun Handbook of Mathematical Functions With Formulas, Graphs and Mathematical Tables, 1973
URL copied to clipboard
Creative Commons Attribution/Share-Alike License 3.0 (Unported) PLANETCALC, Numerical integration