Derivation of the trapezoid formula for calculating integrals. Calculation of integrals using formulas of rectangles and trapezoids. Error estimate

How to calculate a definite integral using the trapezoidal method?

First the formula in general view. Perhaps it will not be immediately clear to everyone... yes, Karlsson is with you - practical examples everything will be cleared up! 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:
– the length of each of the small segments or step;
– values integrand function 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:

Thus, 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:

Let me remind you that the resulting value is an approximate value of the area (see figure 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 partition segments, 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. General recommendation is this: you need to add 2-3 digits to the required accuracy. IN 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:

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 one.

The trapezoidal method is one of the methods of numerical integration. It allows you to calculate definite integrals with a predetermined degree of accuracy.

Let us set ourselves the following task: let us need to approximately calculate a definite integral , where the integrand is y=f(x) continuous on

segment .

Let's split the segment on n equal length intervals h dots In this case, we find the partition step and determine which nodes from the equality.

Let us consider the integrand on elementary segments .

Four cases are possible (the figure shows the simplest of them, to which everything reduces with infinite magnification n):

On every segment replace the function y=f(x) a straight line segment passing through points with coordinates and. Let's depict them in the figure with blue lines:

As an approximate value of the integral, we take the expression , that is, let's accept .

Let's find out what the written approximate equality means in a geometric sense. This will make it possible to understand why the numerical integration method under consideration is called the trapezoidal method.

We know that the area of ​​a trapezoid is the product of half the sum of the bases and the height. Therefore, in the first case, the area of ​​a curved trapezoid is approximately equal to the area of ​​a trapezoid with bases and height h, in the latter case the definite integral is approximately equal to the area of ​​the trapezoid with the bases and height h, taken with a minus sign. In the second and third cases, the approximate value of the definite integral is equal to the difference in the areas of the red and blue regions shown in the figure below.

Thus we come to essence of the trapezoid method, which consists in representing a definite integral in the form of a sum of integrals seen on each elementary segment and in the subsequent approximate replacement .

Trapezoid method formula.

By virtue of the fifth property of the definite integral .

If we substitute their approximate values ​​instead of integrals, we get trapezoidal method formula:

Estimation of the absolute error of the trapezoidal method.

Absolute error of the trapezoidal method is assessed as.

Graphic illustration of the trapezoid method.

3. Simpson's method (parabolas)

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.

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

Let's split the segment on n elementary segments of length by points. Let the points be the midpoints of the segments, respectively. In this case, all "nodes" are determined from equality.

The essence of the parabola method.

At each interval, the integrand is approximated by a quadratic parabola , passing through the points. Hence the name of the method - the parabola method.

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

Geometrically it looks like this:

Graphic illustration of the parabola method (Simpson).

The red line shows the graph of the function y=f(x), the blue line shows the approximation of the function graph y=f(x) quadratic parabolas on each elementary segment of the partition.

Derivation of the formula for Simpson's method (parabolas).

By virtue of the fifth property of the definite integral, we have .

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

Let (we can always come to this by carrying out the corresponding geometric shift transformation for any i = 1, 2, ..., n).

Let's make a drawing.

Let us show that only one quadratic parabola passes through the points . In other words, we prove that the coefficients are determined in a unique way.


Trapezoid method is one of the methods of numerical integration. It allows you to calculate definite integrals with a predetermined degree of accuracy.

First, we describe the essence of the trapezoidal method and derive the trapezoidal formula. Next, we will write down an estimate of the absolute error of the method and analyze in detail the solution of typical examples. In conclusion, let's compare the trapezoid method with the rectangle method.

Page navigation.

The essence of the trapezoid method.

Let us set ourselves the following task: let us need to approximately calculate a definite integral, where the integrand function y=f(x) is continuous on the segment.

Let's divide the segment into n equal intervals of length h with points. In this case, we find the partition step as well as determine the nodes from the equality .

Let us consider the integrand on elementary segments .

There are four possible cases (the figure shows the simplest of them, to which everything comes down as n increases infinitely):


On every segment Let's replace the function y=f(x) with a straight line segment passing through the points with coordinates and . Let's depict them in the figure with blue lines:


As an approximate value of the integral, we take the expression , that is, let's accept .

Let's find out what the written approximate equality means in a geometric sense. This will make it possible to understand why the numerical integration method under consideration is called the trapezoidal method.

We know that the area of ​​a trapezoid is the product of half the sum of the bases and the height. Therefore, in the first case, the area of ​​a curved trapezoid is approximately equal to the area of ​​a trapezoid with bases and height h, in the latter case the definite integral is approximately equal to the area of ​​the trapezoid with the bases and height h, taken with a minus sign. In the second and third cases, the approximate value of the definite integral is equal to the difference in the areas of the red and blue regions shown in the figure below.


Thus we come to essence of the trapezoid method, which consists in representing a definite integral as a sum of integrals of the form on each elementary segment and in the subsequent approximate replacement .

Trapezoid method formula.

By virtue of the fifth property of the definite integral .

If we substitute their approximate values ​​instead of the integrals, we get:

Estimation of the absolute error of the trapezoidal method.

Absolute error of the trapezoidal method is estimated as
.

Graphic illustration of the trapezoid method.

Let's give graphic illustration of the trapezoid method:

Examples of approximate calculation of definite integrals by the trapezoidal method.

Let us look at examples of the use of the trapezoidal method in the approximate calculation of definite integrals.

There are mainly two types of tasks:

  • or calculate a definite integral using the trapezoidal method for a given number of partitions of the segment n,
  • or find the approximate value of a certain integral with the required accuracy.

It should be noted that for a given n, intermediate calculations should be carried out with a sufficient degree of accuracy, and the larger n, the higher the accuracy of calculations should be.

If you need to calculate a definite integral with a given accuracy, for example, up to 0.01, then we recommend performing intermediate calculations two to three orders of magnitude more accurately, that is, up to 0.0001 - 0.00001. If the specified accuracy is achieved at large n, then intermediate calculations should be carried out with even higher accuracy.

For example, let's take a definite integral, the value of which we can calculate using the Newton-Leibniz formula, so that we can compare this result with the approximate value obtained using the trapezoidal method.

So, .

Example.

Calculate the definite integral using the trapezoidal method for n = 10.

Solution.

The formula for the trapezoidal method has the form . That is, to use it, we just need to calculate the step h using the formula, determine the nodes and calculate the corresponding values ​​of the integrand.

Let's calculate the partition step: .

We define the nodes and calculate the values ​​of the integrand at them (we will take four decimal places):

For convenience, the calculation results are presented in the form of a table:

We substitute them into the formula of the trapezoidal method:

The resulting value coincides to hundredths with the value calculated using the Newton-Leibniz formula.

Example.

Calculate definite integral using the trapezoidal method with an accuracy of 0.01.

Solution.

What do we have from the condition: a = 1; b = 2 ; .

In this case, the first thing we do is find the number of points of partition of the integration segment, that is, n. We can do this by using the inequality to estimate the absolute error . Thus, if we find n for which the inequality will hold , then the trapezoidal formula for given n will give us an approximate value of a certain integral with the required accuracy.

Let's find it first highest value modulus of the second derivative of a function on the interval.

The second derivative of the function is a quadratic parabola, we know from its properties that it is positive and increasing on the interval, therefore . As you can see, in our example the finding process is quite simple. In more difficult cases refer to the section. If it is very difficult to find, then after this example we will give alternative method actions.

Let's return to our inequality and substitute the resulting value into it:

Because n is a natural number (n is the number of elementary intervals into which the integration segment is divided), then we can take n = 6, 7, 8, ... Let's take n = 6. This will allow us to achieve the required accuracy of the trapezoidal method with a minimum of calculations (although in our case with n = 10 it is more convenient to perform calculations manually).

So, n is found, now we proceed as in the previous example.

Calculate the step: .

We find the grid nodes and the values ​​of the integrand in them:

Let's enter the calculation results into the table:

We substitute the obtained results into the trapezoidal formula:

Let's calculate the original integral using the Newton-Leibniz formula to compare the values:

Therefore, the required accuracy has been achieved.

It should be noted that finding the number n from the inequality for estimating the absolute error is not a very simple procedure, especially for integrands complex type. Therefore, it is logical to resort to the following method.

The approximate value of the definite integral obtained using the trapezoidal method for n nodes will be denoted by .

We choose an arbitrary number n, for example n = 10. Using the formula of the trapezoidal method, we calculate the original integral for n = 10 and for twice the number of nodes, that is, for n = 20. We find the absolute value of the difference between the two obtained approximate values. If it is less than the required accuracy , then we stop the calculations and take the value as an approximate value of the definite integral, having first rounded it to the required order of accuracy. Otherwise, we double the number of nodes (take n = 40) and repeat the steps.

Ekaterinburg


Calculation of the definite integral

Introduction

The problem of numerical integration of functions is to calculate the approximate value of a certain integral:

, (1)

based on a series of values ​​of the integrand.( f(x) |x=x k = f(x k) = y k ).

Formulas for the numerical calculation of a single integral are called quadrature formulas, double and more multiple ones are called cubature formulas.

The usual technique for constructing quadrature formulas is to replace the integrand function f(x) on a segment with an interpolating or approximating function g(x) relatively simple type, for example, a polynomial, followed by analytical integration. This leads to the view

Neglecting the remainder term R[f] we obtain the approximate formula

.

Let us denote by y i = f(x i) the value of the integrand function in various points

on . Quadrature formulas are formulas of closed type if x 0 =a, x n =b.

As an approximate function g(x), we consider an interpolation polynomial on

in the form of a Lagrange polynomial: , , wherein , where is the remainder term of the Lagrange interpolation formula.

Formula (1) gives

, (2) . (3)

In formula (2) the quantities (

) are called nodes, () are called weights, and are called the error of the quadrature formula. If the weights () of a quadrature formula are calculated using formula (3), then the corresponding quadrature formula is called a quadrature formula of interpolation type.

Summarize.

) of quadrature formula (2) for a given location of nodes do not depend on the type of the integrand.

