Information support for schoolchildren and students
Site search

Solving definite integrals by the Simpson method. Estimation of the accuracy of the calculation of "untaken" integrals. The remainder term of Simpson's formula is

Trapezoidal method

Let's split the segment into equal parts with dots:

The trapezoid method consists in replacing the integral with the sum:


The absolute error of the approximation obtained by the trapezoid formula is estimated using the formula, where.

Parabola method (Simpson's method)

a) Only one parabola passes through any three points with coordinates.

b) We express the area under the parabola on the segment through:

Taking into account the values ​​and from paragraph a) it follows:

c) Divide the segment into equal parts using points:

The parabola method consists in replacing the integral with the sum:

For approximate practical calculations, the following formula is used:


The absolute error of calculation by formula (4) is estimated by the relation, where.

Estimation of the accuracy of calculation of "non-taken" integrals

In this paper, the calculation of the absolute and relative errors is carried out on the condition that the exact value is known definite integral. However, not every antiderivative, even when it exists, is expressed in the final form through elementary functions. Such are the antiderivatives expressed by integrals, and so on. In all such cases, the antiderivative is some new feature, which is not reduced to a combination of a finite number of elementary functions.

Definite integrals of such functions can only be calculated approximately. To assess the accuracy of the calculation in such cases, for example, the Runge rule is used. In this case, the integral is calculated according to the chosen formula (rectangles, trapezoids, Simpson's parabolas) with the number of steps equal to n, and then with the number of steps equal to. The error in calculating the value of the integral with the number of steps equal is calculated by the Runge formula:, for the formulas of rectangles and trapezoids, and for the Sipson formula. Thus, the integral is calculated for successive values ​​of the number of steps, ..., where is the initial number of steps. The calculation process ends when the condition is met for the next value, where is the specified accuracy.

In order not to calculate the same integral several times for different partitions of the integration segment, you can calculate the integration step in advance.

Example. Select the integration step for calculating the integral with an accuracy of 0.01 using the quadrature formulas of rectangles, trapezoids, Simpson.

Quadrature formula of rectangles.

Let's calculate at what step the error will be 0.01:

integrand trapezoid parabola non-grasping

Because, then.

At a step, the segment is divided into equidistant nodes.

The quadrature formula of trapezoids.

Because the, .

When stepping, the segment is divided into equal nodes.

Simpson's quadrature formula.

Let's calculate at what step the error will be 0.01:

When stepping, the segment is divided into equal nodes.

As expected, the smallest number of equidistant nodes is obtained by calculating the integral using Simpson's quadrature formula.

The student is offered a job consisting of four stages:

  • Stage 1 - exact calculation of a definite integral.
  • Stage 2 - approximate calculation of a definite integral by one of the methods: rectangles or trapezoids.
  • Stage 3 - approximate calculation of a definite integral by the parabola method.

Stage 4 - calculation and comparison of the absolute and relative errors of approximate methods: , where - the exact solution of the integral, - the value of the integral obtained using approximate methods.

Plotting the integrand.

Variants and a sample of the implementation of the RGR are given below.

Options

option number

A sample of the implementation of the GGR

Exercise. Calculate Integral

1. Accurate calculation:


2. Approximate calculation using rectangle formulas:

Let's make a table:

According to the first formula of rectangles, we get:

0.1 = 0.1 3.062514 = 0.306251.

According to the second formula of rectangles, we get:

0.1 = 0.1 4.802669 = 0.480267.

In this case, the first formula gives the value of the integral with a deficiency, the second - with an excess.

3. Approximate calculation using the trapezoid formula:

In our case, we get:

0.1 = =0.1 = 0.1 4.095562 = =0.409556.


Let us calculate the relative and absolute errors.

4. Approximate calculation according to the Simpson formula:

In our case, we get:


Let us calculate the relative and absolute errors.

In reality, = 0.40631714.

Thus, when dividing the segment into 10 parts according to the Simpson formula, we got 5 correct signs; according to the formula of trapezoids - three correct signs; according to the formula of rectangles, we can only vouch for the first sign.

Parabola method (Simpson)

The essence of the method, formula, error estimate.

Let the function y = f(x) be continuous on a segment and we need to calculate a definite integral.

Divide the segment into n elementary

segments [;], i = 1., n of length 2*h = (b-a)/ n points

a =< < < < = b. Пусть точки, i = 1., n являются серединами отрезков [;], i = 1., n соответственно. В этом случае все «узлы» определяются из равенства = a + i*h, i = 0,1., 2*n.

On each interval [;], i = 1,2., n the integrand

is approximated by a quadratic parabola y = a* + b*x + c passing through the points (; f ()), (; f ()), (; f ()). Hence the name of the method - the method of parabolas.

This is done in order to take as an approximate value of a certain integral, which we can calculate using the Newton-Leibniz formula. This is what essence of the parabola method.

Derivation of Simpson's Formula.

To obtain the formula for the parabola method (Simpson), we have to calculate

Let us show that only one quadratic parabola y = a* + b*x + c passes through the points (; f ()), (; f ()), (; f ()) In other words, we prove that the coefficients are uniquely defined.

Since (; f ()), (; f ()), (; f ()) are points of the parabola, then each of the equations of the system

The written system of equations is a system of linear algebraic equations with respect to unknown variables, . The determinant of the main matrix of this system of equations is the Vandermonde determinant, and it is nonzero for mismatched points,. This indicates that the system of equations has a unique solution (this is discussed in the article solving systems of linear algebraic equations), that is, the coefficients are uniquely determined, and through the points (; f ()), (; f ()), (; f ()) passes through a single quadratic parabola.

Let's move on to finding the integral.

Obviously:

f() = f(0) = + + =

f() = f(h) = + +

f() = f(2*h) = + +

We use these equalities to make the last transition in the following chain of equalities:

= = (++) = h/3*(f()+4*f()+f())

Thus, you can get the formula of the parabola method:

An example of Simpson's method.

Calculate the approximate integral using Simpson's formula to the nearest 0.001. Splitting start with two segments

The integral, by the way, is not taken.

Solution: I immediately draw attention to the type of task - it is necessary to calculate a definite integral with a certain accuracy. As with the trapezoid method, there is a formula that will immediately allow you to determine the required number of segments in order to guarantee the required accuracy. True, we will have to find the fourth derivative and solve the extremal problem. In practice, a simplified method for estimating the error is almost always used.

I'm starting to decide. If we have two partition segments, then the nodes will be one more: , . And Simpson's formula takes a very compact form:

Let's calculate the partition step:

Let's fill in the calculation table:

In the top line we write the "counter" of indices

In the second line we first write lower limit integration a = 1.2, and then sequentially add the step h = 0.4.

In the third line we enter the values ​​of the integrand. For example, if = 1.6, then. How many decimal places to leave? Indeed, the condition again says nothing about this. The principle is the same as in the trapezoidal method, we look at the required accuracy: 0.001. And add an additional 2-3 digits. That is, you need to round up to 5-6 decimal places.

As a result:

The first result has been obtained. Now double number of segments up to four: . Simpson's formula for a given partition takes next view:

Let's calculate the partition step:

Let's fill in the calculation table:

In this way:

We estimate the error:


The error is greater than the required accuracy: 0.002165 > 0.001, so it is necessary to double the number of segments again: .

Simpson's formula gets bigger:

Let's calculate the step:

Let's fill in the spreadsheet again:

In this way:


Note that here it is desirable to describe the calculations in more detail, since the Simpson formula is rather cumbersome:

We estimate the error:

The error is less than the required accuracy: 0.000247< 0,001. Осталось взять наиболее точное приближение, округлить его до трёх знаков после запятой и записать.

Chair " higher mathematics»

Completed by: Matveev F.I.

Checked by: Burlova L.V.

Ulan-Ude.2002

1. Numerical methods of integration

2. Derivation of Simpson's formula

3.Geometric illustration

4. Choice of integration step

5.Examples

1. Numerical methods of integration

The problem of numerical integration is to calculate the integral

through a series of values ​​of the integrand .

Numerical integration problems have to be solved for functions given in a table, a function whose integrals are not taken into elementary functions, etc. Consider only functions of one variable.

Instead of the function to be integrated, let's integrate the interpolation polynomial. Methods based on the replacement of the integrand by an interpolation polynomial make it possible to estimate the accuracy of the result from the parameters of the polynomial or from given accuracy select these options.

Numerical methods can be conditionally grouped according to the method of integrand approximation.

The Newton-Cotes methods are based on the approximation of the function

degree polynomial. The algorithm of this class differs only in the degree of the polynomial. As a rule, the nodes of the approximating polynomial are equally related.

Spline integration methods are based on the function approximation

spline-piecewise polynomial.

The methods of the highest algebraic accuracy (Gauss method) use specially selected unequal nodes that provide the minimum integration error for a given (chosen) number of nodes.

Monte Carlo methods are used most often in the calculation of multiple integrals, the nodes are chosen randomly, the answer is probabilistic.


total error truncation error

rounding error

Regardless of the chosen method, in the process of numerical integration, it is necessary to calculate the approximate value of the integral and estimate the error. The error decreases as the n-number increases

partitions of the segment

. However, this increases the rounding error.

by summing the values ​​of the integrals calculated on partial segments.

The truncation error depends on the properties of the integrand and the length

partial cut.

2. Derivation of Simpson's formula

If for each pair of segments

construct a polynomial of the second degree, then integrate it and use the additivity property of the integral, then we obtain the Simpson formula. Consider the integrand on the interval . Let us replace this integrand with a second-degree Lagrange interpolation polynomial coinciding with at the points :

Let's integrate

:

and is called Simpson's formula.

Obtained for the integral

value coincides with the area of ​​a curvilinear trapezoid bounded by the axis , straight lines , and a parabola passing through the points

Let us now estimate the error of integration by the Simpson formula. We will assume that

there are continuous derivatives on the interval. Compose the difference

The mean value theorem can already be applied to each of these two integrals, since

is continuous on and the function is non-negative on the first integration interval and non-positive on the second (that is, it does not change sign on each of these intervals). That's why:

(we used the mean value theorem because

- continuous function; ).

differentiating

twice and then applying the mean value theorem, we obtain another expression for , where

From both estimates for

it follows that Simpson's formula is exact for polynomials of degree at most three. Let's write Simpson's formula, for example, in the form: , .

If the segment

integration is too large, then it is divided into equal parts (assuming ), after which the Simpson formula is applied to each pair of adjacent segments , ,..., namely:

Let us write the Simpson formula in general form.

Using three points to interpolate the integrand allows the use of a parabolic function (polynomial of the second degree). This leads to Simpson's formula for the approximate evaluation of the integral.

Consider an arbitrary integral

We use the change of variable so that the boundaries of the integration segment become [-1,1] instead of [-1,1], for this we introduce the variable z:

Then and

Consider the problem of interpolation by a polynomial of the second degree (parabola) of the integrand, using three equidistant nodal points as nodes - z = -1, z = 0, z = +1 (the step is 1, the length of the integration segment is 2). Let us denote the corresponding values ​​of the integrand at the interpolation nodes

System of equations for finding the coefficients of a polynomial

passing through three points, and

will take the form

or

Coefficients can easily be obtained

Let us now calculate the value of the integral of the interpolation polynomial

By a reverse change of variable, we return to the original integral. We take into account that

We obtain the Simpson formula for an arbitrary integration interval:

If necessary, the initial segment of integration can be divided into N double segments, to each of which the Simpson formula is applied. The interpolation step in this case will be

For the first segment of integration, the interpolation nodes will be points a, a + h, a + 2h, for the second - a + 2h, a + 3h, a + 4h, the third a + 4h, a + 5h, a + 6h, etc. . The approximate value of the integral is obtained by summing N areas:

This sum includes the same terms (for internal nodes with an even index value - 2i). Therefore, we can rearrange the terms in this sum in this way

What is equivalent

Because

The error of this approximate method decreases in proportion to the length of the integration step to the fourth power, i.e. doubling the number of intervals reduces the error by 16 times

Increasing Accuracy

Here we consider the so-called Aitken process. It makes it possible to estimate the error of the method and indicates the algorithm for refining the results. The calculation is carried out sequentially three times at different partitioning steps h 1 , h 2 , h 3 , and their ratios are constant: h 2 / h 1 = h 3 / h 2 = q (for example, when dividing the step in half q=0.5). Let the values ​​of the integral I 1 , I 2 , I 3 be obtained as a result of numerical integration. Then the refined value of the integral is calculated by the formula

and the order of accuracy of the numerical integration method used is determined by the relation

.

The value of the integral can also be refined using the Runge-Romberg method.

It follows from the analysis of the errors of numerical integration methods that the accuracy of the results obtained depends both on the nature of the change in the integrand and on the integration step. We assume that we set the step size. At the same time, it is clear that in order to achieve comparable accuracy when integrating a weakly changing function, the step can be chosen larger than when integrating sharply changing functions.

In practice, there are often cases when the integrand varies differently on separate sections of the integration segment. This circumstance requires such an organization of economical numerical algorithms, in which they would automatically adapt to the nature of the change in the function. Such algorithms are called adaptive (adaptable). They allow you to enter different values ​​of the integration step on separate sections of the integration segment. This makes it possible to reduce the computer time without losing the accuracy of the calculation results. We emphasize that this approach is usually used when setting the integrand y=f(x) in the form of a formula, and not in a tabular form.

Consider the principle of the adaptive algorithm. Initially, the segment is divided into n parts. In what follows, each such elementary segment is sequentially divided in half. The final number of steps, their location and size depend on the integrand and the allowable error e.

For each elementary segment, we apply the numerical integration formulas for two different partitions. We obtain approximations for the integral over this segment:

We compare the obtained values ​​and evaluate their error. If the error is within acceptable limits, then one of these approximations is taken as the value of the integral over this elementary segment. Otherwise, the segment is further divided and new approximations are calculated. In order to save time, the division points are arranged in such a way that the calculated values ​​at the points of the previous division are used.

The process of dividing the segment in half and calculating the refined values ​​continues until their difference becomes no more than some given value d i, depending on e and h:

.

A similar procedure is carried out for all n elementary segments. The value is taken as the desired value of the integral. The conditions and the corresponding choice of values ​​d i ensure the fulfillment of the condition

The remainder term of Simpson's quadrature formula is , where ξ∈(x 0 ,x 2) or

Service assignment. The service is designed to calculate the definite integral using the Simpson formula online.

Instruction. Enter the integrand f(x) , click Solve. The resulting solution is saved in a Word file. A solution template is also created in Excel.

Function entry rules

Examples correct spelling F(x):
1) 10 x e 2x ≡ 10*x*exp(2*x)
2) x e -x + cos(3x) ≡ x*exp(-x)+cos(3*x)
3) x 3 -x 2 +3 ≡ x^3-x^2+3

