How to calculate a definite integral using the trapezoid method? Calculation of integrals by the formulas of rectangles and trapezoids. Error estimate Quadrature trapezoid formula for calculating integrals

How to calculate a definite integral
using the trapezoid formula and the Simpson method?

Numerical methods is a fairly large section of higher mathematics and serious textbooks on this topic have hundreds of pages. In practice, in tests, some tasks are traditionally proposed for solving by numerical methods, and one of the common tasks is approximate calculation definite integrals. In this article, I will consider two methods for the approximate calculation of a definite integral − trapezoidal method And simpson's method.

What do you need to know to master these methods? It sounds funny, but you may not be able to take integrals at all. And even do not understand what integrals are. Of the technical means, you will need a microcalculator. Yes, yes, we are waiting for routine school calculations. Better yet, download my semi-automatic calculator for the trapezoid method and the Simpson method. The calculator is written in Excel and will allow you to reduce the time for solving and processing tasks tenfold. A video manual is included for Excel teapots! By the way, the first video with my voice.

First, let's ask ourselves the question, why do we need approximate calculations at all? It seems to be possible to find the antiderivative of the function and use the Newton-Leibniz formula, calculating the exact value of a certain integral. As an answer to the question, let's immediately consider a demo example with a picture.

Calculate a definite integral

Everything would be fine, but in this example the integral is not taken - before you is not taken, the so-called integral logarithm. Does this integral even exist? Let's depict the graph of the integrand in the drawing:

Everything is fine. The integrand is continuous on the interval and the definite integral is numerically equal to the shaded area. Yes, that's just one snag - the integral is not taken. And in such cases, numerical methods come to the rescue. In this case, the problem occurs in two formulations:

1) Calculate the definite integral approximately , rounding the result to a certain decimal place. For example, up to two decimal places, up to three decimal places, etc. Let's say you get an approximate answer of 5.347. In fact, it may not be entirely correct (actually, let's say the more accurate answer is 5.343). Our task is only in that to round the result to three decimal places.

2) Calculate the definite integral approximately, with a certain precision. For example, calculate the definite integral approximately with an accuracy of 0.001. What does it mean? This means that we must find such an approximate value that modulo (one way or the other) differs from the truth by no more than 0.001.

There are several basic methods for the approximate calculation of a definite integral that occurs in problems:

The segment of integration is divided into several parts and a stepped figure is constructed, which is close in area to the desired area:

Do not judge strictly by the drawings, the accuracy is not perfect - they only help to understand the essence of the methods.

The idea is similar. The integration segment is divided into several intermediate segments, and the graph of the integrand approaches broken line line:

So our area (blue shading) is approximated by the sum of the areas of the trapezoids (red). Hence the name of the method. It is easy to see that the trapezoid method gives a much better approximation than the rectangle method (with the same number of partition segments). And, of course, the more smaller intermediate segments we consider, the higher the accuracy will be. The trapezoid method is encountered from time to time in practical tasks, and in this article several examples will be analyzed.

Simpson's method (parabola method). This is a more perfect way - the graph of the integrand is approached not by a broken line, but by small parabolas. How many intermediate segments - so many small parabolas. If we take the same three segments, then the Simpson method will give an even more accurate approximation than the rectangle method or the trapezoid method.

I don’t see the point in building a drawing, since visually the approximation will be superimposed on the graph of the function (the broken line of the previous paragraph - and even then it almost coincided).

The task of calculating a definite integral using the Simpson formula is the most popular task in practice. And the method of parabolas will be given considerable attention.

How to calculate a definite integral using the trapezoid method?

First, the general formula. Perhaps it will not be clear to everyone and not immediately ... Yes, Karlsson is with you - practical examples will clarify everything! Calm. Only calmness.

Consider the definite integral , where is a function continuous on the segment . Let us divide the segment into equal segments:
. In this case, obviously: (lower limit of integration) and (upper limit of integration). points also called knots.

Then the definite integral can be calculated approximately by the trapezoid formula:
, where:
step;
are the values ​​of the integrand at points .

Example 1

