Numerical methods are a fairly large section of higher mathematics and serious textbooks on this topic contain hundreds of pages. In practice, test papers traditionally propose to solve some problems using numerical methods, and one of the common problems is approximate calculation definite integrals. In this article I will look at two methods for approximate calculation of the definite integral - trapezoid method And Simpson method.
What do you need to know to master these methods? It may sound funny, but you may not be able to take integrals at all. And you don’t even understand what integrals are. From technical means you will need a microcalculator. Yes, yes, routine school calculations await us. Better yet, download my semi-automatic calculator for the trapezoidal method and the Simpson method. The calculator is written in Excel and will reduce the time required for solving and completing problems by tens of times. For Excel dummies, a video manual is included! By the way, the first video recording with my voice.
First, let's ask ourselves: why do we need approximate calculations at all? It seems that you can find the antiderivative of the function and use the Newton-Leibniz formula, calculating the exact value of the definite integral. To answer the question, let’s immediately look at a demo example with a picture.
Calculate definite integral
Everything would be fine, but in this example the integral is not taken - in front of you is an untaken integral, the so-called integral logarithm. Does this integral even exist? Let us depict in the drawing the graph of the integrand function:
Everything is fine. The integrand is continuous on the segment and the definite integral is numerically equal to the shaded area. There’s just one catch: the integral cannot be 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 assume the approximate answer is 5.347. In fact, it may not be entirely correct (in reality, say, the more accurate answer is 5.343). Our task is only that to round the result to three decimal places.
2) Calculate the definite integral approximately, with a certain accuracy. For example, calculate a definite integral approximately with an accuracy of 0.001. What does it mean? This means we must find 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 approximate calculation of the definite integral that occurs in problems:
The integration segment 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 ideal - 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 function approaches broken line line:
Thus, 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, naturally, the more smaller intermediate segments we consider, the higher the accuracy will be. The trapezoid method is found from time to time in practical tasks, and several examples will be discussed in this article.
Simpson's method (parabola method). This is a more advanced method - the graph of the integrand is approximated not by a broken line, but by small parabolas. There are as many small parabolas as there are intermediate segments. If we take the same three segments, then Simpson's method will give an even more accurate approximation than the rectangle method or the trapezoid method.
I don’t see the point in constructing a drawing, since the visual approximation will be superimposed on the graph of the function (the broken line of the previous paragraph - and even then it almost coincided).
The problem of calculating a definite integral using Simpson's formula is the most popular task in practice. And the parabola method will be given considerable attention.
First, the general formula. Perhaps it will not be immediately clear to everyone... yes, Karlsson is with you - practical examples will clarify everything! Calm. Only peace.
Let us consider the definite integral , where is a function continuous on the interval . Let's split the segment into equal segments:
. In this case, it is obvious: (lower limit of integration) and (upper limit of integration). Points also called nodes.
Then the definite integral can be calculated approximately according to the trapezoidal formula:
, Where:
step;
– values of the integrand at points .
Example 1
Calculate an approximately definite integral using the trapezoidal formula. Round the results to three decimal places.
a) Dividing the segment of integration into 3 parts.
b) Dividing the segment of integration into 5 parts.
Solution:
a) Especially for dummies, I linked the first point to a drawing that clearly demonstrated the principle of the method. If it’s difficult, look at the drawing as you comment, here’s a piece of it:
According to the condition, the integration segment must be divided into 3 parts, that is.
Let's calculate the length of each partition segment: . The 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 conditions 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) Let's divide the integration segment into 5 equal parts, that is. Why is this necessary? To prevent Phobos-Grunt from falling into the ocean, by increasing the number of segments, we increase the accuracy of the calculations.
If , then the trapezoidal formula takes the following form:
Let's find the partition step: , that is, the length of each intermediate segment is 0.6.
When finalizing the task, it is convenient to formalize all calculations using 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 limit of integration, the remaining values are obtained by successively adding the step.
I think almost everyone understood the principle by which the bottom line is filled out. For example, if , then . As they say, count, don’t 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 confidence we can say that, at least.
Example 2
Calculate an approximately definite integral using the trapezoidal formula accurate to two decimal places (up to 0.01).
Solution: Almost the same task, but in a slightly different formulation. The fundamental difference from Example 1 is that we we don't know, HOW MANY segments should we split the integration segment into to get two correct decimal places? In other words, we don't know the meaning of .
There is a special formula that allows you to determine the number of partition segments in order to guarantee the required accuracy, 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, usually 2-3-4-5. Let us divide the segment of integration, 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 says nothing about how many decimal places to leave. The general recommendation is: you need to add 2-3 digits to the required accuracy. In this case, the required accuracy is 0.01. According to the recommendation, after the decimal point we will leave five characters after the decimal point (four were possible):
As a result:
, let us denote the approximation by .
After the primary result, the number of segments double. In this case, it is necessary to split into 10 segments. And when the number of segments grows, the bright thought comes to mind that I’m somehow tired of poking my fingers at the microcalculator. Therefore, I once again suggest downloading and using 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 moved to the next line.
Let's calculate the partition step:
Let's summarize the calculation results in a table:
When finished in a notebook, it is advantageous to turn a long table into a two-story table.
As a result:
Now let's calculate the discrepancy between the approximations:
Here we use the modulus sign, since we are interested in absolute difference, and not which result is greater and which is less.
As for further actions, I personally have come across 2 solutions in practice:
1) The first method is “head-on comparison”. Since the resulting error estimate more than the required accuracy: , then it is necessary to once again double the number of segments of the partition up to and calculate . Using an Excel calculator, you can get the finished result in a matter of seconds: . Now we estimate the error again: . Received score less than the required accuracy:
, therefore, the calculations are completed. All that remains is to round the last (most accurate) result to two decimal places and give the answer.
2) Another, more effective method is based on the use of the so-called Runge's rules, according to which we are mistaken in estimating the definite integral by no more than . In our problem: thus, there is no need for calculation. However, the speed of solution in this case came at the cost of accuracy: . Nevertheless, this result is acceptable, since our “limit for error” is exactly one hundredth.
What to choose? Focus on your teaching method or teacher preferences.
Answer: accurate to 0.01 (using Runge's rule).
Example 3
Calculate an approximately definite integral using the trapezoidal formula with an accuracy of 0.001.
Here again is an integral integral (almost integral cosine). In the sample solution, the first step is divided into 4 segments, that is. A complete solution and an approximate sample of the final design at the end of the lesson.
If you were looking only for the Simpson method on this page, I strongly recommend that you first read the beginning of the lesson and look at 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
Let us consider the definite integral , where is a function continuous on the interval . Let's split the segment into even quantity equal segments. An even number of segments is denoted by .
In practice, the segments can be:
two:
four:
eight:
ten:
twenty:
I don't remember any other options.
Attention! The number is understood as a SINGLE NUMBER. That is, IT IS FORBIDDEN reduce, for example, by two, getting . Record only stands for, that the number of segments even. And there is no talk of any reductions
So, our partition looks like this:
The terms are similar to those of the trapezoidal method:
The points are called nodes.
Simpson's formula for the approximate calculation of the definite integral has the following form:
, Where:
– the length of each of the small segments or step;
– values of the integrand at points .
Detailing this heap, I will analyze the formula in more detail:
– the sum of the first and last values of the integrand;
– sum of terms with even indexes are multiplied by 2;
– sum of terms with odd indexes are multiplied by 4.
Example 4
Calculate the approximately definite integral using Simpson's formula with an accuracy of 0.001. Start splitting with two segments
The integral, by the way, is again insoluble.
Solution: I immediately draw your 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 using specific examples in the previous paragraph. As with 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, you will have to find the fourth derivative and solve the extremal problem. Those who understood what I meant and appreciated the amount of work, smiled. However, this is no laughing matter; finding the fourth derivative of such an integrand function will no longer be a mega-nerd, but a clinical psychopath. Therefore, in practice, a simplified error estimation method is almost always used.
Let's start deciding. If we have two segments of partition, then there will be nodes one more: . And Simpson's formula takes a very compact form:
Let's calculate the partition step:
Let's fill out the calculation table:
Let me comment once again on how the table is filled out:
In the top line we write the “counter” of indexes
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 should I 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 to 5-6 decimal places.
As a result:
The primary result has been received. 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 out the calculation table:
Thus:
Let's find the absolute value of the difference between the approximations:
Runge's rule for Simpson's method is very tasty. If when using middle rectangle method and the trapezoid method we are given a “indulgence” of one third, but now – as much as one fifteenth:
, and the accuracy here no longer suffers:
But to complete the picture, I will also give a “simple” solution, where you have to take an additional step: since there is more accuracy required: , 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:
And fill out the calculation table again:
Thus:
Please note that it is advisable to describe the calculations here in more detail, since Simpson’s formula is quite cumbersome, and if you immediately bang:
, then this booze will look like hack work. And with a more detailed note, the teacher will have the good impression that you conscientiously erased the keys of the microcalculator for a good hour. Detailed calculations for “hard” cases are available in my calculator.
We estimate the error:
The error is less than the required accuracy: . All that remains is to take the most accurate approximation, round it to three decimal places and write:
Answer: accurate to 0.001
Example 5
Calculate the approximately definite integral using Simpson's formula with an accuracy of 0.0001. Start splitting with two segments
This is an example for you to solve on your own. An approximate sample of the final design and the answer at the end of the lesson.
In the final part of the lesson, we’ll look at a couple more common examples.
Example 6
Calculate approximate value of definite integral using Simpson's formula, dividing the integration segment into 10 parts. Calculations must be carried out accurate to the third decimal place.
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 an estimate of the absolute error of the method. We will illustrate each section 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 interval [ a ; b ] . To do this, 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. Let's determine the nodes from the equality x i = a + i · h, i = 0, 1, . . . , n.
On elementary segments we consider the integrand function x i - 1 ; x i, i = 1, 2, . . , n.
As n increases infinitely, we reduce all cases to the four simplest options:
Let us select the segments x i - 1 ; x i, i = 1, 2, . . . , n. Let us 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 . Let's mark them in blue in the pictures.
Let us take the expression f (x i - 1) + f (x i) 2 · h as an approximate value of the integral ∫ x i - 1 x i f (x) d x. Those. let's 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 a geometric point of view.
In order to calculate the area of a trapezoid, it is necessary to multiply the half sums of its bases by its height. In the first case, the area of a curved 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 the 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 cases considered, we need to find the difference in 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 a definite integral ∫ a b f (x) d x as a sum of integrals of the form ∫ x i - 1 x i f (x) d x on each elementary segment and in the subsequent approximate replacement ∫ x i - 1 x i f (x) d x ≈ f (x i - 1) + f (x i) 2 · h.
Let us 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, it is necessary to substitute their approximate values instead of the integrals ∫ x i - 1 x i f (x) d x: ∫ x i - 1 x i f (x) d x = ∑ i = 1 n ∫ x i - 1 x i f (x) d x ≈ ∑ i = 1 n f (x i - 1) + f (x i) 2 h = = h 2 (f (x 0) + f (x 1) + f (x 1) + f (x 2) + f (x 2) + f (x 3) + . . . + f (x n)) = = h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (x i) + f (x n) ⇒ ∫ 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)
Definition 1
Trapezoidal method 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)
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:
Let's look at examples of using the trapezoidal method for approximate calculation of definite integrals. We will pay special attention to two types of tasks:
For a given n, all intermediate calculations must be carried out with a sufficiently high degree of accuracy. The accuracy of calculations should be higher, the larger n.
If we have a given accuracy in calculating a certain 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 carry out 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 look at the above rule with an example. To do this, compare the values of the definite integral calculated using the Newton-Leibniz formula and obtained using the trapezoidal 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 function f (x) = 7 x 2 + 1.
The partitioning step is calculated as follows: h = b - a n = 5 - 0 10 = 0. 5 . To calculate the integrand at the nodes x i = a + i · h, i = 0, 1, . . . , n we will take four decimal places:
i = 0: x 0 = 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 calculation results into 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 |
Let's substitute the obtained values into the formula of the trapezoidal method: ∫ 0 5 7 d x x 2 + 1 ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (x i) + f (x n) = = 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 using the Newton-Leibniz formula. The obtained values coincide to hundredths.
Answer:∫ 0 5 7 d x x 2 + 1 = 9 , 6117
Example 2
Using the trapezoidal 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.
Let us find n, which is equal to the number of points of partition 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 this as follows: we will find the values of n for which the inequality m a x x ∈ [ a ; b ] f "" (x) · (b - a) 3 12 n 2 ≤ 0.01. Given n, the trapezoidal formula will give us an approximate value of the definite 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 . From its properties we know that it is positive and increases on the interval [1; 2]. In this regard, m a x x ∈ [ a ; b ] f "" (x) = f "" (2) = 2 2 = 4 .
In the example given, the process of finding m a x x ∈ [ a ; b ] f "" (x) turned out to be quite simple. In complex cases, you can use the largest and smallest values of the function to perform calculations. After considering this example, we will present an alternative method for finding m a x x ∈ [ a ; b ] f "" (x) .
Let us substitute the resulting 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 n is divided is a natural number. For the calculation behavior, we take n equal to six. This value of n will allow us to achieve the specified accuracy of the trapezoidal method with a minimum of calculations.
Let's calculate the step: h = b - a n = 2 - 1 6 = 1 6 .
Let's find the 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 = 1 + 1 1 6 = 7 6 ⇒ f (x 1) = f 7 6 = 1 12 7 6 4 + 1 3 7 6 - 1 60 ≈ 0.5266. . . i = 6: x 10 = 1 + 6 1 6 = 2 ⇒ f (x 6) = f (2) = 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 |
Let's substitute the results obtained into the trapezoidal formula:
∫ 1 2 1 12 x 4 + 1 3 x - 1 60 d x ≈ h 2 f (x 0) + 2 ∑ i = 1 n - 1 f (x i) + f (x n) = = 1 12 0 , 4 + 2 0.5266 + 0.6911 + 0.9052 + 1.1819 + 1.5359 + 1.9833 ≈ 1.0054
To make a comparison, 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 calculation accuracy.
Answer: ∫ 1 2 1 12 x 4 + 1 3 x - 1 60 d x ≈ 1.0054
For integrands of complex form, finding the number n from the inequality for estimating the absolute error is not always easy. In this case, the following method will be appropriate.
Let us denote the approximate value of the definite integral, which was obtained using the trapezoidal method for n nodes, as I n. Let's choose an arbitrary number n. Using the formula of the trapezoidal 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 large amount 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 will omit intermediate calculations using the trapezoidal method.
Example 3
It is necessary to calculate the definite integral ∫ 0 2 x e x d x using the trapezoidal method with an accuracy of 0.001.
Solution
Let's take n equal to 10 and 20. Using the trapezoidal formula, we obtain I 10 = 8.4595380, I 20 = 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 continued 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
The approximate value of the original integral can be obtained by rounding I 160 = 8, 3893317 to thousandths: ∫ 0 2 x e x d x ≈ 8, 389.
For comparison, let's 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
Intermediate calculations to determine the value of a definite integral are mostly carried out approximately. This means that as n increases, the computational error begins to accumulate.
Let's compare the estimates of the absolute errors of the trapezoidal method and the average rectangle method:
δ 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 rectangle method 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 in the middle segments of elementary segments are known.
In cases where the functions to be integrated are not specified analytically, but as a set of values at nodes, we can use the trapezoidal method.
If we compare the accuracy of the trapezoid method and the right and left rectangle method, then the first method is superior to the second in the accuracy of the result.
If you notice an error in the text, please highlight it and press Ctrl+Enter
Exercises.
5.1 Calculate using the quadrature formula of rectangles at n= 3 integral and compare with the exact value of the integral:
A) , I= 1; b) , I= ln 2;
V) , I= ; G) , I= 0,75.
5.2 Calculate using the quadrature formula of rectangles at n= 5 integral and estimate the integration error:
5.3 Determine the number of nodes n, which must be used to calculate the integral using the rectangle formula with an accuracy of 0.01:
A) ; b) ; V) ; 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 plot the integrand function (Fig. 17). Let us divide the integration segment into n equal segments by 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) |
x 0 |
x 1 |
x 2 |
x i- 1 |
x i |
xn-1 |
x n |
x n- 2 |
A |
b |
X |
at |
ABOUT |
The length of each partition segment. In this case, it is obvious that the following relation will be valid for the partition points:
and x 0 = a And x n = b.
Let us connect the points of the graph of the function with coordinates with segments. As a result, we obtain a broken line, which is a graph of a piecewise linear function (Fig. 17). On each of the partition segments 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 a function on a segment (Figure 17).
Let's calculate the integral:
This result has a simple geometric meaning: a figure bounded 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 integrals (14):
Quadrature formula
gives an approximate value of the integral I:
where is the remainder term (special designation). In quadrature formula (16), which is called trapezoidal quadrature formula , the nodes are points , the weight factors are all, except two for and , the same and equal to , and the weight coefficients for and are equal to . To within an accuracy, 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 quantity 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. Consequently, if the function is integrable on , then by virtue of the definition of the definite integral
those. the convergence conditions for the trapezoidal quadrature formula (16) are satisfied in this case.
Limit relations (17) prove the fundamental possibility of calculating a definite integral of an arbitrary integrable function by the trapezoidal method with any accuracy ε by choosing a number n points of division of the segment and the corresponding step h.
Let's consider the main question related to the organization of a real computing process: what should be taken n in order to achieve the required accuracy when calculating the definite integral (6) ε . To do this, it is necessary to estimate 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 met, then the following estimate holds for the remainder term:
Where M– 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 is enough to use the relation
Example 1. Calculate using the quadrature formula of trapezoids at n= 3 integral
Compare with the exact value of the integral.
Solution.
Because n= 3, then step
And given that and:
This means that according to formula (15) we have
Hence, .
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 trapezoidal formula
with an accuracy of 0.01.
Solution.
For determining n, let's use relation (19)
According to the conditions of the problem and ε = 0.01. Considering that the integrand and its first and second derivatives are respectively equal to and , then on the integration interval = is true. Means M= 1. As a result, we obtain the relation
From which we determine n:
ah, then we'll take it n = 6.
Therefore, to achieve accuracy ε = 0.01, you need to take 7 nodes.
Answer:n = 6.
Example 3. Calculate the trapezoidal integral using the quadrature formula
with an accuracy of 0.01.
Solution.
Let's first determine the number of nodes n, which must be used to calculate the integral. According to the conditions of the problem, ε = 0.01 and . Because
and for is executed
That M= 2. Substituting values a, b, ε And M in formula (12) we obtain the relation:
From which we will find n.
ah, then we'll take it n = 5.
Because n= 5, then step
Let's find the values using the relation
And given that, and b :
Now let's calculate the values of the integrand at points , :
This means that according to formula (15) we have
Hence, .
Answer: with an accuracy of 0.01.
Let us again take a partition of the segment into parts , . Let us 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 figure).
Then the area of such a trapezoid is obviously equal to
Summing up all the areas, we get the quadrature trapezoidal 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 was already calculated when finding the area of the previous trapezoid.
If all segments of the partition are chosen to be the same length, then the trapezoidal formula takes the form
All values of the function except and appear in this formula twice. Therefore, by combining equal terms, we can write the trapezoidal formula in the form
Let the function have a second derivative that maintains sign on the interval. As is easily seen from the previous figure, the nature of the error in this quadrature formula is as follows: if , that is, if the graph is convex upward, then and, therefore, ; if the graph is convex downward, then .
If we compare this with the error values of the central rectangle formula studied above, we see that for functions whose second derivative retains its sign on the integration segment, 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 much as possible. In order to understand which combination of formulas should be taken, we need to find out what magnitude these errors have and, depending on the choice step. These error estimates also have independent significance, 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 effective 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 increasing dimension of the integral. For example, if to calculate a one-dimensional integral using the trapezoidal method with a given accuracy, it is necessary to calculate a sum of the order N terms, then to calculate the double integral using the same method it is necessary to add about N 2 terms, and for a triple integral the number of terms is about N 3 .
Number of tests N required to achieve a given accuracy ε approximate value, in the Monte Carlo method there is a value of the order of and does not depend on the dimension of the integral .
The following criterion for choosing between the cubature formula is applied R th order of accuracy and the Monte Carlo method for calculations with accuracy ε multiple integral of the function m variables:
1) if the number of dimensions is m < 2R, it is better to use cubature or quadrature formulas;
2) if m > 2R – Monte Carlo method.
For example, if R= 1, it is more profitable to calculate triple integrals using the Monte Carlo method, and one-dimensional integrals using quadrature formulas.
If R= 2, it is better to calculate five-dimensional integrals using the Monte Carlo method, and one-dimensional, double and triple integrals using quadrature or cubature formulas.
Let us consider specific formulas of the Monte Carlo method for calculating multiple integrals, obtained in the manner that was used to derive formula (9.7).
Suppose we need to calculate the double integral
Let's conduct a series of N random point tests ( x i, y i), Where x i a, b], a y i uniformly distributed on the segment [ With, d]. Let us calculate the integral (9.9) using the formula
For the triple integral, we similarly obtain the formula
Where x i uniformly distributed on the segment [ a, b], y i– on the segment [ With, d], a z i– on the segment [ R, q]; N– number of tests.
For m-multiple integral formula of the Monte Carlo method has the form
nanbaby.ru - Health and beauty. Fashion. Children and parents. Leisure. Life House