Derivation of Simpson's formula

From the formula
at n= 2 we get

Because x 2 -x 0 = 2h, then we have . (ten)
it simpson's formula. Geometrically, this means that we replace the curve y=f(x) with a parabola y=L 2 (x) passing through three points: M 0 (x 0 ,y 0), M 1 (x 1 ,y 1), M 2 (x2,y2).

The remainder term of Simpson's formula is


Assume that y∈C (4) . Let's get an explicit expression for R . Fixing the midpoint x 1 and considering R=R(h) as a function of h, we have:
.
Hence, differentiating successively three times with respect to h, we get






Finally we have
,
where ξ 3 ∈(x 1 -h,x 1 +h). In addition, we have: R(0) = 0, R"(0)=0. R""(0)=0. Now, integrating R"""(h) successively, using the mean value theorem, we obtain


Thus, the remainder term of Simpson's quadrature formula is
, where ξ∈(x 0 ,x 2). (eleven)
Therefore, Simpson's formula is exact for polynomials not only of the second, but also of the third degree.
We now obtain the Simpson formula for an arbitrary interval [ a,b]. Let n = 2m there is even number grid nodes (x i ), x i =a+i h, i=0,...,n, and y i =f(x i). Applying the Simpson formula (10) to each double interval , ,..., of length 2 h, will have


