Calculate the definite integral using the Simpson formula. Start in science

If you were looking for only the Simpson method on this page, then I strongly recommend that you first read the beginning of the lesson and view at least the first example. For the reason that many ideas and techniques will be similar to the trapezoid method.

Again, let's start with the general formula
Consider the definite integral , where is a function continuous on the segment . Let us divide the segment into even amount equal segments. An even number of segments is denoted by .

In practice, segments can be:
two:
four:
eight:
ten:
twenty:
I don't remember any other options.

Attention! Number is understood as ONE NUMBER. That is, IT IS FORBIDDEN reduce, for example, by two, getting . Recording only means that the number of segments evenly. And there are no cuts to speak of.

So our partition looks like this:

The terms are similar to those of the trapezoidal method:
Dots are called knots.

Simpson formula for the approximate calculation of the definite integral has the following form:
where:
- the length of each of the small segments or step;
are the values ​​of the integrand at the points .

Detailing this piling up, I will analyze the formula in more detail:
is the sum of the first and last values ​​of the integrand;
is the sum of members with even indexes multiplied by 2;
is the sum of members with odd index is multiplied by 4.

Example 4

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

The integral, by the way, is again not taken.

Solution: I immediately draw attention to the type of task - it is necessary to calculate a definite integral with a certain accuracy. What this means has already been commented on at the beginning of the article, as well as on concrete examples of the previous paragraph. As for the trapezoidal method, there is a formula that will immediately allow you to determine the required number of segments (the value of "en") in order to guarantee the required accuracy. True, we will have to find the fourth derivative and solve the extremal problem. Who understood what I mean and estimated the amount of work, he smiled. However, there is no laughing matter here, finding the fourth derivative of such an integrand will no longer be a megabotan, but a clinical psychopath. Therefore, in practice, a simplified method for estimating the error is almost always used.

We start 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:


Once again I comment on how the table is filled:

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

In the second line, we first write the lower limit of integration, and then successively add the step.

In the third line we enter the values ​​of the integrand. For example, if , 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 this partition takes the following form:

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: , so you need to double the number of segments again: .

Simpson's formula is growing by leaps and bounds:

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 Simpson's formula is rather cumbersome, and if you immediately thump:
, then this booze will look like a hack. And with a more detailed recording, the teacher will get the favorable impression that you conscientiously erased the keys of the microcalculator for a good hour. Detailed calculations for "hard" cases are present in my calculator.

We estimate the error:

The error is less than the required accuracy: . It remains to take the most accurate approximation , round it up to three decimal places and write:

Answer: accurate to 0.001

Example 5

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

This is a do-it-yourself example. An approximate example of a final “short” design of the solution and the answer at the end of the lesson.

In the final part of the lesson, we will consider a couple more common examples.

Example 6

Calculate the approximate value of a definite integral using the Simpson formula, dividing the integration segment into 10 parts. Calculation accuracy 0.001.

This integral is taken, however, it is not so easy for a beginner to crack it, the corresponding solution method is considered in example 5 of the lesson Complex integrals. In problems of approximate calculation, the integral need not necessarily be untaken! Curious students can calculate it exactly and estimate the error relative to the approximate value.

Solution: Pay attention to the wording of the task: "The accuracy of calculations is 0.001." The semantic nuance of this formulation suggests that the results need only be rounded to the third decimal place, and not achieve such accuracy. Thus, when you are asked to solve a problem on the trapezoid method, the Simpson method, always pay close attention to the terms! Haste, as you know, is needed when hunting for fleas.

We use the Simpson formula:

With ten division segments, the step is

Let's fill in the calculation table:

It is more rational to make the table two-story so that you don’t have to “shrink” and everything fits legibly on a notebook sheet.

Calculations, do not be lazy, paint in more detail:

Answer:

And once again I emphasize that there is no question of accuracy here. In fact, the answer may not be, but, relatively speaking, . In this regard, in the answer, it is not necessary to automatically attribute the “duty” ending: “with an accuracy of 0.001”

Example 7

Calculate the approximate value of the definite integral using Simpson's formula, dividing the integration segment into 10 parts. All calculations must be carried out to the third decimal place.

A rough version of the final design and the answer at the end of the lesson that came to an end.

Other methods are also used for the approximate calculation of a definite integral. In particular, the theory power series with a standard task Approximate calculation of a definite integral by expanding the integrand into a series. But this is the material of the second course.

And now it's time to reveal the terrible secret of integral calculus. I have already created more than a dozen lessons on integrals, and this, so to speak, is a theory and a classic of the topic. In practice, in particular, in engineering calculations, to bring objects closer real world almost impossible with standard mathematical functions. Impossible perfect exactly calculate, area, volume, density, for example, asphalt pavement. Error, let it be from the tenth, let it be from the hundredth decimal place - but it will still be. That is why hundreds of heavy bricks have been written using approximate calculation methods and serious software for approximate calculations has been created. The classical theory of integral calculus is actually used much less frequently. But, by the way, without it - also nowhere!