2. In interpolation-type quadrature formulas, the remainder term R n [f] can be represented as the value of a specific differential operator on the function f(x). For

.

3. For polynomials up to order n inclusive, quadrature formula (2) is exact, i.e.

. The highest degree of a polynomial for which the quadrature formula is exact is called the degree of the quadrature formula.

Let's consider special cases of formulas (2) and (3): the method of rectangles, trapezoids, parabolas (Simpson's method). The names of these methods are due to the geometric interpretation of the corresponding formulas.

Rectangle method

Definite integral of function f(x):

numerically equal to the area of ​​a curvilinear trapezoid bounded by the curves y=0, x=a, x=b, y=f(x) (Figure 1).
Rice. 1 Area under the curve y=f(x) To calculate this area, the entire integration interval is divided into n equal subintervals of length h=(b-a)/n. The area under the integrand is approximately replaced by the sum of the areas of the rectangles, as shown in Figure (2).
Rice. 2 The area under the curve y=f(x) is approximated by the sum of the areas of the rectangles
The sum of the areas of all rectangles is calculated by formula (4)

The method represented by formula (4) is called the left rectangle method, and the method represented by formula (5) is called the right rectangle method:

(5) The error in calculating the integral is determined by the value of the integration step h. How smaller step integration, the more accurately the integral sum S approximates the value of the integral I. Based on this, an algorithm is constructed for calculating the integral with a given accuracy. It is considered that the integral sum S represents the value of the integral I with an accuracy of eps if the difference in absolute value between the integral sums and calculated with steps h and h/2, respectively, does not exceed eps.

