# Numerical integration

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

### This page exists due to the efforts of the following people:

**Author**- Anton - Numerical integration
**Created using the work of**- Anton - Numerical integration with explicit Newton-Cotes formula coefficients
- Anton - Numerical integration using Newton-Cotes formulas

**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:

Save the calculation to reuse next time, toextensionembed in your website orshareshare with friends.

## Numerical integration using Newton-Cotes formulas

Using Newton-Cotes formulas, the integration interval is divided by points x_{1},x_{2},x_{3}..x_{n} 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:

- W
_{i}- weights, determined by integration methods - R
_{n}- 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 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 W_{i} weights it looks like Riemann sum representation. If negative W_{i} 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:

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.

Save the calculation to reuse next time, toextensionembed in your website orshareshare with friends.

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.*

Literature:

- N.S. Bakhvalov Numerical methods, 2012
- U.G.Pirumov Numerical methods, 2006
- D. Kahaner, C.Moler, S.Nash Numerical methods and software, 1989
- R.V. Hamming Numerical methods for scientists and engineers, 1972
- M. Abramovitz и I. Stegun Handbook of Mathematical Functions With Formulas, Graphs and Mathematical Tables, 1973

## Comments