This lesson is not a record in terms of volume, but it took me an unusually long time to create it. I corrected the material and reworked the structure of the article several times, as new nuances and subtleties were constantly drawn. I hope the work was not in vain, and it turned out quite logical and accessible.

All the best!

Solutions and answers:

Example 3:Solution: We divide the integration segment into 4 parts:
Then the trapezoid formula takes the following form:

Let's calculate the step:
Let's fill in the calculation table:

To find a definite integral using the trapezoid method, the area of ​​a curvilinear trapezoid is also divided into n rectangular trapezoids with heights h and bases y 1, y 2, y 3,..y n, where n is the number of the rectangular trapezoid. The integral will be numerically equal to the sum of the areas of rectangular trapezoids (Figure 4).

Rice. four

n - number of splits

The error of the trapezoid formula is estimated by the number

The error of the trapezoid formula decreases faster with growth than the error of the rectangle formula. Therefore, the trapezoid formula allows you to get more accuracy than the rectangle method.

Simpson formula

If for each pair of segments we construct a polynomial of the second degree, then integrate it on the segment and use the additivity property of the integral, then we obtain the Simpson formula.

In Simpson's method for calculating the definite integral, the entire integration interval is divided into subintervals equal length h=(b-a)/n. The number of partition segments is an even number. Then, on each pair of adjacent subintervals, the subintegral function f(x) is replaced by a Lagrange polynomial of the second degree (Figure 5).

Rice. 5 The function y=f(x) on the segment is replaced by a 2nd order polynomial

Consider the integrand on the interval. Let us replace this integrand with a second-degree Lagrange interpolation polynomial coinciding with y= at the points:

Let's integrate on the interval:

We introduce a change of variables:

Given the replacement formulas,


After integrating, we get the Simpson formula:

The value obtained for the integral coincides with the area of ​​a curvilinear trapezoid bounded by an axis, straight lines, and a parabola passing through points. On a segment, Simpson's formula will look like:

In the parabola formula, the value of the function f (x) at odd split points x 1, x 3, ..., x 2n-1 has a coefficient of 4, at even points x 2, x 4, ..., x 2n-2 - coefficient 2 and at two boundary points x 0 =a, x n =b - coefficient 1.

The geometric meaning of Simpson's formula: the area of ​​a curvilinear trapezoid under the graph of the function f(x) on a segment is approximately replaced by the sum of the areas of the figures lying under the parabolas.

If the function f(x) has a continuous derivative of the fourth order, then the absolute value of the error of the Simpson formula is no more than

where M - highest value on the segment. Since n 4 grows faster than n 2 , the error of Simpson's formula decreases with increasing n much faster than the error of the trapezoid formula.

We calculate the integral

This integral is easy to calculate:

Let's take n equal to 10, h=0.1, calculate the values ​​of the integrand at the partition points, as well as half-integer points.