To find the definite integral by the method of average rectangles, the area bounded by lines a and b is divided into n rectangles with identical bases h; the heights of the rectangles will be the points of intersection of the function f(x) with the midpoints of the rectangles (h/2). The integral will be numerically equal to the sum areas of n rectangles (Figure 3).


Rice. 3 The area under the curve y=f(x) is approximated by the sum of the areas of the rectangles ,

n – number of partitions of the segment.

Trapezoid method

To find the definite integral by the trapezoidal method, the area of ​​a curvilinear trapezoid is also divided into n rectangular trapezoids with heights h and bases 1, 2, 3,..у 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. 4 The area under the curve y=f(x) is approximated by the sum of the areas of rectangular trapezoids.

n – number of partitions

(6)

The error of the trapezoidal formula is estimated by the number

Error of the trapezoidal formula with growth

decreases faster than the error of the rectangle formula. Therefore, the trapezoidal formula allows for greater accuracy than the rectangle method.

Simpson's formula

If for each pair of segments

construct a polynomial of the second degree, then integrate it on a segment and use the property of additivity of the integral, then we obtain Simpson’s formula. In Simpson's method, to calculate a definite integral, the entire integration interval is divided into subintervals of equal length h=(b-a)/n. The number of partition segments is an even number. Then, on each pair of adjacent subintervals, the integrand 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 segment. Let us replace this integrand with a Lagrange interpolation polynomial of the second degree, coinciding with y= at the points:

Educational tasks:

  • Didactic purpose. Introduce students to methods of approximate calculation of a definite integral.
  • Educational purpose. The topic of this lesson is of great practical and educational importance. The simplest way to approach the idea of ​​numerical integration is to rely on the definition of a definite integral as the limit of integral sums. For example, if we take any sufficiently small partition of the segment [ a; b] and construct an integral sum for it, then its value can be approximately taken as the value of the corresponding integral. At the same time, it is important to quickly and correctly carry out calculations using computer technology.

Basic knowledge and skills. Have an understanding of approximate methods for calculating a definite integral using the formulas of rectangles and trapezoids.

Providing classes

  • Handout. Cards-tasks for independent work.
  • TSO. Multi-projector, PC, laptops.
  • TSO equipment. Presentations: “Geometric meaning of derivatives”, “Method of rectangles”, “Method of trapezoids”. (Presentations can be obtained from the author).
  • Computing equipment: PC, microcalculators.
  • Guidelines

Type of lesson. Integrated practical.

Motivation cognitive activity students. Very often it is necessary to calculate definite integrals for which it is impossible to find an antiderivative. In this case, approximate methods for calculating definite integrals are used. Sometimes the approximate method is also used for “taken” integrals, if the calculation using the Newton-Leibniz formula is not rational. The idea of ​​approximate calculation of the integral is that the curve is replaced by a new curve that is sufficiently “close” to it. Depending on the choice of the new curve, one or another approximate integration formula can be used.

Sequence of the lesson.

  1. Rectangle formula.
  2. Trapezoid formula.
  3. Solution of exercises.

Lesson plan

  1. Repetition of students' basic knowledge.

Repeat with students: the basic formulas of integration, the essence of the studied methods of integration, the geometric meaning of a definite integral.

  1. Doing practical work.

The solution of many technical problems comes down to calculating definite integrals, exact expression which is complex, requires time-consuming calculations and is not always justified in practice. Here their approximate value is quite sufficient.

Let, for example, you need to calculate the area, bounded by a line, the equation of which is unknown. In this case, you can replace this line with a simpler one, the equation of which is known. The area of ​​the curvilinear trapezoid obtained in this way is taken as an approximate value of the desired integral.

The simplest approximate method is the rectangle method. Geometrically, the idea of ​​the method of calculating the definite integral using the rectangle formula is that the area of ​​a curvilinear trapezoid ABCD is replaced by the sum of the areas of rectangles, one side of which is equal to , and the other - .

If we sum up the areas of rectangles that show the area of ​​a curved trapezoid with a disadvantage [Figure 1], we get the formula:

[Picture 1]

then we get the formula:

If in excess

[Figure2],

That

Values y 0, y 1,..., y n found from equalities , k = 0, 1..., n.These formulas are called rectangle formulas and give an approximate result. With increase n the result becomes more accurate.

So, to find the approximate value of the integral, you need:

In order to find the calculation error, you need to use the formulas:


Example 1. Calculate using the rectangle formula. Find the absolute and relative errors of calculations.

Let's split the segment [ a, b] into several (for example, 6) equal parts. Then a = 0, b = 3 ,

x k = a + k x
X
0 = 2 + 0 = 2
X 1 = 2 + 1 = 2,5
X 2 = 2 + 2 =3
X 3 = 2 + 3 = 3
X 4 = 2 + 4 = 4
X 5 = 2 + 5 = 4,5

f(x 0) = 2 2 = 4
f (x 1) = 2 ,5 2 = 6,25
f (x 2) = 3 2 = 9
f (x 3) = 3,5 2 = 12,25
f (x 4) = 4 2 = 16
f (x 5) = 4,5 2 = 20,25.

X 2 2,5 3 3,5 4 4,5
at 4 6,25 9 12,25 16 20,25

According to formula (1):

In order to calculate the relative error of calculations, it is necessary to find the exact value of the integral:



