# Numerical Integration

Here the *definite integral* for a function f(x) in the range x_{1}≤x≤x_{2} is calculated numerically.

Various numerical methods can be used in parallel: trapezoid rule, Simpson rule, Gauss quadrature method and integration according to Fejér.

The prerequisite is that the specified function curve is defined in the area x_{1}<x<x_{2} and has no pole positions.

The step size of the numerical integration is h. For integration, the interval [x_{1},x_{2}] is divided into areas of equal length of approximately this size h.

## Step size and support points of integration

An odd number of support points is required for the Simpson rule.
The specified step size may therefore be slightly reduced.

It should also be noted that Gaussian integration requires 2 or 3 function evaluations per interval.

The midpoint rule requires one function evaluation per interval and

the other methods each require a function evaluation at the interval boundaries.

The center rule and the Gaussian methods do not require *evaluation* at the edges of the area.

This is an advantage if the integrand at the edge of the domain has a definable gap in definition, such as x*ln(x) at x=0.

Even convergent improper integrals of the first kind, such as the integral over ln(x) from 0 to 1, are not a problem for these methods.

## Explanation of the graphical representation

The definite integral for a function f(x) returns the weighted sum of the area components that the function f(x) encloses in the area [a,b] with the x-axis.

Area portions that lie below the x-axis are included in the total with a negative sign, i.e. weighted with -1.

The definite integral then results in the difference of the sum of the area portions that lie above the x-axis and those that lie below the x-axis.

The graphical representation makes no difference between the positive and negative summands of the calculation.

## Area between 2 curves

Sometimes you want to determine the area of a surface enclosed by 2 curves for an interval [a,b] of the x-axis.

If the curves are given as functions f(x) and g(x), then the definite integral of |f(x)-g(x)| gives the enclosed area.

This also applies if the two curves intersect in the interval [a,b].

The area between the curve of f(x) and the x-axis g(x)=0 can therefore be calculated using the definite integral of |f(x)|.

more JavaScript applications