Calculate an approximately definite integral using the trapezoid formula. Round the results to three decimal places.

a) Dividing the integration segment into 3 parts.
b) Dividing the segment of integration into 5 parts.

Solution:
a) Especially for dummies, I tied the first paragraph to the drawing, which clearly demonstrated the principle of the method. If it will be difficult, look at the drawing in the course of the comments, here is a piece of it:

By condition, the integration segment must be divided into 3 parts, that is, .
Calculate the length of each segment of the partition: . Parameter, I remind you, is also called step.

How many points (partition nodes) will there be? There will be one more than the number of segments:

Well, the general formula of trapezoids is reduced to a pleasant size:

For calculations, you can use a regular microcalculator:

Note that, in accordance with the condition of the problem, all calculations should be rounded to the 3rd decimal place.

Finally:

From a geometric point of view, we calculated the sum of the areas of three trapezoids (see picture above).

b) We divide the integration segment into 5 equal parts, that is, . Why is this needed? So that Phobos-Grunt does not fall into the ocean - by increasing the number of segments, we increase the accuracy of calculations.

If , then the trapezoid formula takes the following form:

Let's find the partitioning step:
, that is, the length of each intermediate segment is 0.6.

When finishing the task, it is convenient to draw up all calculations with a calculation table:

In the first line we write "counter"

I think everyone can see how the second line is formed - first we write down the lower integration limit , we get the remaining values ​​by successively adding the step .

By what principle the bottom line is filled, too, I think, almost everyone understood. For example, if , then . What is called, consider, do not be lazy.

As a result:

Well, there really is a clarification, and a serious one! If for 3 segments of the partition the approximate value was, then for 5 segments . Thus, with a high degree of certainty, it can be argued that, at least .

Example 2

Calculate an approximately defined integral using the trapezoid formula with an accuracy of two decimal places (up to 0.01).

Solution: Almost the same problem, but in a slightly different formulation. The fundamental difference from Example 1 is that we we don't know, INTO HOW MANY segments to split the integration segment in order to get two correct decimal places. In other words, we do not know the value of .

There is a special formula that allows you to determine the number of partition segments to ensure that the required accuracy is achieved, but in practice it is often difficult to apply. Therefore, it is advantageous to use a simplified approach.

First, the integration segment is divided into several large segments, as a rule, into 2-3-4-5. Let us divide the integration segment, for example, into the same 5 parts. The formula is already familiar:

And the step, of course, is also known:

But another question arises, to what digit should the results be rounded? The condition does not say anything about how many decimal places to leave. The general recommendation is: 2-3 digits must be added to the required accuracy. In this case, the required accuracy is 0.01. According to the recommendation, after the comma, for fidelity, we leave five characters (four could have been):

As a result:
, we denote the approximation by .

After the primary result, the number of segments double. In this case, it is necessary to divide into 10 segments. And when the number of segments grows, then a bright thought comes to mind that poking fingers into a microcalculator is already somehow tired. Therefore, I once again propose to download and use my semi-automatic calculator (link at the beginning of the lesson).

For the trapezoid formula takes the following form:

In the paper version, the entry can be safely transferred to the next line.

Let's calculate the partition step:

The results of the calculations are summarized in the table:


When finishing in a notebook, it is advantageous to turn a long table into a two-story table.

As a result:

Now we calculate the discrepancy between the approximations:

Here we use the modulo sign, since we are interested in absolute difference, and not which result is greater, but which is less.

As for further actions, I personally encountered 2 solutions in practice:

1) The first way is a “head-to-head comparison”. Since the resulting error estimate more than the required accuracy: , then it is necessary to double the number of segments of the partition up to and calculate already . With the help of an Excel calculator, the finished result can be obtained in a matter of seconds:. Now we estimate the error again: . Score received less than the required accuracy: , therefore, the calculations are completed. It remains to round the last (most accurate) result to two decimal places and give an answer.

2) Another, more efficient method is based on the use of the so-called Runge rules, according to which we are wrong in estimating the definite integral, in fact, by no more than . In our problem: , thus, the need for calculation disappears. However, for the speed of the solution in this case, we had to pay with accuracy: . Nevertheless, this result is acceptable, since our “error limit” is exactly one hundredth.