According to the formula of middle rectangles, we get I straight = 0.785606 (the error is 0.027%), according to the trapezoid formula I trap = 0.784981 (the error is about 0.054. When using the method of right and left rectangles, the error is more than 3%.

To compare the accuracy of the approximate formulas, we calculate once again the integral

but now by the Simpson formula for n=4. We divide the segment into four equal parts with points x 0 \u003d 0, x 1 \u003d 1/4, x 2 \u003d 1/2, x 3 \u003d 3/4, x 4 \u003d 1 and calculate approximately the values ​​of the function f (x) \u003d 1 / ( 1+x) at these points: y 0 =1.0000, y 1 =0.8000, y 2 =0.6667, y 3 =0.5714, y 4 =0.5000.

By Simpson's formula, we get

Let us estimate the error of the result obtained. For the integrand f(x)=1/(1+x) we have: f (4) (x)=24/(1+x) 5 , whence it follows that on the segment . Therefore, we can take M=24, and the result error does not exceed 24/(2880 4 4)=0.0004. Comparing the approximate value with the exact one, we conclude that the absolute error of the result obtained by the Simpson formula is less than 0.00011. This is in accordance with the error estimate given above and, in addition, indicates that the Simpson formula is much more accurate than the trapezoid formula. Therefore, the Simpson formula for the approximate calculation of definite integrals is used more often than the trapezoid formula.

In this method, it is proposed to approximate the integrand on a partial interval by a parabola passing through the points
(x j , f(x j)), where j = i-1; i-0.5; i, that is, we approximate the integrand by the Lagrange interpolation polynomial of the second degree:

(10.14)

After integrating, we get:

(10.15)

That's what it is simpson's formula or the formula of parabolas. On the segment
[a, b] Simpson's formula takes the form

(10.16)

A graphical representation of Simpson's method is shown in fig. 2.4.

Rice. 10.4. Simpson method

Let's get rid of fractional indices in expression (2.16) by renaming the variables:

(10.17)

Then Simpson's formula takes the form

(10.18)

The error of formula (2.18) is estimated by the following expression:

, (10.19)

where h n = b-a, . Thus, the error of Simpson's formula is proportional to O(h 4).

Comment. It should be noted that in the Simpson formula, the integration segment is necessarily divided into even number of intervals.

10.5. Calculation of definite integrals by methods
Monte Carlo

The previously discussed methods are called deterministic , that is, devoid of the element of chance.

Monte Carlo Methods(MMK) are numerical methods for solving mathematical problems using simulation random variables. MCM allow to successfully solve mathematical problems caused by probabilistic processes. Moreover, when solving problems that are not related to any probabilities, one can artificially come up with a probabilistic model (and even more than one) that allows solving these problems. Consider the calculation of the definite integral

(10.20)

When calculating this integral using the formula of rectangles, the interval [ a, b] split into N identical intervals, in the middle of which the values ​​of the integrand were calculated. By calculating the function values ​​at random nodes, you can get a more accurate result:

(10.21)

(10.22)

Here γ i is a random number uniformly distributed over the interval
. The error in calculating the MMK integral ~ , which is much larger than that of the previously studied deterministic methods.

On fig. 2.5 shows a graphical implementation of the Monte Carlo method for calculating a single integral with random nodes (2.21) and (2.22).


(2.23)

Rice. 10.6. Monte Carlo integration (2nd case)

As seen in fig. 2.6, the integral curve lies in the unit square, and if we can get pairs of random numbers uniformly distributed over the interval, then the obtained values ​​(γ 1, γ 2) can be interpreted as the coordinates of a point in the unit square. Then, if there are enough of these pairs of numbers, we can approximately assume that
. Here S is the number of pairs of points that fall under the curve, and N is the total number of pairs of numbers.

Example 2.1. Calculate the following integral:

The task was solved various methods. The results obtained are summarized in table. 2.1.

Table 2.1

Comment. The choice of the table integral allowed us to compare the error of each method and find out the influence of the number of partitions on the accuracy of calculations.

11 APPROXIMATE SOLUTION OF NONLINEAR
AND TRANSCENDENT EQUATIONS

Calculation of integrals using the formulas of rectangles, trapezoids and Simpson's formula. Estimation of errors.

Guidelines on topic 4.1:

Calculation of integrals by formulas of rectangles. Error estimate:

The solution of many technical problems is reduced to the calculation of certain integrals, the exact expression of which is difficult, requires lengthy calculations and is not always justified in practice. Here, their approximate value is quite sufficient. For example, you need to calculate the area bounded by a line whose equation is unknown, the axis X and two ordinates. In this case, you can replace this line with a simpler one, for which the equation is known. The area of ​​the curvilinear trapezoid thus obtained is taken as the approximate value of the desired integral. Geometrically, the idea behind the method of calculating the definite integral using the formula of rectangles is that the area of ​​a curvilinear trapezoid A 1 ABB 1 is replaced by the area of ​​an equal area rectangle A 1 A 2 B 1 B 2, which, according to the mean value theorem, is equal to

Where f(c) --- height rectangle A 1 A 2 B 1 B 2, which is the value of the integrand at some intermediate point c(a< c

It is practically difficult to find such a value With, at which (b-a)f(c) would be exactly equal to . To obtain a more accurate value, the area of ​​\u200b\u200ba curvilinear trapezoid is divided into n rectangles whose heights are equal y 0 , y 1 , y 2 , …,y n -1 and foundations.

If we summarize the areas of rectangles that cover the area of ​​a curvilinear trapezoid with a disadvantage, the function is non-decreasing, then instead of the formula, the formula is used

If in excess, then

Values ​​are found from equalities. These formulas are called rectangle formulas and give an approximate result. With the increase n the result becomes more accurate.

Example 1 . Calculate from the formula of rectangles

We divide the interval of integration into 5 parts. Then . Using a calculator or a table, we find the values ​​​​of the integrand (with an accuracy of 4 decimal places):

According to the formula of rectangles (with a disadvantage)

On the other hand, according to the Newton-Leibniz formula

Let's find the relative calculation error using the formula of rectangles:

Calculation of integrals by trapezoid formulas. Error estimate:

The geometric meaning of the following method for the approximate calculation of integrals is that finding the area of ​​an approximately equal-sized "rectilinear" trapezoid.

Let it be necessary to calculate the area A 1 AmBB 1 curvilinear trapezoid, expressed by the formula .

Let's replace the arc AmB chord AB and instead of the area of ​​a curvilinear trapezoid A 1 AmBB 1 calculate the area of ​​the trapezoid A 1 ABB 1: , where AA 1 and BB 1 - the base of the trapezoid, and A 1 B 1 is its height.


Denote f(a)=A 1 A,f(b)=B 1 B. trapezoid height A 1 B 1 \u003d b-a, square . Consequently, or

This so-called small trapezoid formula.

The problem arises of the numerical calculation of a definite integral, which is solved with the help of formulas called quadrature.

Recall the simplest formulas for numerical integration.

Let us calculate the approximate numerical value of . We divide the integration interval [а, b] into n equal parts by dividing points
, called nodes of the quadrature formula. Let the values ​​in the nodes be known
:


Value

is called the integration interval or step. Note that in the practice of -calculations, the number i is chosen small, usually it is not more than 10-20. On a partial interval

the integrand is replaced by the interpolation polynomial


which approximately represents the function f(x) on the interval under consideration.

a) Keep only one first term in the interpolation polynomial, then


The resulting quadratic formula

called the formula of rectangles.

b) Keep the first two terms in the interpolation polynomial, then