The calculations took a long time and we ended up with a rather rough rounding. To calculate this integral with a smaller approximation, you can use the technical capabilities of a computer.

To find the definite integral using the rectangle method, you must enter the values ​​of the integrand f(x) to Excel worksheet in range X with a given step X= 0,1.

  1. Making a data table (X And f(x)). X f(x). Argument, and in cell B1 - the word Function2 2,1 ). Then, selecting the block of cells A2:A3, using autofill we get all the values ​​of the argument (we drag the lower right corner of the block to cell A32, to the value x=5).
  2. Next, we enter the values ​​of the integrand. In cell B2 you need to write down its equation. To do this, place the table cursor in cell B2 and enter the formula from the keyboard =A2^2(with English keyboard layout). Press the key Enter. In cell B2 appears 4 . Now you need to copy the function from cell B2. Using autofill, copy this formula to the range B2:B32.
    The result should be a table of data for finding the integral.
  3. Now in cell B33 the approximate value of the integral can be found. To do this, enter the formula in cell B33 = 0,1*, then call the Function Wizard (by clicking the Insert Function button on the toolbar (f(x)). In the dialog box that appears, Function Wizard - step 1 of 2, on the left in the Category field, select Mathematical. On the right in the Function field is the Sum function. Press the button OK. The Amounts dialog box appears. Using the mouse, enter the summation range B2:B31 into the work field. Press the button OK. In cell B33, an approximate value of the desired integral appears with a disadvantage ( 37,955 ) .

Comparing the obtained approximate value with the true value of the integral ( 39 ), one can see that the approximation error of the rectangle method in this case is equal to

= |39 - 37 , 955| = 1 ,045

Example 2. Using the rectangle method, calculate with a given step X = 0,05.

Comparing the obtained approximate value with the true value of the integral , one can see that the approximation error of the rectangle method in this case is equal to

The trapezoidal method usually gives a more accurate integral value than the rectangular method. The curved trapezoid is replaced by the sum of several trapezoids and the approximate value of the definite integral is found as the sum of the areas of the trapezoids

[Figure3]

Example 3. Find using the trapezoidal method in steps X = 0,1.

  1. Open a blank worksheet.
  2. Making a data table (X And f(x)). Let the first column be the values X, and the second with the corresponding indicators f(x). To do this, enter the word in cell A1 Argument, and in cell B1 - the word Function. The first value of the argument is entered into cell A2 - the left border of the range ( 0 ). The second value of the argument is entered into cell A3 - the left boundary of the range plus the construction step ( 0,1 ). Then, selecting the block of cells A2:A3, using autofill we get all the values ​​of the argument (we drag the lower right corner of the block to cell A33, to the value x=3.1).
  3. Next, we enter the values ​​of the integrand. In cell B2 you need to write down its equation (in the example of sine). To do this, the table cursor must be placed in cell B2. Here there should be a sine value corresponding to the value of the argument in cell A2. To obtain the sine value, we will use a special function: click on the Insert Function button on the toolbar f(x). In the dialog box that appears, Function Wizard - step 1 of 2, on the left in the Category field, select Mathematical. On the right in the Function field - function SIN. Press the button OK. A dialog box appears SIN. By placing the mouse pointer over the gray field of the window, with the left button pressed, move the field to the right to open the data column ( A). We indicate the value of the sine argument by clicking on cell A2. Press the button OK. A 0 appears in cell B2. Now you need to copy the function from cell B2. Using autofill, copy this formula to the range B2:B33. The result should be a table of data for finding the integral.
  4. Now in cell B34 the approximate value of the integral can be found using the trapezoidal method. To do this, enter the formula in cell B34 = 0.1*((B2+B33)/2+, then call the Function Wizard (by clicking the Insert Function button on the toolbar (f(x)). In the dialog box that appears, Function Wizard - step 1 of 2, on the left in the Category field, select Mathematical. On the right in the Function field is the Sum function. Press the button OK. The Amounts dialog box appears. Enter the summation range B3:B32 into the work field with the mouse. Press the button OK once again OK. In cell B34, an approximate value of the desired integral appears with a disadvantage ( 1,997 ) .

Comparing the obtained approximate value with the true value of the integral, one can see that the approximation error of the rectangle method in this case is quite acceptable for practice.

  1. Solution of exercises.
Share