What to choose? Focus on your training manual or the preferences of the teacher.

Answer: accurate to 0.01 (when using Runge's rule).

Example 3

Calculate an approximately definite integral using the trapezoid formula with an accuracy of 0.001.

Before you is again an untaken integral (almost integral cosine). In the sample solution, at the first step, a division into 4 segments was carried out, that is, . A complete solution and an approximate sample of finishing at the end of the lesson.

How to calculate the definite integral using Simpson's formula?

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 number 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. I.e, IT IS FORBIDDEN reduce, for example, by two, getting . Recording only stands for 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 trapezoid method, there is a formula that will immediately allow you to determine the required number of segments (the “en” value) 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:

Let's find the absolute value of the difference between the approximations:

Runge's rule for Simpson's method is delicious. If when using middle rectangle method and the trapezoid method, we are given an “indulgence” of one third, now - as much as one fifteenth:
, and accuracy does not suffer here anymore:

But for the sake of completeness, I will also give a “simple” solution, where you have to take an additional step: since there is more than the required accuracy: , then it is necessary 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 quite 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. A rough example of finishing work and an 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. Calculations are carried out with an accuracy of three decimal places.

Today we will get acquainted with another method of numerical integration, the trapezoidal method. With its help, we will calculate definite integrals with a given degree of accuracy. In the article, we will describe the essence of the trapezoid method, analyze how the formula is derived, compare the trapezoid method with the rectangle method, and write down the estimate of the absolute error of the method. We will illustrate each of the sections with examples for a deeper understanding of the material.

Suppose that we need to approximately calculate the definite integral ∫ a b f (x) d x , whose integrand y = f (x) is continuous on the segment [ a ; b] . To do this, we divide the segment [ a ; b ] into several equal intervals of length h with points a = x 0< x 1 < x 2 < . . . < x n - 1 < x n = b . Обозначим количество полученных интервалов как n .

Let's find the partition step: h = b - a n . We define nodes from the equality x i = a + i h , i = 0 , 1 , . . . , n .

On elementary intervals, consider the integrand x i - 1 ; x i , i = 1 , 2 , . . , n .

With an infinite increase in n, we reduce all cases to the four simplest options:

Select segments x i - 1 ; x i , i = 1 , 2 , . . . , n . Let's replace the function y = f (x) on each of the graphs with a straight line segment that passes through the points with coordinates x i - 1 ; f x i - 1 and x i ; f x i . We mark them in the figures in blue.

Let's take the expression f (x i - 1) + f (x i) 2 h as an approximate value of the integral ∫ x i - 1 x if (x) d x . Those. take ∫ x i - 1 x i f (x) d x ≈ f (x i - 1) + f (x i) 2 h .

Let's see why the numerical integration method we are studying is called the trapezoidal method. To do this, we need to find out what the written approximate equality means from the point of view of geometry.

To calculate the area of ​​a trapezoid, multiply the half sums of its bases by the height. In the first case, the area of ​​a curvilinear trapezoid is approximately equal to a trapezoid with bases f (x i - 1) , f (x i) height h . In the fourth of the cases we are considering, the given integral ∫ x i - 1 x f (x) d x is approximately equal to the area of ​​a trapezoid with bases - f (x i - 1) , - f (x i) and height h, which must be taken with the sign "-". In order to calculate the approximate value of the definite integral ∫ x i - 1 x i f (x) d x in the second and third of the considered cases, we need to find the difference between the areas of the red and blue regions, which we marked with hatching in the figure below.

Let's summarize. The essence of the trapezoidal method is as follows: we can represent the definite integral ∫ abf (x) dx as a sum of integrals of the form ∫ xi - 1 xif (x) dx on each elementary segment and in the subsequent approximate change ∫ xi - 1 xif (x) dx ≈ f (xi - 1) + f (xi) 2 h.

Trapezoidal formula

Recall the fifth property of the definite integral: ∫ a b f (x) d x = ∑ i = 1 n ∫ x i - 1 x i f (x) d x . In order to obtain the formula of the trapezoidal method, instead of the integrals ∫ xi - 1 xif (x) dx, it is necessary to substitute their approximate values: ∫ xi - 1 xif (x) dx = ∑ i = 1 n ∫ xi - 1 xif (x) dx ≈ ∑ i = 1 nf (xi - 1) + f (xi) 2 h = = h 2 (f (x 0) + f (x 1) + f (x 1) + f (x 2) + f (x 2) + f (x 3) + . . . + f (xn)) = = h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (xi) + f (xn) ⇒ ∫ xi - 1 xif (x) dx ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (xi) + f (xn)

Definition 1

Trapezoidal formula:∫ x i - 1 x i f (x) d x ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (x i) + f (x n)

Estimation of the absolute error of the trapezoidal method

Let us estimate the absolute error of the trapezoidal method as follows:

Definition 2

δ n ≤ m a x x ∈ [ a ; b ] f "" (x) n h 3 12 = m a x x ∈ [ a ; b ] f "" (x) b - a 3 12 n 2

A graphic illustration of the trapezoidal method is shown in the figure:

Calculation examples

Let us analyze examples of using the trapezoid method for the approximate calculation of definite integrals. We will pay special attention to two types of tasks:

  • calculation of a definite integral by the trapezoid method for a given number of partitions of the segment n;
  • finding an approximate value of a certain integral with a specified accuracy.

For a given n, all intermediate calculations must be carried out with a sufficiently high degree of accuracy. The accuracy of the calculations should be those higher, the larger n .

If we have a given accuracy of calculating a definite integral, then all intermediate calculations must be carried out two or more orders of magnitude more accurately. For example, if the accuracy is set to 0 . 01 , then we perform intermediate calculations with an accuracy of 0 . 0001 or 0 . 00001 . For large n, intermediate calculations must be carried out with even higher accuracy.

Let's take the above rule as an example. To do this, we compare the values ​​of a definite integral calculated by the Newton-Leibniz formula and obtained by the trapezoid method.

So, ∫ 0 5 7 d x x 2 + 1 = 7 a r c t g (x) 0 5 = 7 a r c t g 5 ≈ 9 , 613805 .

Example 1

Using the trapezoidal method, we calculate the definite integral ∫ 0 5 7 x 2 + 1 d x for n equal to 10 .

Solution

The formula for the trapezoidal method is ∫ x i - 1 x i f (x) d x ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (x i) + f (x n)

In order to apply the formula, we need to calculate the step h using the formula h = b - a n , determine the nodes x i = a + i h , i = 0 , 1 , . . . , n , calculate the values ​​of the integrand f (x) = 7 x 2 + 1 .

The partition step is calculated as follows: h = b - a n = 5 - 0 10 = 0 . five . To calculate the integrand at the nodes x i = a + i · h , i = 0 , 1 , . . . , n we will take four decimal places:

i \u003d 0: x 0 \u003d 0 + 0 0. 5 = 0 ⇒ f (x 0) = f (0) = 7 0 2 + 1 = 7 i = 1: x 1 = 0 + 1 0 . 5 = 0 . 5 ⇒ f (x 1) = f (0 . 5) = 7 0 . 5 2 + 1 = 5 . 6 . . . i = 10: x 10 = 0 + 10 0 . 5 = 5 ⇒ f(x 10) = f(5) = 7 5 2 + 1 ≈ 0 , 2692

Let's enter the results of the calculations in the table:

i 0 1 2 3 4 5 6 7 8 9 10
x i 0 0 . 5 1 1 , 5 2 2 , 5 3 3 , 5 4 4 , 5 5
f (x i) 7 5 , 6 3 , 5 2 , 1538 1 , 4 0 , 9655 0 , 7 0 , 5283 0 , 4117 0 , 3294 0 , 2692

Substitute the obtained values ​​into the formula of the trapezoidal method: ∫ 0 5 7 dxx 2 + 1 ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (xi) + f (xn) = = 0 , 5 2 7 + 2 5 , 6 + 3 , 5 + 2 , 1538 + 1 , 4 + 0 , 9655 + 0 , 7 + 0 , 5283 + 0 , 4117 + 0 , 3294 + 0 , 2692 = 9 , 6117

Let's compare our results with the results calculated by the Newton-Leibniz formula. The received values ​​coincide up to hundredths.

Answer:∫ 0 5 7 d x x 2 + 1 = 9 , 6117

Example 2

Using the trapezoid method, we calculate the value of the definite integral ∫ 1 2 1 12 x 4 + 1 3 x - 1 60 d x with an accuracy of 0 , 01 .

Solution

According to the condition of the problem a = 1 ; b = 2 , f (x) = 1 12 x 4 + 1 3 x - 1 60 ; δn ≤ 0 , 01 .

Find n , which is equal to the number of split points of the integration segment, using the inequality for estimating the absolute error δ n ≤ m a x x ∈ [ a ; b ] f "" (x) (b - a) 3 12 n 2 . We will do it in the following way: we will find the values ​​n for which the inequality m a x x ∈ [ a ; b ] f "" (x) (b - a) 3 12 n 2 ≤ 0 , 01 . Given n, the trapezoid formula will give us an approximate value of a certain integral with a given accuracy.

First, let's find the largest value of the modulus of the second derivative of the function on the interval [ 1 ; 2].

f "(x) = 1 12 x 4 + 1 3 x - 1 60" = 1 3 x 3 + 1 3 ⇒ f "" (x) = 1 3 x 3 + 1 3 " = x 2

The second derivative function is a quadratic parabola f "" (x) = x 2 . We know from its properties that it is positive and increases on the segment [ 1 ; 2]. In this regard, m a x x ∈ [ a ; b ] f "" (x) = f "" (2) = 2 2 = 4 .

In the given example, the process of finding m a x x ∈ [ a ; b ] f "" (x) turned out to be rather simple. In complex cases, for calculations, you can refer to the largest and smallest values ​​of the function. After considering this example, we present an alternative method for finding m a x x ∈ [ a ; b ] f "" (x) .

Let us substitute the obtained value into the inequality m a x x ∈ [ a ; b ] f "" (x) (b - a) 3 12 n 2 ≤ 0 , 01

4 (2 - 1) 3 12 n 2 ≤ 0 . 01 ⇒ n 2 ≥ 100 3 ⇒ n ≥ 5 . 7735

The number of elementary intervals into which the integration segment is divided n is a natural number. For calculation behavior, let's take n equal to six. Such a value of n will allow us to achieve the specified accuracy of the trapezoid method with a minimum of calculations.

Let's calculate the step: h = b - a n = 2 - 1 6 = 1 6 .

Find nodes x i = a + i h , i = 1 , 0 , . . . , n , we determine the values ​​of the integrand at these nodes:

i = 0: x 0 = 1 + 0 1 6 = 1 ⇒ f (x 0) = f (1) = 1 12 1 4 + 1 3 1 - 1 60 = 0 , 4 i = 1: x 1 \u003d 1 + 1 1 6 \u003d 7 6 ⇒ f (x 1) \u003d f 7 6 \u003d 1 12 7 6 4 + 1 3 7 6 - 1 60 ≈ 0, 5266. . . i \u003d 6: x 10 \u003d 1 + 6 1 6 \u003d 2 ⇒ f (x 6) \u003d f (2) \u003d 1 12 2 4 + 1 3 2 - 1 60 ≈ 1, 9833

We write the calculation results in the form of a table:

i 0 1 2 3 4 5 6
x i 1 7 6 4 3 3 2 5 3 11 6 2
f x i 0 , 4 0 , 5266 0 , 6911 0 , 9052 1 , 1819 1 , 5359 1 , 9833

We substitute the results obtained into the trapezoid formula:

∫ 1 2 1 12 x 4 + 1 3 x - 1 60 dx ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (xi) + f (xn) = = 1 12 0 , 4 + 2 0, 5266 + 0, 6911 + 0, 9052 + 1, 1819 + 1, 5359 + 1, 9833 ≈ 1, 0054

To compare, we calculate the original integral using the Newton-Leibniz formula:

∫ 1 2 1 12 x 4 + 1 3 x - 1 60 d x = x 5 60 + x 2 6 - x 60 1 2 = 1

As you can see, we have achieved the obtained accuracy of calculations.

Answer: ∫ 1 2 1 12 x 4 + 1 3 x - 1 60 d x ≈ 1, 0054

For complex integrands, finding the number n from the inequality for estimating the absolute error is not always easy. In this case, the following method would be appropriate.

Let us denote the approximate value of the definite integral, which was obtained by the trapezoid method for n nodes, as I n . Let's choose an arbitrary number n . Using the formula of the trapezoid method, we calculate the initial integral for a single (n = 10) and double (n = 20) number of nodes and find the absolute value of the difference between the two obtained approximate values ​​I 20 - I 10 .

If the absolute value of the difference between the two obtained approximate values ​​is less than the required accuracy I 20 - I 10< δ n , то мы прекращаем вычисления и выбираем значение I 20 , которое можно округлить до требуемого порядка точности.

If the absolute value of the difference between the two obtained approximate values ​​is greater than the required accuracy, then it is necessary to repeat the steps with twice the number of nodes (n = 40).

This method requires a lot of calculations, so it is wise to use computer technology to save time.

Let's solve the problem using the above algorithm. In order to save time, we omit intermediate calculations using the trapezoid method.

Example 3

It is necessary to calculate the definite integral ∫ 0 2 x e x d x using the trapezoid method with an accuracy of 0 , 001 .

Solution

Let's take n equal to 10 and 20 . According to the trapezoid formula, we get I 10 \u003d 8, 4595380, I 20 \u003d 8, 4066906.

I 20 - I 10 = 8, 4066906 - 8, 4595380 = 0, 0528474 > 0, 001, which requires further calculations.

Let's take n equal to 40: I 40 = 8, 3934656.

I 40 - I 20 = 8, 3934656 - 8, 4066906 = 0, 013225 > 0, 001, which also requires further calculations.

Let's take n equal to 80: I 80 = 8 , 3901585 .

I 80 - I 40 = 8.3901585 - 8.3934656 = 0.0033071 > 0.001, which requires another doubling of the number of nodes.

Let's take n equal to 160: I 160 = 8, 3893317.

I 160 - I 80 = 8, 3893317 - 8, 3901585 = 0, 0008268< 0 , 001

You can get an approximate value of the original integral by rounding I 160 = 8 , 3893317 to thousandths: ∫ 0 2 x e x d x ≈ 8 , 389 .

For comparison, we calculate the original definite integral using the Newton-Leibniz formula: ∫ 0 2 x e x d x = e x · (x - 1) 0 2 = e 2 + 1 ≈ 8 , 3890561 . The required accuracy has been achieved.

Answer: ∫ 0 2 x e x d x ≈ 8, 389

Errors

Intermediate calculations to determine the value of a definite integral are carried out, for the most part, approximately. This means that as n increases, the computational error begins to accumulate.

Let us compare the estimates of the absolute errors of the trapezoidal method and the method of mean rectangles:

δ n ≤ m a x x ∈ [ a ; b ] f "" (x) n h 3 12 = m a x x ∈ [ a ; b ] f "" (x) b - a 3 12 n 2 δ n ≤ m a x x ∈ [ a ; b ] f "" (x) n h 3 24 = m a x x ∈ [ a ; b ] f "" (x) b - a 3 24 n 2 .

The method of rectangles for a given n with the same amount of computational work gives half the error. This makes the method more preferable in cases where the values ​​of the function are known in the middle segments of elementary segments.

In those cases when the integrable functions are specified not analytically, but as a set of values ​​at the nodes, we can use the trapezoidal method.

If we compare the accuracy of the trapezoidal method and the method of right and left rectangles, then the first method surpasses the second in the accuracy of the result.

If you notice a mistake in the text, please highlight it and press Ctrl+Enter

Exercises.

5.1 Calculate by the quadrature formula of rectangles with n= 3 integral and compare with the exact value of the integral:

but) , I= 1; b) , I= ln 2;

