# Numerical integration

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

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

### 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 various degrees, integration of which yields the numerical integration formulas with various degrees 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 endpoints used by an integration method, **open** or **closed** rules are distinguished.

*Open rules* do not use endpoints. The open integration methods can be used in cases where the 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 endpoints 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 only one side.

## Newton-Cotes rule approximation error

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

Karl Runge, a 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 at the error equation. The formula includes interval h and factorial n!; both increase accuracy if n tends to infinity, but the n-degree derivative part value, which decreases accuracy in the error equation, raises faster for particular functions.

Also, with raising interpolation polynomial degree, we get negative weights, which can increase computational error. The calculator displays intermediate quadrature function results in graphical form. The methods having only positive W_{i} weights look like Riemann sum representation. If negative W_{i} weights exist, the graph has both positive and negative halves wider than the integration interval. This effect can be seen here: Closed Newton-Cotes rule with 11-nodes

Taking into account these arguments, it is not recommended to use rules with polynomial degree >10.

The integration interval can be divided into a few parts to increase accuracy, for each of which definite integral can be calculated separately with any integration rule. The final integral value is the sum of integrals for each partial interval.

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

The weights are comma-separated real numbers or common fractions. The first coefficient in the weight list is a common multiplier; enter 1 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., the Gauss-Kronrod rule. Hopefully, we'll illustrate it with 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