(2)

Formula (2) is called the trapezoid formula.

c) Integration interval
we divide into an even number of 2n equal parts, while the integration step h will be equal to . On the interval
of length 2h, we replace the integrand with an interpolation polynomial of the second degree, i.e., we keep the first three terms in the polynomial:

The resulting quadrature formula is called Simpson's formula

(3)

Formulas (1), (2) and (3) have a simple geometric meaning. In the formula of rectangles, the integrand f(x) on the interval
is replaced by a straight line segment y \u003d uk, parallel to the x-axis, and in the trapezoid formula - by a straight line segment
and the area of ​​a rectangle and a rectilinear trapezoid is calculated, respectively, which are then summed up. In Simpson's formula, the function f(x) on the interval
length 2h is replaced by a square trinomial - a parabola
the area of ​​a curvilinear parabolic trapezoid is calculated, then the areas are summed up.

CONCLUSION

In conclusion, I would like to note a number of features of the application of the methods discussed above. Each method for the approximate solution of a definite integral has its advantages and disadvantages, depending on the task at hand, specific methods should be used.

Variable substitution method is one of the main methods for calculating indefinite integrals. Even when we integrate by some other method, we often have to resort to a change of variables in intermediate calculations. The success of the integration depends to a large extent on whether we can find such a good change of variables that would simplify the given integral.

In essence, the study of integration methods comes down to finding out what kind of change of variable should be made for one form or another of the integrand.

In this way, integration of every rational fraction reduces to integrating a polynomial and a few simple fractions.

The integral of any rational function can be expressed in terms of elementary functions in the final form, namely:

    through logarithms - in cases of the simplest fractions of type 1;

    through rational functions - in the case of simple fractions of type 2

    through logarithms and arctangents - in the case of simple fractions of type 3

    through rational functions and arctangents - in the case of the simplest fractions of type 4. The universal trigonometric substitution always rationalizes the integrand, but often it leads to very cumbersome rational fractions, for which, in particular, it is practically impossible to find the roots of the denominator. Therefore, if possible, partial substitutions are used, which also rationalize the integrand and lead to less complex fractions.

Newton–Leibniz formula is a general approach to finding definite integrals.

As for the methods for calculating definite integrals, they practically do not differ from all those methods and methods.

The same applies substitution methods(change of variable), the method of integration by parts, the same methods of finding antiderivatives for trigonometric, irrational and transcendental functions. The only peculiarity is that when applying these techniques, it is necessary to extend the transformation not only to the sub-integral function, but also to the limits of integration. When changing the integration variable, remember to change the integration limits accordingly.

Properly from the theorem, the continuity condition of the function is a sufficient condition for the integrability of the function. But this does not mean that the definite integral exists only for continuous functions. The class of integrable functions is much wider. So, for example, there is a definite integral of functions that have a finite number of discontinuity points.

The calculation of a definite integral of a continuous function using the Newton-Leibniz formula is reduced to finding an antiderivative, which always exists, but is not always an elementary function or a function for which tables are compiled that make it possible to obtain the value of the integral. In numerous applications, the integrable function is given in a table, and the Newton-Leibniz formula is not directly applicable.

If you want the most accurate result, ideal simpson's method.

From the above studied, the following conclusion can be drawn that the integral is used in such sciences as physics, geometry, mathematics and other sciences. With the help of the integral, the work of the force is calculated, the coordinates of the center of mass, the path traveled by the material point are found. In geometry, it is used to calculate the volume of a body, find the length of an arc of a curve, etc.