in) , I= ; G) , I= 0,75.

5.2 Calculate by the quadrature formula of rectangles when n= 5 integral and evaluate the integration error:

5.3 Determine the number of nodes n, which must be used to calculate the integral using the formula of rectangles with an accuracy of 0.01:

but) ; b) ; in) ; G) .

5.4 Calculate the integral using the quadrature formula of rectangles with an accuracy of 0.01:

Consider the definite integral I(6) and draw the graph of the integrand (Fig. 17). Let us divide the interval of integration into n equal segments with points , where (Fig. 17).

Figure 17
f( X 1)
f( X 2)
f( x i)
f( x n -1)
f( x n)
f( X 0)
f( x i - 1)
f( x n- 2)
x0
x 1
x2
x i- 1
x i
xn-1
x n
xn-2
but
b
X
at
ABOUT

The length of each segment of the partition . In this case, it is obvious that for the partition points the relation will be true:

and x 0 = a And x n = b.

Connect the points of the graph of the function with the coordinates by segments. As a result, we get a broken line, which is a graph of a piecewise linear function (Fig. 17). On each segment of the partition, the function is given by the formula

At points, it takes the same values ​​as the function:

those. the function performs piecewise linear interpolation of the function on the segment (Fig. 17).

Let's calculate the integral:

This result has a simple geometric meaning: a figure bounded from below by an axis segment Oh, from above by a segment of function (13), from the sides by vertical straight lines and , is a trapezoid with bases of length and and height h, the area of ​​which is determined by formula (14) (Fig. 17).

The integral of the function over the entire segment is the sum of the integrals (14):

Quadrature formula

gives an approximate value of the integral I:

where is the remainder term (special notation). In the quadrature formula (16), which is called trapezoid quadrature formula , the nodes are the points, the weight factors all but two at and are the same and equal to , and the weight coefficients at and are equal to . Formula (16) expresses the area of ​​a curvilinear trapezoid, corresponding to the integral I, through the sum of the areas of trapezoids (14) (Fig. 17).

Formula (7) or (7ʹ) for the value was constructed as an integral sum. When deriving formula (15) for , the concept of an integral sum was not used, but it can also be considered as an integral sum. Therefore, if the function is integrable on , then by the definition of a definite integral



those. the convergence conditions for the quadrature trapezoid formula (16) are satisfied in this case.

Limit relations (17) prove the fundamental possibility of calculating the definite integral of an arbitrary integrable function by the trapezoid method with any accuracy ε by choosing a number n splitting points of the segment and the corresponding step h.

Let us consider the main question related to the organization of a real computing process: how to take n in order to achieve the required accuracy when calculating the definite integral (6) ε . To do this, it is necessary to evaluate the residual term (error) . In this regard, the integrand must not only be integrable, but also twice continuously differentiable on the interval . If all the conditions described above are satisfied, then the following estimate holds for the remainder term