From here we get general formula Simpson
.(12)
The error for each double interval (k=1,...,m) is given by formula (11).

Because the number of double gaps is m, then

Taking into account the continuity of y IV on [ a,b], one can find a point ε such that .
Therefore we will have
. (13)
If the maximum permissible error ε is given, then, denoting , we get to determine the step h
.
In practice, the calculation R formula (13) is difficult. In this case, you can do the following. We calculate the integral I(h)=I 1 with step h , I(2h)=I 2 with step 2h, etc. and calculate the error Δ:
Δ = |I k -I k-1 | ≤ ε. (fourteen)
If inequality (14) is satisfied (ε is a given error), then I k = I(k·h) is taken as an estimate of the integral.
Comment. If the grid is non-uniform, then Simpson's formula takes the following form (get it yourself)
.
Let the number of nodes be n = 2m (even). Then

where h i =x i -x i-1 .

Example #1. Calculate the integral using Simpson's formula, assuming n = 10.
Solution: We have 2 m= 10. Hence . The calculation results are given in the table:

ix iy 2i-1y 2i
0 0 y 0 = 1.00000
1 0.1 0.90909
2 0.2 0.83333
3 0.3 0.76923
4 0.4 0.71429
5 0.5 0.66667
6 0.6 0.62500
7 0.7 0.58824
8 0.8 0.55556
9 0.9 0.52632
10 1.0 yn=0.50000
σ 1σ2

By formula (12) we obtain .
Let's calculate the error R=R 2 . Because , then .
Hence max|y IV |=24 for 0≤x≤1 and hence . Thus, I = 0.69315 ± 0.00001.

Example #2. In tasks, calculate the definite integral approximately using the Simpson formula, dividing the integration segment into 10 equal parts. Calculations shall be made with rounding to the fourth decimal place.