where M is a positive number satisfying condition (11).

For a given accuracy ε condition (18) allows us to determine the number of nodes n, which must be used when calculating the definite integral (6). To do this, it suffices to use the ratio

Example 1 Calculate by the quadrature formula of trapezoids with n= 3 integral

Compare with the exact value of the integral.

Solution.

Because n= 3, then step

And given that and:

Hence, by formula (15) we have

Consequently, .

Let us compare the obtained approximate value with the exact value of the integral

Answer: , .

Example 2 Determine the number of nodes n, which must be used to calculate the integral using the trapezoid formula

with an accuracy of 0.01.

Solution.

For determining n, we use relation (19)

According to the task and ε = 0.01. Taking into account that the integrand and its first and second derivatives are respectively equal to and , then on the integration segment we have = . Means M= 1. As a result, we obtain the relation

From which we determine n:

ah, then let's take n = 6.

Therefore, in order to achieve accuracy ε = 0.01, you need to take 7 nodes.

Answer:n = 6.

Example 3 Calculate the integral using the quadrature trapezoid formula

with an accuracy of 0.01.

Solution.

Let us first determine the number of nodes n, which must be used to calculate the integral. According to the task, ε = 0.01 and . Because

and for running

then M= 2. Substituting the values a, b, ε And M into formula (12) we obtain the relation:

From which we find n.

ah, then let's take n = 5.

Because n= 5, then step

Let's find the values ​​using the ratio

And given that , and b :

Now let's calculate the values ​​of the integrand at the points , :

Hence, by formula (15) we have

Consequently, .

Answer: with an accuracy of 0.01.

Let the division of the segment into parts , be again taken. Approximately replace the area under the graph, lying above the partition interval, with the area of ​​the trapezoid, the parallel bases of which are the segments that specify the values ​​of the function at the ends of the interval, that is, and (see Fig.).

Then the area of ​​such a trapezoid is obviously equal to

Summing up all the areas, we get the quadrature trapezoid formula:

This is the same formula that was obtained by combining the formulas of the left and right rectangles, in which we denoted the right side by .

Note that when calculating the area of ​​each next trapezoid, it is enough to calculate the value of the function only at one new point - at the right end of the next interval, since the point was the right end of the previous segment and the value at this point has already been calculated when finding the area of ​​the previous trapezoid.

If all segments of the partition are chosen to be of the same length, then the trapezoid formula takes the form

All values ​​of the function except and occur twice in this formula. Therefore, by combining equal terms, we can write the trapezoid formula in the form

Let the function have a second derivative that preserves sign on the interval . As can be easily seen from the previous figure, the nature of the error of this quadrature formula is as follows: if , that is, if the graph is convex upwards, then and, therefore, ; if the graph also has a downward convexity, then and .

If we compare this with the values ​​of the error of the formula of central rectangles studied above, then we see that for functions whose second derivative retains its sign on the integration interval, the signs of the errors and are opposite. There is a desire to combine the formula of trapezoids and the formula of central rectangles so that these errors are compensated as far as possible. In order to understand which combination of formulas should be taken, we need to find out what value these errors have and, depending on the choice step. These error estimates are also of independent importance, since they make it possible to find out the accuracy of the approximate value of the integral obtained by applying the corresponding quadrature formula.

The Monte Carlo method for calculating one-dimensional integrals is usually not used, since quadrature formulas are more convenient to obtain high accuracy. This method turns out to be more efficient when calculating multiple integrals, when cubature formulas are too cumbersome and require a large amount of calculations to achieve a small error.

When using quadrature or cubature formulas, the number of operations increases rapidly with the growth of the dimension of the integral. For example, if in order to calculate a one-dimensional integral by the trapezoid method with a given accuracy, it is necessary to calculate the sum of the order N terms, then to calculate the double integral by the same method, it is necessary to add order N 2 terms, and for the triple integral the number of terms is of the order N 3 .


Number of trials N required to achieve the specified accuracy ε approximate value, in the Monte Carlo method there is a quantity of order and does not depend on the dimension of the integral .

The following selection criterion is applied between the cubature formula R-th order of accuracy and the Monte Carlo method for calculating with accuracy ε multiple integral of the function m variables:

1) if the number of dimensions m < 2R, it is better to use cubature or quadrature formulas;

2) if m > 2RMonte Carlo method.

For example, if R= 1, it is more advantageous to calculate triple integrals by the Monte Carlo method, and one-dimensional integrals - by quadrature formulas.

If R= 2, it is better to calculate five-dimensional integrals by the Monte Carlo method, and one-dimensional, double and triple integrals - by quadrature or cubature formulas.

Let us consider specific formulas of the Monte Carlo method for calculating multiple integrals, which are obtained by the method that was used to derive formula (9.7).

Let it be required to calculate the double integral

Let's run a series of N random point tests ( x i, y i), where x i a, b], a y i uniformly distributed on the interval [ from, d]. Let us calculate the integral (9.9) by the formula

For the triple integral, we similarly obtain the formula

where x i uniformly distributed on the interval [ a, b], y i– on the segment [ from, d], a z i– on the segment [ R, q]; N is the number of trials.

For m-fold integral, the formula of the Monte Carlo method has the form



What else to read